| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// Rapid Optimization Library (ROL) Package |
| 4 |
// |
| 5 |
// Copyright 2014 NTESS and the ROL contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#ifndef ROL_CoupledConstraint_SimOpt_H |
| 11 |
#define ROL_CoupledConstraint_SimOpt_H |
| 12 |
|
| 13 |
#include "ROL_Constraint_SimOpt.hpp" |
| 14 |
|
| 15 |
#include "constraint.hpp" |
| 16 |
#include "volume_constraint_SimOpt.hpp" |
| 17 |
|
| 18 |
#include "ROL_TpetraMultiVector.hpp" |
| 19 |
#include "ROL_StdVector.hpp" |
| 20 |
#include "Amesos2.hpp" |
| 21 |
|
| 22 |
template<class Real> |
| 23 |
class EqualityConstraint_PDEOPT_ElasticitySIMP_Coupled : public ROL::Constraint_SimOpt<Real> { |
| 24 |
private: |
| 25 |
const ROL::Ptr<EqualityConstraint_PDEOPT_ElasticitySIMP<Real> > pde_; |
| 26 |
const ROL::Ptr<EqualityConstraint_PDEOPT_ElasticitySIMP_Volume_SimOpt<Real> > vol_; |
| 27 |
|
| 28 |
public: |
| 29 |
EqualityConstraint_PDEOPT_ElasticitySIMP_Coupled(const ROL::Ptr<EqualityConstraint_PDEOPT_ElasticitySIMP<Real> > &pde, |
| 30 |
const ROL::Ptr<EqualityConstraint_PDEOPT_ElasticitySIMP_Volume_SimOpt<Real> > &vol) : pde_(pde), vol_(vol) {} |
| 31 |
|
| 32 |
using ROL::Constraint_SimOpt<Real>::value; |
| 33 |
void value(ROL::Vector<Real> &c, const ROL::Vector<Real> &u, const ROL::Vector<Real> &z, Real &tol) |
| 34 |
{ |
| 35 |
ROL::Ptr<std::vector<Real> > cp = (dynamic_cast<ROL::StdVector<Real>&>(c)).getVector(); |
| 36 |
ROL::Ptr<const Tpetra::MultiVector<> > up = (dynamic_cast<const ROL::TpetraMultiVector<Real>&>(u)).getVector(); |
| 37 |
ROL::Ptr<const Tpetra::MultiVector<> > zp = (dynamic_cast<const ROL::TpetraMultiVector<Real>&>(z)).getVector(); |
| 38 |
|
| 39 |
pde_->value(*cp1,*up,*zp,tol); |
| 40 |
vol_->value(*cp2,*up,*zp,tol); |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
void applyJacobian_1(ROL::Vector<Real> &jv, const ROL::Vector<Real> &v, const ROL::Vector<Real> &u, |
| 45 |
const ROL::Vector<Real> &z, Real &tol) |
| 46 |
{ |
| 47 |
ROL::Ptr<std::vector<Real> > jvp = (dynamic_cast<ROL::StdVector<Real>&>(jv)).getVector(); |
| 48 |
ROL::Ptr<const Tpetra::MultiVector<> > vp = (dynamic_cast<const ROL::TpetraMultiVector<Real>&>(v)).getVector(); |
| 49 |
ROL::Ptr<const Tpetra::MultiVector<> > up = (dynamic_cast<const ROL::TpetraMultiVector<Real>&>(u)).getVector(); |
| 50 |
ROL::Ptr<const Tpetra::MultiVector<> > zp = (dynamic_cast<const ROL::TpetraMultiVector<Real>&>(z)).getVector(); |
| 51 |
|
| 52 |
pde_->applyJacobian_1(*jvp1,*vp,*up,*zp,tol); |
| 53 |
vol_->applyJacobian_1(*jvp2,*vp,*up,*zp,tol); |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
void applyJacobian_2(ROL::Vector<Real> &jv, const ROL::Vector<Real> &v, const ROL::Vector<Real> &u, |
| 58 |
const ROL::Vector<Real> &z, Real &tol) |
| 59 |
{ |
| 60 |
ROL::Ptr<std::vector<Real> > jvp = (dynamic_cast<ROL::StdVector<Real>&>(jv)).getVector(); |
| 61 |
ROL::Ptr<const Tpetra::MultiVector<> > vp = (dynamic_cast<const ROL::TpetraMultiVector<Real>&>(v)).getVector(); |
| 62 |
ROL::Ptr<const Tpetra::MultiVector<> > up = (dynamic_cast<const ROL::TpetraMultiVector<Real>&>(u)).getVector(); |
| 63 |
ROL::Ptr<const Tpetra::MultiVector<> > zp = (dynamic_cast<const ROL::TpetraMultiVector<Real>&>(z)).getVector(); |
| 64 |
|
| 65 |
pde_->applyJacobian_2(*jvp1,*vp,*up,*zp,tol); |
| 66 |
vol_->applyJacobian_2(*jvp2,*vp,*up,*zp,tol); |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
void applyAdjointJacobian_1(ROL::Vector<Real> &ajv, const ROL::Vector<Real> &v, const ROL::Vector<Real> &u, |
| 71 |
const ROL::Vector<Real> &z, Real &tol) |
| 72 |
{ |
| 73 |
ROL::Ptr<std::vector<Real> > ajvp = (dynamic_cast<ROL::StdVector<Real>&>(jv)).getVector(); |
| 74 |
ROL::Ptr<const Tpetra::MultiVector<> > vp = (dynamic_cast<const ROL::TpetraMultiVector<Real>&>(v)).getVector(); |
| 75 |
ROL::Ptr<const Tpetra::MultiVector<> > up = (dynamic_cast<const ROL::TpetraMultiVector<Real>&>(u)).getVector(); |
| 76 |
ROL::Ptr<const Tpetra::MultiVector<> > zp = (dynamic_cast<const ROL::TpetraMultiVector<Real>&>(z)).getVector(); |
| 77 |
|
| 78 |
pde_->applyAdjointJacobian_1(*ajvp1,*vp,*up,*zp,tol); |
| 79 |
vol_->applyAdjointJacobian_1(*ajvp2,*vp,*up,*zp,tol); |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
void applyAdjointJacobian_2(ROL::Vector<Real> &ajv, const ROL::Vector<Real> &v, const ROL::Vector<Real> &u, |
| 84 |
const ROL::Vector<Real> &z, Real &tol) |
| 85 |
{ |
| 86 |
ROL::Ptr<Tpetra::MultiVector<> > ajvp = (dynamic_cast<ROL::TpetraMultiVector<Real>&>(ajv)).getVector(); |
| 87 |
ROL::Ptr<const std::vector<Real> > vp = (dynamic_cast<const ROL::StdVector<Real>&>(v)).getVector(); |
| 88 |
ROL::Ptr<const Tpetra::MultiVector<> > up = (dynamic_cast<const ROL::TpetraMultiVector<Real>&>(u)).getVector(); |
| 89 |
ROL::Ptr<const Tpetra::MultiVector<> > zp = (dynamic_cast<const ROL::TpetraMultiVector<Real>&>(z)).getVector(); |
| 90 |
|
| 91 |
pde_->applyAdjointJacobian_2(*ajvp1,*vp,*up,*zp,tol); |
| 92 |
vol_->applyAdjointJacobian_2(*ajvp2,*vp,*up,*zp,tol); |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
void applyAdjointHessian_11(ROL::Vector<Real> &ahwv, const ROL::Vector<Real> &w, const ROL::Vector<Real> &v, |
| 97 |
const ROL::Vector<Real> &u, const ROL::Vector<Real> &z, Real &tol) |
| 98 |
{ |
| 99 |
ahwv.zero(); |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
void applyAdjointHessian_12(ROL::Vector<Real> &ahwv, const ROL::Vector<Real> &w, const ROL::Vector<Real> &v, |
| 104 |
const ROL::Vector<Real> &u, const ROL::Vector<Real> &z, Real &tol) |
| 105 |
{ |
| 106 |
ahwv.zero(); |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
void applyAdjointHessian_21(ROL::Vector<Real> &ahwv, const ROL::Vector<Real> &w, const ROL::Vector<Real> &v, |
| 111 |
const ROL::Vector<Real> &u, const ROL::Vector<Real> &z, Real &tol) |
| 112 |
{ |
| 113 |
ahwv.zero(); |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
void applyAdjointHessian_22(ROL::Vector<Real> &ahwv, const ROL::Vector<Real> &w, const ROL::Vector<Real> &v, |
| 118 |
const ROL::Vector<Real> &u, const ROL::Vector<Real> &z, Real &tol) |
| 119 |
{ |
| 120 |
ahwv.zero(); |
| 121 |
} |
| 122 |
|
| 123 |
}; |
| 124 |
|
| 125 |
#endif |