53 #ifndef ROL_CANTILEVER_HPP
54 #define ROL_CANTILEVER_HPP
69 Real
value(
const std::vector<Real> &x, Real &tol ) {
73 void gradient( std::vector<Real> &g,
const std::vector<Real> &x, Real &tol ) {
78 void hessVec( std::vector<Real> &hv,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
88 Real
stress(
const Real w,
const Real t,
const int deriv = 0,
const int comp1 = 0,
const int comp2 = 0)
const {
89 const Real scale(600), X(500), Y(1000);
92 val = scale*(Y/(w*t*t) + X/(w*w*t));
94 else if (deriv == 1) {
97 val = scale*(-Y/(w*w*t*t) - two*X/(w*w*w*t));
99 else if (comp1 == 1) {
101 val = scale*(-two*Y/(w*t*t*t) - X/(w*w*t*t));
104 else if (deriv == 2) {
105 if (comp1 == 0 && comp2 == 0) {
106 const Real two(2), six(6);
107 val = scale*(two*Y/(w*w*w*t*t) + six*X/(w*w*w*w*t));
109 else if (comp1 == 1 && comp2 == 1) {
110 const Real two(2), six(6);
111 val = scale*(six*Y/(w*t*t*t*t) + two*X/(w*w*t*t*t));
113 else if (comp1 == 0 && comp2 == 1) {
115 val = scale*two*(Y/(w*w*t*t*t) + X/(w*w*w*t*t));
117 else if (comp1 == 1 && comp2 == 0) {
119 val = scale*two*(Y/(w*w*t*t*t) + X/(w*w*w*t*t));
125 Real
displacement(
const Real w,
const Real t,
const int deriv = 0,
const int comp1 = 0,
const int comp2 = 0)
const {
126 const Real four(4), L(100), E(2.9e7), X(500), Y(1000);
127 const Real C = four*std::pow(L,3)/E;
128 Real arg1 = std::pow(Y/(t*t),2), arg2 = std::pow(X/(w*w),2);
129 Real mag = std::sqrt(arg1 + arg2);
134 else if (deriv == 1) {
137 val = -C * (three * std::pow(X*t*t,2) + std::pow(Y*w*w,2))
138 / (std::pow(w,6)*std::pow(t,5)*mag);
140 else if (comp1 == 1) {
142 val = -C * (std::pow(X*t*t,2) + three*std::pow(Y*w*w,2))
143 / (std::pow(w,5)*std::pow(t,6)*mag);
146 else if (deriv == 2) {
147 if (comp1 == 0 && comp2 == 0) {
148 const Real two(2), six(6), nine(9);
149 val = C * two * mag * (std::pow(Y*w*w,4) + nine*std::pow(Y*X*w*w*t*t,2) + six*std::pow(X*t*t,4))
150 / (std::pow(w,3)*t*std::pow(std::pow(Y*w*w,2)+std::pow(X*t*t,2),2));
152 else if (comp1 == 1 && comp2 == 1) {
153 const Real two(2), six(6), nine(9);
154 val = C * two * mag * (six*std::pow(Y*w*w,4) + nine*std::pow(Y*X*w*w*t*t,2) + std::pow(X*t*t,4))
155 / (std::pow(t,3)*w*std::pow(std::pow(Y*w*w,2)+std::pow(X*t*t,2),2));
157 else if (comp1 == 0 && comp2 == 1) {
158 const Real two(2), three(3);
159 val = C * (three*std::pow(X*t*t,4) + two*std::pow(X*Y*t*t*w*w,2) + three*std::pow(Y*w*w,4))
160 / (std::pow(t*w,6)*mag*(std::pow(X*t*t,2) + std::pow(Y*w*w,2)));
162 else if (comp1 == 1 && comp2 == 0) {
163 const Real two(2), three(3);
164 val = C * (three*std::pow(X*t*t,4) + two*std::pow(X*Y*t*t*w*w,2) + three*std::pow(Y*w*w,4))
165 / (std::pow(t*w,6)*mag*(std::pow(X*t*t,2) + std::pow(Y*w*w,2)));
173 void value( std::vector<Real> &c,
const std::vector<Real> &x, Real &tol ) {
174 const Real R(40000), D(2.2535), one(1);
175 Real s =
stress(x[0],x[1],0)/R;
181 void applyJacobian( std::vector<Real> &jv,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
182 const Real R(40000), D(2.2535);
183 Real s0 =
stress(x[0],x[1],1,0)/R, s1 =
stress(x[0],x[1],1,1)/R;
185 jv[0] = s0*v[0] + s1*v[1];
186 jv[1] = d0*v[0] + d1*v[1];
189 void applyAdjointJacobian( std::vector<Real> &ajv,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
190 const Real R(40000), D(2.2535);
191 Real s0 =
stress(x[0],x[1],1,0)/R, s1 =
stress(x[0],x[1],1,1)/R;
193 ajv[0] = s0*v[0] + d0*v[1];
194 ajv[1] = s1*v[0] + d1*v[1];
197 void applyAdjointHessian( std::vector<Real> &ahuv,
const std::vector<Real> &u,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
198 const Real R(40000), D(2.2535);
199 Real s00 =
stress(x[0],x[1],2,0,0)/R, s01 =
stress(x[0],x[1],2,0,1)/R;
200 Real s10 =
stress(x[0],x[1],2,1,0)/R, s11 =
stress(x[0],x[1],2,1,1)/R;
203 ahuv[0] = (s00*u[0] + d00*u[1])*v[0] + (s01*u[0] + d01*u[1])*v[1];
204 ahuv[1] = (s10*u[0] + d10*u[1])*v[0] + (s11*u[0] + d11*u[1])*v[1];
215 return makePtr<Objective_Cantilever<Real>>();
220 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(n,
static_cast<Real
>(1.0));
221 Ptr<std::vector<Real>> xp = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0.0));
222 (*xp)[0] =
static_cast<Real
>(2.0);
223 (*xp)[1] =
static_cast<Real
>(2.0);
224 return makePtr<PrimalScaledStdVector<Real>>(xp,scale);
229 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(n,
static_cast<Real
>(1.0));
230 Ptr<std::vector<Real>> xp = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0.0));
231 (*xp)[0] =
static_cast<Real
>(2.3520341271);
232 (*xp)[1] =
static_cast<Real
>(3.3262784077);
233 return makePtr<PrimalScaledStdVector<Real>>(xp,scale);
238 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(n,
static_cast<Real
>(1.0));
239 Ptr<std::vector<Real>> lp = makePtr<std::vector<Real>>(n,
static_cast<Real
>(1.0));
240 Ptr<std::vector<Real>> up = makePtr<std::vector<Real>>(n,
static_cast<Real
>(4.0));
241 Ptr<Vector<Real>> l = makePtr<PrimalScaledStdVector<Real>>(lp,scale);
242 Ptr<Vector<Real>> u = makePtr<PrimalScaledStdVector<Real>>(up,scale);
243 return makePtr<Bounds<Real>>(l,u);
247 return makePtr<Constraint_Cantilever<Real>>();
251 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(2,
static_cast<Real
>(1.0));
252 Ptr<std::vector<Real>> lp = makePtr<std::vector<Real>>(2,
static_cast<Real
>(0.0));
253 return makePtr<DualScaledStdVector<Real>>(lp,scale);
257 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(2,
static_cast<Real
>(1.0));
258 Ptr<std::vector<Real>> up = makePtr<std::vector<Real>>(2,
static_cast<Real
>(0.0));
259 Ptr<Vector<Real>> u = makePtr<DualScaledStdVector<Real>>(up,scale);
260 return makePtr<Bounds<Real>>(*u,
false);
Ptr< Objective< Real > > getObjective(void) const
void gradient(std::vector< Real > &g, const std::vector< Real > &x, Real &tol)
void applyJacobian(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
virtual void hessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Ptr< BoundConstraint< Real > > getSlackBoundConstraint(void) const
Real displacement(const Real w, const Real t, const int deriv=0, const int comp1=0, const int comp2=0) const
void applyAdjointJacobian(std::vector< Real > &ajv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Real stress(const Real w, const Real t, const int deriv=0, const int comp1=0, const int comp2=0) const
Defines the equality constraint operator interface for StdVectors.
Specializes the ROL::Objective interface for objective functions that operate on ROL::StdVector's.
void applyAdjointHessian(Vector< Real > &ahuv, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the derivative of the adjoint of the constraint Jacobian at to vector in direction ...
Contains definitions of test objective functions.
void value(std::vector< Real > &c, const std::vector< Real > &x, Real &tol)
Ptr< Vector< Real > > getSolution(const int i=0) const
Ptr< Constraint< Real > > getInequalityConstraint(void) const
Ptr< BoundConstraint< Real > > getBoundConstraint(void) const
Real value(const std::vector< Real > &x, Real &tol)
Ptr< Vector< Real > > getInitialGuess(void) const
Ptr< Vector< Real > > getInequalityMultiplier(void) const