39 #include "Teuchos_GlobalMPISession.hpp"
41 #include "ROL_ParameterList.hpp"
74 ROL::Ptr<const vector>
Vp_;
78 return dynamic_cast<const SV&
>(x).getVector();
83 return dynamic_cast<SV&
>(x).getVector();
93 using namespace Teuchos;
96 ROL::Ptr<const vector> vp = getVector(v);
99 ROL::Ptr<vector> kvp = getVector(kv);
103 (*kvp)[0] = (2.0*(*vp)[0]-(*vp)[1])/dx2;
105 for(
uint i=1;i<nx_-1;++i) {
106 (*kvp)[i] = (2.0*(*vp)[i]-(*vp)[i-1]-(*vp)[i+1])/dx2;
109 (*kvp)[nx_-1] = (2.0*(*vp)[nx_-1]-(*vp)[nx_-2])/dx2;
117 dx_ = (1.0/(1.0+nx_));
130 ROL::Ptr<const vector> psip = getVector(psi);
133 ROL::Ptr<V> kpsi = psi.
clone();
134 ROL::Ptr<vector> kpsip = getVector(*kpsi);
138 this->applyK(psi,*kpsi);
140 for(
uint i=0;i<nx_;++i) {
141 J += (*psip)[i]*(*kpsip)[i] + (*Vp_)[i]*pow((*psip)[i],2) + g_*pow((*psip)[i],4);
157 ROL::Ptr<const vector> psip = getVector(psi);
160 ROL::Ptr<vector> gp = getVector(g);
163 ROL::Ptr<V> kpsi = psi.
clone();
164 ROL::Ptr<vector> kpsip = getVector(*kpsi);
168 for(
uint i=0;i<nx_;++i) {
169 (*gp)[i] = ((*kpsip)[i] + (*Vp_)[i]*(*psip)[i] + 2.0*g_*pow((*psip)[i],3))*dx_;
183 ROL::Ptr<const vector> psip = getVector(psi);
186 ROL::Ptr<const vector> vp = getVector(v);
189 ROL::Ptr<vector> hvp = getVector(hv);
193 for(
uint i=0;i<nx_;++i) {
195 (*hvp)[i] += ( (*Vp_)[i] + 6.0*g_*pow((*psip)[i],2) )*(*vp)[i]*dx_;
218 return dynamic_cast<const SV&
>(x).getVector();
223 return dynamic_cast<SV&
>(x).getVector();
239 ROL::Ptr<vector> cp = getVector(c);
242 ROL::Ptr<const vector> psip = getVector(psi);
245 for(
uint i=0;i<nx_;++i) {
246 (*cp)[0] += dx_*pow((*psip)[i],2);
258 ROL::Ptr<vector> jvp = getVector(jv);
261 ROL::Ptr<const vector> vp = getVector(v);
264 ROL::Ptr<const vector> psip = getVector(psi);
267 for(
uint i=0;i<nx_;++i) {
268 (*jvp)[0] += 2.0*dx_*(*psip)[i]*(*vp)[i];
280 ROL::Ptr<vector> ajvp = getVector(ajv);
283 ROL::Ptr<const vector> vp = getVector(v);
286 ROL::Ptr<const vector> psip = getVector(psi);
288 for(
uint i=0;i<nx_;++i) {
289 (*ajvp)[i] = 2.0*dx_*(*psip)[i]*(*vp)[0];
303 ROL::Ptr<vector> ahuvp = getVector(ahuv);
306 ROL::Ptr<const vector> up = getVector(u);
309 ROL::Ptr<const vector> vp = getVector(v);
312 ROL::Ptr<const vector> psip = getVector(psi);
314 for(
uint i=0;i<nx_;++i) {
315 (*ahuvp)[i] = 2.0*dx_*(*vp)[i]*(*up)[0];
Provides the interface to evaluate objective functions.
typename PV< Real >::size_type size_type
Real value(const Vector< Real > &psi, Real &tol)
Evaluate .
ROL::Ptr< const vector > getVector(const V &x)
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
void applyAdjointJacobian(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &psi, Real &tol)
Evaluate .
std::vector< Real > vector
ROL::Ptr< vector > getVector(V &x)
void value(Vector< Real > &c, const Vector< Real > &psi, Real &tol)
Evaluate .
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &psi, Real &tol)
Evaluate .
Normalization_Constraint(int n, Real dx)
Defines the linear algebra or vector space interface.
std::vector< Real > vector
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &psi, Real &tol)
Evaluate .
ROL::Ptr< const vector > Vp_
void applyK(const Vector< Real > &v, Vector< Real > &kv)
Apply finite difference operator.
ROL::Ptr< const vector > getVector(const V &x)
ROL::Ptr< vector > getVector(V &x)
void gradient(Vector< Real > &g, const Vector< Real > &psi, Real &tol)
Evaluate .
Objective_GrossPitaevskii(const Real &g, const Vector< Real > &V)
Defines the general constraint operator interface.
void applyAdjointHessian(Vector< Real > &ahuv, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &psi, Real &tol)
Evaluate .