45 #include "Teuchos_ScalarTraits.hpp"
46 #include "Epetra_SerialComm.h"
47 #include "Epetra_CrsMatrix.h"
50 # include "Epetra_MpiComm.h"
52 # include "Epetra_SerialComm.h"
57 inline double sqr(
const double& s ) {
return s*s; }
72 :xt0_(xt0),xt1_(xt1),pt0_(pt0),pt1_(pt1),d_(d),
73 isInitialized_(false),supportDerivs_(true)
79 const int nx = 2, np = 2, ng = 1;
81 map_x_ = rcp(
new Epetra_Map(nx,0,*epetra_comm_));
82 map_p_ = rcp(
new Epetra_Map(np,0,*epetra_comm_));
83 map_g_ = rcp(
new Epetra_Map(ng,0,*epetra_comm_));
86 const double inf = 1e+50;
90 x0_ = rcp(
new Epetra_Vector(*map_x_)); (*x0_)[0] = x00; (*x0_)[1] = x01;
93 p0_ = rcp(
new Epetra_Vector(*map_p_)); (*p0_)[0] = p00; (*p0_)[1] = p01;
100 int indices[nx] = { 0, 1 };
101 for(
int i = 0; i < nx; ++i )
102 W_graph_->InsertGlobalIndices(i,nx,indices);
104 W_graph_->FillComplete();
106 isInitialized_ =
true;
113 supportDerivs_ = supportDerivs;
118 double pL0,
double pL1,
double pU0,
double pU1
128 double xL0,
double xL1,
double xU0,
double xU1
139 Teuchos::RCP<const Epetra_Map>
145 Teuchos::RCP<const Epetra_Map>
151 Teuchos::RCP<const Epetra_Map>
154 TEUCHOS_TEST_FOR_EXCEPT(l!=0);
158 Teuchos::RCP<const Epetra_Map>
161 TEUCHOS_TEST_FOR_EXCEPT(j!=0);
165 Teuchos::RCP<const Epetra_Vector>
171 Teuchos::RCP<const Epetra_Vector>
174 TEUCHOS_TEST_FOR_EXCEPT(l!=0);
178 Teuchos::RCP<const Epetra_Vector>
184 Teuchos::RCP<const Epetra_Vector>
190 Teuchos::RCP<const Epetra_Vector>
193 TEUCHOS_TEST_FOR_EXCEPT(l!=0);
197 Teuchos::RCP<const Epetra_Vector>
200 TEUCHOS_TEST_FOR_EXCEPT(l!=0);
204 Teuchos::RCP<Epetra_Operator>
235 if (supportDerivs_) {
269 using Teuchos::dyn_cast;
270 using Teuchos::rcp_dynamic_cast;
274 Teuchos::RCP<const Epetra_Vector> p_in = inArgs.
get_p(0);
292 f[0] = x[0] + x[1]*x[1] - p[0];
293 f[1] = d_ * ( x[0]*x[0] - x[1] - p[1] );
297 g[0] = 0.5 * ( sqr(x[0]-xt0_) + sqr(x[1]-xt1_) + sqr(p[0]-pt0_) + sqr(p[1]-pt1_) );
311 values[0] = 1.0; indexes[0] = 0;
312 values[1] = 2.0*x[1]; indexes[1] = 1;
315 values[0] = 2.0*d_*x[0]; indexes[0] = 0;
316 values[1] = -d_; indexes[1] = 1;
327 DgDx_trans[0] = x[0]-xt0_;
328 DgDx_trans[1] = x[1]-xt1_;
332 DgDp_trans[0] = p[0]-pt0_;
333 DgDp_trans[1] = p[1]-pt1_;