53 #ifndef ROL_POISSONCONTROL_HPP
54 #define ROL_POISSONCONTROL_HPP
74 Teuchos::RCP<const std::vector<Real> > zp =
76 Teuchos::RCP<std::vector<Real> > Mzp =
77 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(Mz)).getVector());
80 Real h = 1.0/((Real)n+1.0);
81 for (
int i=0; i<n; i++) {
83 (*Mzp)[i] = h/6.0*(4.0*(*zp)[i] + (*zp)[i+1]);
85 else if ( i == n-1 ) {
86 (*Mzp)[i] = h/6.0*((*zp)[i-1] + 4.0*(*zp)[i]);
89 (*Mzp)[i] = h/6.0*((*zp)[i-1] + 4.0*(*zp)[i] + (*zp)[i+1]);
95 Teuchos::RCP<std::vector<Real> > up =
96 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(u)).getVector());
99 Real h = 1.0/((Real)n+1.0);
101 Teuchos::RCP<std::vector<Real> > bp =
102 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(b)).getVector());
108 std::vector<Real> c(n,o);
110 (*up)[0] = (*bp)[0]/d;
111 for (
int i = 1; i < n; i++ ) {
112 m = 1.0/(d - o*c[i-1]);
114 (*up)[i] = ( (*bp)[i] - o*(*up)[i-1] )*m;
116 for (
int i = n-1; i > 0; i-- ) {
117 (*up)[i-1] = (*up)[i-1] - c[i-1]*(*up)[i];
122 Real val = 1.0/3.0*std::pow(x,4.0) - 2.0/3.0*std::pow(x,3.0) + 1.0/3.0*x + 8.0*this->
alpha_;
127 Teuchos::RCP<const std::vector<Real> > zp =
130 Real h = 1.0/((Real)n+1.0);
134 Teuchos::RCP<std::vector<Real> > up =
135 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(u)).getVector());
142 for (
int i=0; i<n; i++) {
143 res = this->
alpha_*(*zp)[i];
145 res *= h/6.0*(4.0*(*zp)[i] + (*zp)[i+1]);
148 res += h/6.0*(4.0*res1 + res2)*res1;
150 else if ( i == n-1 ) {
151 res *= h/6.0*((*zp)[i-1] + 4.0*(*zp)[i]);
154 res += h/6.0*(res1 + 4.0*res2)*res2;
157 res *= h/6.0*((*zp)[i-1] + 4.0*(*zp)[i] + (*zp)[i+1]);
161 res += h/6.0*(res1 + 4.0*res2 + res3)*res2;
169 Teuchos::RCP<const std::vector<Real> > zp =
171 Teuchos::RCP<std::vector<Real> > gp =
172 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(g)).getVector());
174 Real h = 1.0/((Real)n+1.0);
179 Teuchos::RCP<std::vector<Real> > up =
180 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(u)).getVector());
184 Teuchos::RCP<std::vector<Real> > rp =
185 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(res)).getVector());
186 for (
int i=0; i<n; i++) {
191 Teuchos::RCP<std::vector<Real> > pp =
192 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(p)).getVector());
197 for (
int i=0; i<n; i++) {
199 res1 = this->
alpha_*(*zp)[i] - (*pp)[i];
200 res2 = this->
alpha_*(*zp)[i+1] - (*pp)[i+1];
201 (*gp)[i] = h/6.0*(4.0*res1 + res2);
203 else if ( i == n-1 ) {
204 res1 = this->
alpha_*(*zp)[i-1] - (*pp)[i-1];
205 res2 = this->
alpha_*(*zp)[i] - (*pp)[i];
206 (*gp)[i] = h/6.0*(res1 + 4.0*res2);
209 res1 = this->
alpha_*(*zp)[i-1] - (*pp)[i-1];
210 res2 = this->
alpha_*(*zp)[i] - (*pp)[i];
211 res3 = this->
alpha_*(*zp)[i+1] - (*pp)[i+1];
212 (*gp)[i] = h/6.0*(res1 + 4.0*res2 + res3);
218 Teuchos::RCP<const std::vector<Real> > zp =
220 Teuchos::RCP<const std::vector<Real> > vp =
222 Teuchos::RCP<std::vector<Real> > hvp =
223 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(hv)).getVector());
226 Real h = 1.0/((Real)n+1.0);
231 Teuchos::RCP<std::vector<Real> > up =
232 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(u)).getVector());
237 Teuchos::RCP<std::vector<Real> > pp =
238 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(p)).getVector());
243 for (
int i=0; i<n; i++) {
245 res1 = this->
alpha_*(*vp)[i] + (*pp)[i];
246 res2 = this->
alpha_*(*vp)[i+1] + (*pp)[i+1];
247 (*hvp)[i] = h/6.0*(4.0*res1 + res2);
249 else if ( i == n-1 ) {
250 res1 = this->
alpha_*(*vp)[i-1] + (*pp)[i-1];
251 res2 = this->
alpha_*(*vp)[i] + (*pp)[i];
252 (*hvp)[i] = h/6.0*(res1 + 4.0*res2);
255 res1 = this->
alpha_*(*vp)[i-1] + (*pp)[i-1];
256 res2 = this->
alpha_*(*vp)[i] + (*pp)[i];
257 res3 = this->
alpha_*(*vp)[i+1] + (*pp)[i+1];
258 (*hvp)[i] = h/6.0*(res1 + 4.0*res2 + res3);
268 Teuchos::RCP<std::vector<Real> > x0p =
269 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(x0)).getVector());
270 Teuchos::RCP<std::vector<Real> > xp =
271 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(x)).getVector());
280 for (
int i=0; i<n; i++) {
284 Real h = 1.0/((Real)n+1.0);
286 for(
int i=0; i<n; i++ ) {
288 (*xp)[i] = 4.0*pt*(1.0-pt);
Provides the interface to evaluate objective functions.
Objective_PoissonControl(Real alpha=1.e-4)
Real value(const Vector< Real > &z, Real &tol)
Compute value.
void getPoissonControl(Teuchos::RCP< Objective< Real > > &obj, Vector< Real > &x0, Vector< Real > &x)
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
Defines the linear algebra or vector space interface.
void solve_poisson(Vector< Real > &u, const Vector< Real > &z)
Provides the std::vector implementation of the ROL::Vector interface.
void gradient(Vector< Real > &g, const Vector< Real > &z, Real &tol)
Compute gradient.
Poisson distributed control.
void apply_mass(Vector< Real > &Mz, const Vector< Real > &z)
Real evaluate_target(Real x)