Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_SGQuadMPModelEvaluator.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
12 #include "Stokhos_Quadrature.hpp"
19 #include "Epetra_Map.h"
20 #include "Epetra_Vector.h"
21 #include "Teuchos_TimeMonitor.hpp"
22 #include "Teuchos_Assert.hpp"
23 
28  const Teuchos::RCP<const Epetra_Map>& mp_block_map_) :
29  me(me_),
30  mp_comm(mp_comm_),
31  mp_block_map(mp_block_map_),
32  num_p(0),
33  num_g(0),
34  num_p_mp(0),
35  num_g_mp(0),
36  mp_p_index_map(),
37  mp_g_index_map(),
38  x_dot_mp(),
39  x_mp(),
40  p_mp(),
41  f_mp(),
42  W_mp(),
43  dfdp_mp(),
44  g_mp(),
45  dgdx_mp(),
46  dgdx_dot_mp(),
47  dgdp_mp()
48 {
49  int num_qp = mp_block_map->NumMyElements();
50 
53 
54  // Create storage for x_dot, x, and p at a quad point
55  InArgs me_inargs = me->createInArgs();
56  if (me_inargs.supports(IN_ARG_x_dot)) {
57  x_map = me->get_x_map();
59  mp_block_map, x_map, mp_comm));
60  }
61  if (me_inargs.supports(IN_ARG_x)) {
62  x_map = me->get_x_map();
64  mp_block_map, me->get_x_map(), mp_comm));
65  }
66 
67  // Get the p_mp's supported and build index map
68  num_p = me_inargs.Np();
69  for (int i=0; i<num_p; i++) {
70  if (me_inargs.supports(IN_ARG_p_mp, i))
72  }
74 
76  for (int i=0; i<num_p_mp; i++)
78  mp_block_map, me->get_p_map(mp_p_index_map[i]),
79  mp_comm));
80 
81  // Create storage for f and W at a quad point
82  OutArgs me_outargs = me->createOutArgs();
83 
84  // f
85  if (me_outargs.supports(OUT_ARG_f)) {
86  f_map = me->get_f_map();
88  }
89 
90  // W
91  if (me_outargs.supports(OUT_ARG_W)) {
93  mp_comm));
94  for (int i=0; i<num_qp; i++)
95  W_mp->setCoeffPtr(i, me->create_W());
96  }
97 
98  // df/dp -- note we potentially support derivatives w.r.t. all parameters,
99  // not just those for which p_mp is supported
100  dfdp_mp.resize(num_p);
101  for (int i=0; i<num_p; i++) {
102  Teuchos::RCP<const Epetra_Map> p_map = me->get_p_map(i);
103  DerivativeSupport ds = me_outargs.supports(OUT_ARG_DfDp_mp,i);
104  if (ds.supports(DERIV_MV_BY_COL))
105  dfdp_mp[i] = EpetraExt::ModelEvaluator::MPDerivative(
107  mp_block_map, f_map, mp_comm,
108  p_map->NumGlobalElements())));
109  else if (ds.supports(DERIV_TRANS_MV_BY_ROW))
110  dfdp_mp[i] = EpetraExt::ModelEvaluator::MPDerivative(
112  mp_block_map, p_map, mp_comm,
113  f_map->NumGlobalElements())));
114  else if (ds.supports(DERIV_LINEAR_OP)) {
117  mp_block_map, p_map, f_map,
118  mp_comm));
119  for (int j=0; j<num_qp; j++)
120  dfdp_mp_op->setCoeffPtr(j, me->create_DfDp_op(i));
121  dfdp_mp[i] = EpetraExt::ModelEvaluator::MPDerivative(dfdp_mp_op);
122  }
123 
124  }
125 
126  // Get the g_mp's supported and build index map
127  num_g = me_outargs.Ng();
128  for (int i=0; i<num_g; i++) {
129  if (me_outargs.supports(OUT_ARG_g_mp, i))
131  }
133 
137  dgdp_mp.resize(num_g_mp);
138  for (int i=0; i<num_g_mp; i++) {
139  int ii = mp_g_index_map[i];
140  Teuchos::RCP<const Epetra_Map> g_map = me->get_g_map(ii);
141 
142  // g
143  g_mp[i] =
145 
146  // dg/dx
147  DerivativeSupport ds_x = me_outargs.supports(OUT_ARG_DgDx_mp, ii);
148  if (ds_x.supports(DERIV_TRANS_MV_BY_ROW))
149  dgdx_mp[i] = EpetraExt::ModelEvaluator::MPDerivative(
151  g_map->NumGlobalElements())));
152  else if (ds_x.supports(DERIV_MV_BY_COL))
153  dgdx_mp[i] = EpetraExt::ModelEvaluator::MPDerivative(
155  x_map->NumGlobalElements())));
156  else if (ds_x.supports(DERIV_LINEAR_OP)) {
159  mp_comm));
160  for (int j=0; j<num_qp; j++)
161  dgdx_mp_op->setCoeffPtr(j, me->create_DgDx_op(ii));
162  dgdx_mp[i] = EpetraExt::ModelEvaluator::MPDerivative(dgdx_mp_op);
163  }
164 
165  // dg/dx_dot
166  DerivativeSupport ds_xdot = me_outargs.supports(OUT_ARG_DgDx_dot_mp, ii);
167  if (ds_xdot.supports(DERIV_TRANS_MV_BY_ROW))
168  dgdx_dot_mp[i] = EpetraExt::ModelEvaluator::MPDerivative(
170  g_map->NumGlobalElements())));
171  else if (ds_xdot.supports(DERIV_MV_BY_COL))
172  dgdx_dot_mp[i] = EpetraExt::ModelEvaluator::MPDerivative(
174  x_map->NumGlobalElements())));
175  else if (ds_xdot.supports(DERIV_LINEAR_OP)) {
178  mp_comm));
179  for (int j=0; j<num_qp; j++)
180  dgdx_dot_mp_op->setCoeffPtr(j, me->create_DgDx_dot_op(ii));
181  dgdx_dot_mp[i] = EpetraExt::ModelEvaluator::MPDerivative(dgdx_dot_mp_op);
182  }
183 
184  // dg/dp -- note we potentially support derivatives w.r.t. all parameters,
185  // not just those for which p_mp is supported
186  dgdp_mp[i].resize(num_p);
187  for (int j=0; j<num_p; j++) {
188  Teuchos::RCP<const Epetra_Map> p_map = me->get_p_map(j);
189  DerivativeSupport ds_p = me_outargs.supports(OUT_ARG_DgDp_mp, ii, j);
190  if (ds_p.supports(DERIV_TRANS_MV_BY_ROW))
191  dgdp_mp[i][j] = EpetraExt::ModelEvaluator::MPDerivative(
193  mp_block_map, p_map, mp_comm,
194  g_map->NumGlobalElements())));
195  else if (ds_p.supports(DERIV_MV_BY_COL))
196  dgdp_mp[i][j] = EpetraExt::ModelEvaluator::MPDerivative(
198  mp_block_map, g_map, mp_comm,
199  p_map->NumGlobalElements())));
200  else if (ds_p.supports(DERIV_LINEAR_OP)) {
203  mp_comm));
204  for (int k=0; k<num_qp; k++)
205  dgdp_mp_op->setCoeffPtr(k, me->create_DgDp_op(ii,j));
206  dgdp_mp[i][j] = EpetraExt::ModelEvaluator::MPDerivative(dgdp_mp_op);
207  }
208  }
209  }
210 }
211 
212 // Overridden from EpetraExt::ModelEvaluator
213 
216 get_x_map() const
217 {
218  return me->get_x_map();
219 }
220 
223 get_f_map() const
224 {
225  return me->get_f_map();
226 }
227 
230 get_p_map(int l) const
231 {
232  return me->get_p_map(l);
233 }
234 
237 get_g_map(int l) const
238 {
239  return me->get_g_map(l);
240 }
241 
244 get_p_names(int l) const
245 {
246  return me->get_p_names(l);
247 }
248 
251 get_x_init() const
252 {
253  return me->get_x_init();
254 }
255 
258 get_p_init(int l) const
259 {
260  return me->get_p_init(l);
261 }
262 
265 create_W() const
266 {
267  return me->create_W();
268 }
269 
270 EpetraExt::ModelEvaluator::InArgs
273 {
274  InArgsSetup inArgs;
275  InArgs me_inargs = me->createInArgs();
276 
277  inArgs.setModelEvalDescription(this->description());
278  inArgs.set_Np(num_p);
279  inArgs.setSupports(IN_ARG_x_dot, me_inargs.supports(IN_ARG_x_dot));
280  inArgs.setSupports(IN_ARG_x, me_inargs.supports(IN_ARG_x));
281  inArgs.setSupports(IN_ARG_t, me_inargs.supports(IN_ARG_t));
282  inArgs.setSupports(IN_ARG_alpha, me_inargs.supports(IN_ARG_alpha));
283  inArgs.setSupports(IN_ARG_beta, me_inargs.supports(IN_ARG_beta));
284 
285  for (int i=0; i<num_p_mp; i++)
286  inArgs.setSupports(IN_ARG_p_sg, mp_p_index_map[i], true);
287  inArgs.setSupports(IN_ARG_x_sg, me_inargs.supports(IN_ARG_x));
288  inArgs.setSupports(IN_ARG_x_dot_sg, me_inargs.supports(IN_ARG_x_dot));
289  inArgs.setSupports(IN_ARG_sg_basis, true);
290  inArgs.setSupports(IN_ARG_sg_quadrature, true);
291 
292  return inArgs;
293 }
294 
295 EpetraExt::ModelEvaluator::OutArgs
298 {
299  OutArgsSetup outArgs;
300  OutArgs me_outargs = me->createOutArgs();
301 
302  outArgs.setModelEvalDescription(this->description());
303  outArgs.set_Np_Ng(num_p, num_g);
304  outArgs.setSupports(OUT_ARG_f, me_outargs.supports(OUT_ARG_f));
305  outArgs.setSupports(OUT_ARG_W, me_outargs.supports(OUT_ARG_W));
306  for (int j=0; j<num_p; j++)
307  outArgs.setSupports(OUT_ARG_DfDp, j,
308  me_outargs.supports(OUT_ARG_DfDp, j));
309  for (int i=0; i<num_g; i++) {
310  outArgs.setSupports(OUT_ARG_DgDx, i,
311  me_outargs.supports(OUT_ARG_DgDx, i));
312  outArgs.setSupports(OUT_ARG_DgDx_dot, i,
313  me_outargs.supports(OUT_ARG_DgDx_dot, i));
314  for (int j=0; j<num_p; j++)
315  outArgs.setSupports(OUT_ARG_DgDp, i, j,
316  me_outargs.supports(OUT_ARG_DgDp, i, j));
317  }
318 
319  outArgs.setSupports(OUT_ARG_f_sg, me_outargs.supports(OUT_ARG_f_mp));
320  if (me_outargs.supports(OUT_ARG_W_mp)) {
321  outArgs.set_W_properties(me_outargs.get_W_properties());
322  outArgs.setSupports(OUT_ARG_W_sg, true);
323  }
324  for (int i=0; i<num_g_mp; i++)
325  outArgs.setSupports(OUT_ARG_g_sg, mp_g_index_map[i], true);
326  for (int j=0; j<num_p; j++)
327  outArgs.setSupports(OUT_ARG_DfDp_sg, j,
328  me_outargs.supports(OUT_ARG_DfDp_mp, j));
329  for (int i=0; i<num_g_mp; i++) {
330  int ii = mp_g_index_map[i];
331  outArgs.setSupports(OUT_ARG_DgDx_sg, ii,
332  me_outargs.supports(OUT_ARG_DgDx_mp, ii));
333  outArgs.setSupports(OUT_ARG_DgDx_dot_sg, ii,
334  me_outargs.supports(OUT_ARG_DgDx_dot_mp, ii));
335  for (int j=0; j<num_p; j++)
336  outArgs.setSupports(OUT_ARG_DgDp_sg, ii, j,
337  me_outargs.supports(OUT_ARG_DgDp_mp, ii, j));
338  }
339 
340  return outArgs;
341 }
342 
343 void
345 evalModel(const InArgs& inArgs, const OutArgs& outArgs) const
346 {
347  // Create underlying inargs
348  InArgs me_inargs = me->createInArgs();
349  if (me_inargs.supports(IN_ARG_x))
350  me_inargs.set_x(inArgs.get_x());
351  if (me_inargs.supports(IN_ARG_x_dot))
352  me_inargs.set_x_dot(inArgs.get_x_dot());
353  if (me_inargs.supports(IN_ARG_alpha))
354  me_inargs.set_alpha(inArgs.get_alpha());
355  if (me_inargs.supports(IN_ARG_beta))
356  me_inargs.set_beta(inArgs.get_beta());
357  if (me_inargs.supports(IN_ARG_t))
358  me_inargs.set_t(inArgs.get_t());
359  for (int i=0; i<num_p; i++)
360  me_inargs.set_p(i, inArgs.get_p(i));
361 
362  // Create underlying outargs
363  OutArgs me_outargs = me->createOutArgs();
364  if (me_outargs.supports(OUT_ARG_f))
365  me_outargs.set_f(outArgs.get_f());
366  if (me_outargs.supports(OUT_ARG_W))
367  me_outargs.set_W(outArgs.get_W());
368  for (int j=0; j<num_p; j++)
369  if (!outArgs.supports(OUT_ARG_DfDp, j).none())
370  me_outargs.set_DfDp(j, outArgs.get_DfDp(j));
371  for (int i=0; i<num_g; i++) {
372  me_outargs.set_g(i, outArgs.get_g(i));
373  if (!outArgs.supports(OUT_ARG_DgDx, i).none())
374  me_outargs.set_DgDx(i, outArgs.get_DgDx(i));
375  if (!outArgs.supports(OUT_ARG_DgDx_dot, i).none())
376  me_outargs.set_DgDx(i, outArgs.get_DgDx_dot(i));
377  for (int j=0; j<outArgs.Np(); j++)
378  if (!outArgs.supports(OUT_ARG_DgDp, i, j).none())
379  me_outargs.set_DgDp(i, j, outArgs.get_DgDp(i,j));
380  }
381 
382  bool do_quad = false;
383  InArgs::sg_const_vector_t x_sg;
384  InArgs::sg_const_vector_t x_dot_sg;
386  OutArgs::sg_vector_t f_sg;
387  OutArgs::sg_operator_t W_sg;
388  Teuchos::Array<SGDerivative> dfdp_sg(num_p);
390  Teuchos::Array<SGDerivative> dgdx_sg(num_g_mp);
391  Teuchos::Array<SGDerivative> dgdx_dot_sg(num_g_mp);
393  TEUCHOS_TEST_FOR_EXCEPTION(inArgs.get_sg_basis() == Teuchos::null,
394  std::logic_error,
395  "Error! Stokhos::SGQuadModelEvaluator::evalModel(): " <<
396  "SG basis inArg cannot be null!");
397  TEUCHOS_TEST_FOR_EXCEPTION(inArgs.get_sg_quadrature() == Teuchos::null,
398  std::logic_error,
399  "Error! Stokhos::SGQuadModelEvaluator::evalModel(): " <<
400  "SG quadrature inArg cannot be null!");
402  inArgs.get_sg_basis();
404  inArgs.get_sg_quadrature();
405 
406  if (inArgs.supports(IN_ARG_x_sg)) {
407  x_sg = inArgs.get_x_sg();
408  if (x_sg != Teuchos::null) {
409  do_quad = true;
410  }
411  }
412  if (inArgs.supports(IN_ARG_x_dot_sg)) {
413  x_dot_sg = inArgs.get_x_dot_sg();
414  if (x_dot_sg != Teuchos::null) {
415  do_quad = true;
416  }
417  }
418  for (int i=0; i<num_p_mp; i++) {
419  p_sg[i] = inArgs.get_p_sg(mp_p_index_map[i]);
420  if (p_sg[i] != Teuchos::null) {
421  do_quad = true;
422  }
423  }
424  if (outArgs.supports(OUT_ARG_f_sg)) {
425  f_sg = outArgs.get_f_sg();
426  if (f_sg != Teuchos::null)
427  f_sg->init(0.0);
428  }
429  if (outArgs.supports(OUT_ARG_W_sg)) {
430  W_sg = outArgs.get_W_sg();
431  if (W_sg != Teuchos::null)
432  W_sg->init(0.0);
433  }
434  for (int i=0; i<num_p; i++) {
435  if (!outArgs.supports(OUT_ARG_DfDp_sg, i).none()) {
436  dfdp_sg[i] = outArgs.get_DfDp_sg(i);
437  if (dfdp_sg[i].getMultiVector() != Teuchos::null)
438  dfdp_sg[i].getMultiVector()->init(0.0);
439  else if (dfdp_sg[i].getLinearOp() != Teuchos::null)
440  dfdp_sg[i].getLinearOp()->init(0.0);
441  }
442  }
443 
444  for (int i=0; i<num_g_mp; i++) {
445  int ii = mp_g_index_map[i];
446  g_sg[i] = outArgs.get_g_sg(ii);
447  if (g_sg[i] != Teuchos::null)
448  g_sg[i]->init(0.0);
449 
450  if (!outArgs.supports(OUT_ARG_DgDx_sg, ii).none()) {
451  dgdx_sg[i] = outArgs.get_DgDx_sg(ii);
452  if (dgdx_sg[i].getMultiVector() != Teuchos::null)
453  dgdx_sg[i].getMultiVector()->init(0.0);
454  else if (dgdx_sg[i].getLinearOp() != Teuchos::null)
455  dgdx_sg[i].getLinearOp()->init(0.0);
456  }
457 
458  if (!outArgs.supports(OUT_ARG_DgDx_dot_sg, ii).none()) {
459  dgdx_dot_sg[i] = outArgs.get_DgDx_dot_sg(ii);
460  if (dgdx_dot_sg[i].getMultiVector() != Teuchos::null)
461  dgdx_dot_sg[i].getMultiVector()->init(0.0);
462  else if (dgdx_dot_sg[i].getLinearOp() != Teuchos::null)
463  dgdx_dot_sg[i].getLinearOp()->init(0.0);
464  }
465 
466  dgdp_sg[i].resize(num_p);
467  for (int j=0; j<num_p; j++) {
468  if (!outArgs.supports(OUT_ARG_DgDp_sg, ii, j).none()) {
469  dgdp_sg[i][j] = outArgs.get_DgDp_sg(ii,j);
470  if (dgdp_sg[i][j].getMultiVector() != Teuchos::null)
471  dgdp_sg[i][j].getMultiVector()->init(0.0);
472  else if (dgdp_sg[i][j].getLinearOp() != Teuchos::null)
473  dgdp_sg[i][j].getLinearOp()->init(0.0);
474  }
475  }
476  }
477 
478  if (do_quad) {
479  // Get quadrature data
480  const Teuchos::Array<double>& quad_weights =
481  quad->getQuadWeights();
482  const Teuchos::Array< Teuchos::Array<double> > & quad_values =
483  quad->getBasisAtQuadPoints();
484  const Teuchos::Array<double>& basis_norms = basis->norm_squared();
485 
486  // Evaluate inputs at quadrature points
487  int nqp = mp_block_map->NumMyElements();
488  for (int qp=0; qp<nqp; qp++) {
489 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
491  "Stokhos: SGQuadMPModelEvaluator -- Polynomial Evaluation",
492  PolyEvaluation);
493 #endif
494 
495  int gqp = mp_block_map->GID(qp);
496 
497  if (x_sg != Teuchos::null) {
498  x_sg->evaluate(quad_values[gqp], (*x_mp)[qp]);
499  me_inargs.set_x_mp(x_mp);
500  }
501  if (x_dot_sg != Teuchos::null) {
502  x_dot_sg->evaluate(quad_values[gqp], (*x_dot_mp)[qp]);
503  me_inargs.set_x_dot_mp(x_mp);
504  }
505  for (int i=0; i<num_p_mp; i++) {
506  if (p_sg[i] != Teuchos::null) {
507  p_sg[i]->evaluate(quad_values[gqp], (*(p_mp[i]))[qp]);
508  me_inargs.set_p_mp(mp_p_index_map[i], p_mp[i]);
509  }
510  }
511 
512  }
513 
514  // Set OutArgs
515  if (f_sg != Teuchos::null)
516  me_outargs.set_f_mp(f_mp);
517  if (W_sg != Teuchos::null)
518  me_outargs.set_W_mp(W_mp);
519  for (int i=0; i<num_p_mp; i++) {
520  if (!dfdp_sg[i].isEmpty())
521  me_outargs.set_DfDp_mp(i, dfdp_mp[i]);
522  }
523  for (int i=0; i<num_g_mp; i++) {
524  int ii = mp_g_index_map[i];
525  if (g_sg[i] != Teuchos::null)
526  me_outargs.set_g_mp(ii, g_mp[i]);
527  if (!dgdx_dot_sg[i].isEmpty())
528  me_outargs.set_DgDx_dot_mp(ii, dgdx_dot_mp[i]);
529  if (!dgdx_sg[i].isEmpty())
530  me_outargs.set_DgDx_mp(ii, dgdx_mp[i]);
531  for (int j=0; j<num_p; j++)
532  if (!dgdp_sg[i][j].isEmpty())
533  me_outargs.set_DgDp_mp(ii, j, dgdp_mp[i][j]);
534  }
535 
536 
537  {
538 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
539  TEUCHOS_FUNC_TIME_MONITOR("Stokhos: SGQuadMPModelEvaluator -- Model Evaluation");
540 #endif
541 
542  // Evaluate multi-point model at quadrature points
543  me->evalModel(me_inargs, me_outargs);
544 
545  }
546 
547  // Perform integrations
548  for (int qp=0; qp<nqp; qp++) {
549 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
551  "Stokhos: SGQuadMPModelEvaluator -- Polynomial Integration", Integration);
552 #endif
553 
554  int gqp = mp_block_map->GID(qp);
555 
556  // Sum in results
557  if (f_sg != Teuchos::null) {
558  f_sg->sumIntoAllTerms(quad_weights[gqp], quad_values[gqp], basis_norms,
559  (*f_mp)[qp]);
560  }
561  if (W_sg != Teuchos::null) {
562  W_sg->sumIntoAllTerms(quad_weights[gqp], quad_values[gqp], basis_norms,
563  (*W_mp)[qp]);
564  }
565  for (int j=0; j<num_p; j++) {
566  if (!dfdp_sg[j].isEmpty()) {
567  if (dfdp_sg[j].getMultiVector() != Teuchos::null) {
568  dfdp_sg[j].getMultiVector()->sumIntoAllTerms(
569  quad_weights[gqp], quad_values[gqp], basis_norms,
570  (*(dfdp_mp[j].getMultiVector()))[qp]);
571  }
572  else if (dfdp_sg[j].getLinearOp() != Teuchos::null) {
573  dfdp_sg[j].getLinearOp()->sumIntoAllTerms(
574  quad_weights[gqp], quad_values[gqp], basis_norms,
575  (*(dfdp_mp[j].getLinearOp()))[qp]);
576  }
577  }
578  }
579  for (int i=0; i<num_g_mp; i++) {
580  if (g_sg[i] != Teuchos::null) {
581  g_sg[i]->sumIntoAllTerms(quad_weights[gqp], quad_values[gqp],
582  basis_norms, (*g_mp[i])[qp]);
583  }
584  if (!dgdx_dot_sg[i].isEmpty()) {
585  if (dgdx_dot_sg[i].getMultiVector() != Teuchos::null) {
586  dgdx_dot_sg[i].getMultiVector()->sumIntoAllTerms(
587  quad_weights[gqp], quad_values[gqp], basis_norms,
588  (*(dgdx_dot_mp[i].getMultiVector()))[qp]);
589  }
590  else if (dgdx_dot_sg[i].getLinearOp() != Teuchos::null) {
591  dgdx_dot_sg[i].getLinearOp()->sumIntoAllTerms(
592  quad_weights[gqp], quad_values[gqp], basis_norms,
593  (*(dgdx_dot_mp[i].getLinearOp()))[qp]);
594  }
595  }
596  if (!dgdx_sg[i].isEmpty()) {
597  if (dgdx_sg[i].getMultiVector() != Teuchos::null) {
598  dgdx_sg[i].getMultiVector()->sumIntoAllTerms(
599  quad_weights[gqp], quad_values[gqp], basis_norms,
600  (*(dgdx_mp[i].getMultiVector()))[qp]);
601  }
602  else if (dgdx_sg[i].getLinearOp() != Teuchos::null) {
603  dgdx_sg[i].getLinearOp()->sumIntoAllTerms(
604  quad_weights[gqp], quad_values[gqp], basis_norms,
605  (*(dgdx_mp[i].getLinearOp()))[qp]);
606  }
607  }
608  for (int j=0; j<num_p; j++) {
609  if (!dgdp_sg[i][j].isEmpty()) {
610  if (dgdp_sg[i][j].getMultiVector() != Teuchos::null) {
611  dgdp_sg[i][j].getMultiVector()->sumIntoAllTerms(
612  quad_weights[gqp], quad_values[gqp], basis_norms,
613  (*(dgdp_mp[i][j].getMultiVector()))[qp]);
614  }
615  else if (dgdp_sg[i][j].getLinearOp() != Teuchos::null) {
616  dgdp_sg[i][j].getLinearOp()->sumIntoAllTerms(
617  quad_weights[gqp], quad_values[gqp], basis_norms,
618  (*(dgdp_mp[i][j].getLinearOp()))[qp]);
619  }
620  }
621  }
622  }
623 
624  }
625 
626  // Now communicate partial sums across processors
627  if (mp_block_map->DistributedGlobal()) {
628  for (int i=0; i<num_g_mp; i++) {
629  if (g_sg[i] != Teuchos::null) {
630  g_sg[i]->sumAll();
631 
632  // Need to do the same for all of the other out args --
633  // function needs to be added to multi-vectors and operators
634  }
635  }
636  }
637  }
638  else {
639  // Compute the non-SG functions
640  me->evalModel(me_inargs, me_outargs);
641  }
642 }
int NumGlobalElements() const
#define TEUCHOS_FUNC_TIME_MONITOR(FUNCNAME)
mp_vector_t x_dot_mp
Time derivative vector.
Teuchos::RCP< Epetra_Operator > create_W() const
Create W = alpha*M + beta*J matrix.
Teuchos::Array< mp_vector_t > p_mp
Parameter vectors.
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Return array of parameter names.
SGQuadMPModelEvaluator(const Teuchos::RCP< EpetraExt::ModelEvaluator > &me, const Teuchos::RCP< const EpetraExt::MultiComm > &mp_comm, const Teuchos::RCP< const Epetra_Map > &mp_block_map)
A container class for products of Epetra_Vector&#39;s.
OutArgs createOutArgs() const
Create OutArgs.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::Array< int > mp_p_index_map
Index map between block-p and p_mp maps.
Teuchos::RCP< const EpetraExt::MultiComm > mp_comm
Parallel MP communicator.
Teuchos::RCP< const Epetra_Vector > get_p_init(int l) const
Return initial parameters.
Teuchos::RCP< const Epetra_Vector > get_x_init() const
Return initial solution.
int NumMyElements() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::Array< MPDerivative > dgdx_dot_mp
Response derivative.
Teuchos::RCP< const Epetra_Map > get_f_map() const
Return residual vector map.
Teuchos::RCP< const Epetra_Map > get_x_map() const
Return solution vector map.
int num_g_mp
Number of multipoint response vectors.
Teuchos::Array< MPDerivative > dfdp_mp
Residual derivatives.
A container class for products of Epetra_Vector&#39;s.
Teuchos::RCP< const Epetra_Map > mp_block_map
Map for layout of parallel MP blocks.
void resize(size_type new_size, const value_type &x=value_type())
A container class storing products of Epetra_MultiVector&#39;s.
Teuchos::Array< int > mp_g_index_map
Index map between block-g and g_mp maps.
void push_back(const value_type &x)
Teuchos::RCP< const Epetra_Map > get_g_map(int l) const
Return observation vector map.
size_type size() const
Teuchos::RCP< const Epetra_Map > get_p_map(int l) const
Return parameter vector map.
Teuchos::RCP< EpetraExt::ModelEvaluator > me
Underlying model evaluator.
int num_p_mp
Number of multipoint parameter vectors.
Teuchos::Array< mp_vector_t > g_mp
Response vectors.
Teuchos::Array< MPDerivative > dgdx_mp
Response derivative.
void evalModel(const InArgs &inArgs, const OutArgs &outArgs) const
Evaluate model on InArgs.
int num_p
Number of parameter vectors.
#define TEUCHOS_FUNC_TIME_MONITOR_DIFF(FUNCNAME, DIFF)
Teuchos::Array< Teuchos::Array< MPDerivative > > dgdp_mp
Response sensitivities.