159 inArgs.setModelEvalDescription(
"Simple Model Evaluator");
162 inArgs.setSupports(IN_ARG_x,
true);
166 inArgs.setSupports(IN_ARG_x_sg,
true);
167 inArgs.setSupports(IN_ARG_p_sg, 0,
true);
168 inArgs.setSupports(IN_ARG_sg_basis,
true);
169 inArgs.setSupports(IN_ARG_sg_quadrature,
true);
170 inArgs.setSupports(IN_ARG_sg_expansion,
true);
201 Teuchos::RCP<const Epetra_Vector> x = inArgs.get_x();
202 if (x != Teuchos::null)
204 double x0 = (*x_overlapped)[0];
205 double x1 = (*x_overlapped)[1];
208 Teuchos::RCP<const Epetra_Vector> p = inArgs.get_p(0);
209 if (p == Teuchos::null)
217 Teuchos::RCP<Epetra_Vector>
f = outArgs.get_f();
218 if (
f != Teuchos::null) {
221 if (
x_map->MyGID(0)) {
224 f->ReplaceGlobalValues(1, &v, &row);
226 if (
x_map->MyGID(1)) {
229 f->ReplaceGlobalValues(1, &v, &row);
236 Teuchos::RCP<Epetra_Operator> W = outArgs.get_W();
237 if (W != Teuchos::null) {
238 Teuchos::RCP<Epetra_CrsMatrix> jac =
239 Teuchos::rcp_dynamic_cast<Epetra_CrsMatrix>(W,
true);
240 int indices[2] = { 0, 1 };
242 if (
x_map->MyGID(0)) {
243 values[0] = -1.0; values[1] = 0.0;
244 jac->ReplaceGlobalValues(0, 2, values, indices);
246 if (
x_map->MyGID(1)) {
247 values[0] = -1.0; values[1] = 2.0*x1;
248 jac->ReplaceGlobalValues(1, 2, values, indices);
257 Teuchos::RCP<const Stokhos::OrthogPolyBasis<int,double> > basis =
258 inArgs.get_sg_basis();
259 Teuchos::RCP<Stokhos::OrthogPolyExpansion<int,double> > expn =
260 inArgs.get_sg_expansion();
263 InArgs::sg_const_vector_t x_sg = inArgs.get_x_sg();
265 if (x_sg != Teuchos::null) {
266 for (
int i=0; i<basis->size(); i++) {
268 x0_sg[i] = (*x_overlapped)[0];
269 x1_sg[i] = (*x_overlapped)[1];
274 InArgs::sg_const_vector_t p_sg = inArgs.get_p_sg(0);
276 if (p_sg != Teuchos::null) {
277 for (
int i=0; i<basis->size(); i++) {
278 a_sg[i] = (*p_sg)[i][0];
285 OutArgs::sg_vector_t f_sg = outArgs.get_f_sg();
287 if (f_sg != Teuchos::null) {
289 if (
x_map->MyGID(0)) {
291 expn->times(tmp0_sg, a_sg, a_sg);
292 expn->minus(tmp1_sg, tmp0_sg, x0_sg);
293 for (
int i=0; i<basis->size(); i++)
294 (*f_sg)[i].ReplaceGlobalValues(1, &tmp1_sg[i], &row);
296 if (
x_map->MyGID(1)) {
298 expn->times(tmp0_sg, x1_sg, x1_sg);
299 expn->minus(tmp1_sg, tmp0_sg, x0_sg);
300 for (
int i=0; i<basis->size(); i++)
301 (*f_sg)[i].ReplaceGlobalValues(1, &tmp1_sg[i], &row);
308 OutArgs::sg_operator_t W_sg = outArgs.get_W_sg();
309 if (W_sg != Teuchos::null) {
310 for (
int i=0; i<basis->size(); i++) {
311 Teuchos::RCP<Epetra_CrsMatrix> jac =
312 Teuchos::rcp_dynamic_cast<Epetra_CrsMatrix>(W_sg->getCoeffPtr(i),
true);
313 int indices[2] = { 0, 1 };
315 if (
x_map->MyGID(0)) {
321 jac->ReplaceGlobalValues(0, 2, values, indices);
323 if (
x_map->MyGID(1)) {
328 values[1] = 2.0*x1_sg[i];
329 jac->ReplaceGlobalValues(1, 2, values, indices);