45 #include "Teuchos_ScalarTraits.hpp"
46 #include "Epetra_SerialComm.h"
47 #include "Epetra_CrsMatrix.h"
49 #include "Epetra_MpiComm.h"
53 inline double sqr(
const double& s ) {
return s*s; }
58 Teuchos::RCP<Epetra_Comm> epetra_comm
70 :isInitialized_(false), epetra_comm_(epetra_comm),
71 xt0_(xt0),xt1_(xt1),pt0_(pt0),pt1_(pt1),d_(d)
75 const int nx = 2, np = 2, ng = 1, nq = 1;
77 map_x_ = rcp(
new Epetra_Map(nx,0,*epetra_comm_));
78 map_p_ = rcp(
new Epetra_Map(np,0,*epetra_comm_));
79 map_q_ = rcp(
new Epetra_Map(nq,0,*epetra_comm_));
80 map_g_ = rcp(
new Epetra_Map(ng,0,*epetra_comm_));
83 const double inf = 1e+50;
87 x0_ = rcp(
new Epetra_Vector(*map_x_)); (*x0_)[0] = x00; (*x0_)[1] = x01;
90 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;
111 double pL0,
double pL1,
double pU0,
double pU1
121 double xL0,
double xL1,
double xU0,
double xU1
132 Teuchos::RCP<const Epetra_Map>
138 Teuchos::RCP<const Epetra_Map>
144 Teuchos::RCP<const Epetra_Map>
147 TEUCHOS_TEST_FOR_EXCEPT(l>1);
148 if (l==0)
return map_p_;
152 Teuchos::RCP<const Epetra_Map>
155 TEUCHOS_TEST_FOR_EXCEPT(j!=0);
159 Teuchos::RCP<const Epetra_Vector>
165 Teuchos::RCP<const Epetra_Vector>
168 TEUCHOS_TEST_FOR_EXCEPT(l>1);
169 if (l==0)
return p0_;
173 Teuchos::RCP<const Epetra_Vector>
179 Teuchos::RCP<const Epetra_Vector>
185 Teuchos::RCP<const Epetra_Vector>
188 TEUCHOS_TEST_FOR_EXCEPT(l>1);
189 if (l==0)
return pL_;
193 Teuchos::RCP<const Epetra_Vector>
196 TEUCHOS_TEST_FOR_EXCEPT(l>1);
197 if (l==0)
return pU_;
201 Teuchos::RCP<Epetra_Operator>
261 using Teuchos::dyn_cast;
262 using Teuchos::rcp_dynamic_cast;
266 Teuchos::RCP<const Epetra_Vector> p_in = inArgs.
get_p(0);
267 Teuchos::RCP<const Epetra_Vector> q_in = inArgs.
get_p(1);
287 f[0] = x[0] + x[1]*x[1] - p[0] + q[0];
288 f[1] = d_ * ( x[0]*x[0] - x[1] - p[1] );
292 g[0] = 0.5 * ( sqr(x[0]-xt0_) + sqr(x[1]-xt1_) + sqr(p[0]-pt0_) + sqr(p[1]-pt1_) );
306 values[0] = 1.0; indexes[0] = 0;
307 values[1] = 2.0*x[1]; indexes[1] = 1;
310 values[0] = 2.0*d_*x[0]; indexes[0] = 0;
311 values[1] = -d_; indexes[1] = 1;
322 DgDx_trans[0] = x[0]-xt0_;
323 DgDx_trans[1] = x[1]-xt1_;
327 DgDp_trans[0] = p[0]-pt0_;
328 DgDp_trans[1] = p[1]-pt1_;