14 #include "EpetraExt_BlockUtility.h"
15 #include "EpetraExt_BlockMultiVector.h"
37 num_sg_blocks(sg_basis->size()),
38 num_W_blocks(sg_basis->size()),
39 num_p_blocks(sg_basis->size()),
41 x_map(me->get_x_map()),
42 f_map(me->get_f_map()),
43 sg_parallel_data(sg_parallel_data_),
44 sg_comm(sg_parallel_data->getMultiComm()),
45 epetraCijk(sg_parallel_data->getEpetraCijk()),
48 sg_overlapped_x_map(),
50 sg_overlapped_f_map(),
51 sg_overlapped_x_importer(),
52 sg_overlapped_f_exporter(),
79 stoch_row_map =
epetraCijk->getStochasticRowMap();
118 std::string W_expansion_type =
119 params->
get(
"Jacobian Expansion Type",
"Full");
120 if (W_expansion_type ==
"Linear")
132 W_sg_blocks->setCoeffPtr(i,
me->create_W());
145 InArgs me_inargs =
me->createInArgs();
146 OutArgs me_outargs =
me->createOutArgs();
147 num_p = me_inargs.Np();
150 for (
int i=0; i<
num_p; i++) {
151 if (me_inargs.supports(IN_ARG_p_sg, i))
161 std::string p_expansion_type =
162 params->
get(
"Parameter Expansion Type",
"Full");
163 if (p_expansion_type ==
"Linear")
184 for (
int j=0;
j<p_names->size();
j++) {
185 std::stringstream ss;
186 ss << (*p_names)[
j] <<
" -- SG Coefficient " << i;
199 num_g = me_outargs.Ng();
202 for (
int i=0; i<
num_g; i++) {
203 if (me_outargs.supports(OUT_ARG_g_sg, i))
247 "Error! Invalid p map index " << l);
249 return me->get_p_map(l);
251 return sg_p_map[l-num_p];
260 "Error! Invalid g map index " << j);
268 "Error! Invalid p map index " << l);
270 return me->get_p_names(l);
272 return sg_p_names[l-num_p];
280 return sg_x_init->getBlockVector();
287 "Error! Invalid p map index " << l);
289 return me->get_p_init(l);
291 return sg_p_init[l-num_p]->getBlockVector();
303 if (sgOpParams->
get(
"Operator Method",
"Matrix Free") ==
312 my_W = sg_op_factory.
build(sg_comm, sg_basis, epetraCijk, x_map, f_map,
314 my_W->setupOperator(W_sg_blocks);
328 sg_prec_factory->build(sg_comm, sg_basis, epetraCijk, x_map, sg_x_map);
329 return Teuchos::rcp(
new EpetraExt::ModelEvaluator::Preconditioner(precOp,
341 "Error: dg/dx index " << j <<
" is not supported!");
343 int jj = sg_g_index_map[
j];
346 OutArgs me_outargs = me->createOutArgs();
347 DerivativeSupport ds = me_outargs.supports(OUT_ARG_DgDx_sg, jj);
348 if (ds.supports(DERIV_LINEAR_OP)) {
351 sg_basis, overlapped_stoch_row_map, x_map,
352 g_map, sg_g_map[j], sg_comm));
353 for (
unsigned int i=0; i<num_sg_blocks; i++)
356 else if (ds.supports(DERIV_MV_BY_COL)) {
359 sg_basis, overlapped_stoch_row_map, g_map, sg_g_map[j],
363 sg_mv_blocks,
false));
365 else if (ds.supports(DERIV_TRANS_MV_BY_ROW)) {
368 sg_basis, overlapped_stoch_row_map, x_map, sg_x_map,
372 sg_mv_blocks,
true));
376 "Error! me_outargs.supports(OUT_ARG_DgDx_sg, " << jj
377 <<
").none() is true!");
383 sg_comm, sg_basis, serialCijk, x_map, g_map,
384 sg_x_map, sg_g_map[j], pl));
394 "Error: dg/dx_dot index " << j <<
" is not supported!");
396 int jj = sg_g_index_map[
j];
399 OutArgs me_outargs = me->createOutArgs();
400 DerivativeSupport ds = me_outargs.supports(OUT_ARG_DgDx_dot_sg, jj);
401 if (ds.supports(DERIV_LINEAR_OP)) {
404 sg_basis, overlapped_stoch_row_map, x_map,
405 g_map, sg_g_map[j], sg_comm));
406 for (
unsigned int i=0; i<num_sg_blocks; i++)
407 sg_blocks->
setCoeffPtr(i, me->create_DgDx_dot_op(jj));
409 else if (ds.supports(DERIV_MV_BY_COL)) {
412 sg_basis, overlapped_stoch_row_map, g_map, sg_g_map[j],
416 sg_mv_blocks,
false));
418 else if (ds.supports(DERIV_TRANS_MV_BY_ROW)) {
421 sg_basis, overlapped_stoch_row_map, x_map, sg_x_map,
425 sg_mv_blocks,
true));
429 "Error! me_outargs.supports(OUT_ARG_DgDx_dot_sg, "
430 << jj <<
").none() is true!");
436 sg_comm, sg_basis, serialCijk, x_map, g_map,
437 sg_x_map, sg_g_map[j], pl));
446 j < 0 || j >= num_g_sg || i < 0 || i >= num_p+num_p_sg,
448 "Error: dg/dp index " << j <<
"," << i <<
" is not supported!");
450 int jj = sg_g_index_map[
j];
452 OutArgs me_outargs = me->createOutArgs();
454 if (me_outargs.supports(OUT_ARG_DgDp_sg,jj,i).supports(DERIV_LINEAR_OP)) {
457 sg_basis, overlapped_stoch_row_map,
458 me->get_p_map(i), me->get_g_map(jj),
459 sg_g_map[
j], sg_comm));
460 for (
unsigned int l=0; l<num_sg_blocks; l++)
461 sg_blocks->
setCoeffPtr(l, me->create_DgDp_op(jj,i));
466 true, std::logic_error,
467 "Error: Underlying model evaluator must support DERIV_LINER_OP " <<
468 "to create operator for dg/dp index " << j <<
"," << i <<
"!");
471 int ii = sg_p_index_map[i-num_p];
474 DerivativeSupport ds = me_outargs.supports(OUT_ARG_DgDp_sg,jj,ii);
475 if (ds.supports(DERIV_LINEAR_OP)) {
478 sg_basis, overlapped_stoch_row_map,
479 p_map, g_map, sg_g_map[j], sg_comm));
480 for (
unsigned int l=0; l<num_sg_blocks; l++)
481 sg_blocks->
setCoeffPtr(l, me->create_DgDp_op(jj,ii));
483 else if (ds.supports(DERIV_MV_BY_COL)) {
486 sg_basis, overlapped_stoch_row_map, g_map, sg_g_map[j],
490 sg_mv_blocks,
false));
492 else if (ds.supports(DERIV_TRANS_MV_BY_ROW)) {
495 sg_basis, overlapped_stoch_row_map, p_map,
500 sg_mv_blocks,
true));
504 "Error! me_outargs.supports(OUT_ARG_DgDp_sg, " << jj
505 <<
"," << ii <<
").none() is true!");
511 sg_comm, sg_basis, serialCijk,
512 p_map, g_map, sg_p_map[i-num_p], sg_g_map[j], pl));
525 "Error: df/dp index " << i <<
" is not supported!");
527 OutArgs me_outargs = me->createOutArgs();
529 if (me_outargs.supports(OUT_ARG_DfDp_sg,i).supports(DERIV_LINEAR_OP)) {
532 sg_basis, overlapped_stoch_row_map,
533 me->get_p_map(i), f_map,
534 sg_overlapped_f_map, sg_comm));
535 for (
unsigned int l=0; l<num_sg_blocks; l++)
541 true, std::logic_error,
542 "Error: Underlying model evaluator must support DERIV_LINER_OP " <<
543 "to create operator for df/dp index " << i <<
"!");
546 int ii = sg_p_index_map[i-num_p];
549 DerivativeSupport ds = me_outargs.supports(OUT_ARG_DfDp_sg,ii);
550 if (ds.supports(DERIV_LINEAR_OP)) {
553 sg_basis, overlapped_stoch_row_map,
554 p_map, f_map, sg_overlapped_f_map, sg_comm));
555 for (
unsigned int l=0; l<num_sg_blocks; l++)
558 else if (ds.supports(DERIV_MV_BY_COL)) {
561 sg_basis, overlapped_stoch_row_map, f_map, sg_f_map,
565 sg_mv_blocks,
false));
567 else if (ds.supports(DERIV_TRANS_MV_BY_ROW)) {
570 sg_basis, overlapped_stoch_row_map, p_map,
575 sg_mv_blocks,
true));
579 "Error! me_outargs.supports(OUT_ARG_DfDp_sg, " << ii
580 <<
").none() is true!");
586 sg_comm, sg_basis, epetraCijk,
587 p_map, f_map, sg_p_map[i-num_p], sg_f_map, pl));
595 EpetraExt::ModelEvaluator::InArgs
599 InArgs me_inargs = me->createInArgs();
601 inArgs.setModelEvalDescription(this->description());
602 inArgs.set_Np(num_p+num_p_sg);
603 inArgs.setSupports(IN_ARG_x_dot, me_inargs.supports(IN_ARG_x_dot_sg));
604 inArgs.setSupports(IN_ARG_x, me_inargs.supports(IN_ARG_x_sg));
605 inArgs.setSupports(IN_ARG_t, me_inargs.supports(IN_ARG_t));
606 inArgs.setSupports(IN_ARG_alpha, me_inargs.supports(IN_ARG_alpha));
607 inArgs.setSupports(IN_ARG_beta, me_inargs.supports(IN_ARG_beta));
608 inArgs.setSupports(IN_ARG_sg_basis, me_inargs.supports(IN_ARG_sg_basis));
609 inArgs.setSupports(IN_ARG_sg_quadrature,
610 me_inargs.supports(IN_ARG_sg_quadrature));
611 inArgs.setSupports(IN_ARG_sg_expansion,
612 me_inargs.supports(IN_ARG_sg_expansion));
617 EpetraExt::ModelEvaluator::OutArgs
620 OutArgsSetup outArgs;
621 OutArgs me_outargs = me->createOutArgs();
623 outArgs.setModelEvalDescription(this->description());
624 outArgs.set_Np_Ng(num_p+num_p_sg, num_g_sg);
625 outArgs.setSupports(OUT_ARG_f, me_outargs.supports(OUT_ARG_f_sg));
626 outArgs.setSupports(OUT_ARG_W, me_outargs.supports(OUT_ARG_W_sg));
629 me_outargs.supports(OUT_ARG_W_sg) && sg_prec_factory->isPrecSupported());
630 for (
int j=0;
j<num_p;
j++)
631 outArgs.setSupports(OUT_ARG_DfDp,
j,
632 me_outargs.supports(OUT_ARG_DfDp_sg,
j));
633 for (
int j=0;
j<num_p_sg;
j++)
634 if (!me_outargs.supports(OUT_ARG_DfDp_sg, sg_p_index_map[
j]).none())
635 outArgs.setSupports(OUT_ARG_DfDp, j+num_p, DERIV_LINEAR_OP);
636 for (
int i=0; i<num_g_sg; i++) {
637 int ii = sg_g_index_map[i];
638 if (!me_outargs.supports(OUT_ARG_DgDx_dot_sg, ii).none())
639 outArgs.setSupports(OUT_ARG_DgDx_dot, i, DERIV_LINEAR_OP);
640 if (!me_outargs.supports(OUT_ARG_DgDx_sg, ii).none())
641 outArgs.setSupports(OUT_ARG_DgDx, i, DERIV_LINEAR_OP);
642 for (
int j=0; j<num_p; j++)
643 outArgs.setSupports(OUT_ARG_DgDp, i, j,
644 me_outargs.supports(OUT_ARG_DgDp_sg, ii, j));
645 for (
int j=0; j<num_p_sg; j++)
646 if (!me_outargs.supports(OUT_ARG_DgDp_sg, ii, sg_p_index_map[j]).none())
647 outArgs.setSupports(OUT_ARG_DgDp, i, j+num_p, DERIV_LINEAR_OP);
655 const OutArgs& outArgs)
const
659 if (inArgs.supports(IN_ARG_x)) {
665 if (inArgs.supports(IN_ARG_x_dot))
666 x_dot = inArgs.get_x_dot();
669 EpetraExt::ModelEvaluator::Evaluation<Epetra_Vector> f_out;
670 if (outArgs.supports(OUT_ARG_f))
671 f_out = outArgs.get_f();
673 if (outArgs.supports(OUT_ARG_W))
674 W_out = outArgs.get_W();
676 if (outArgs.supports(OUT_ARG_WPrec))
677 WPrec_out = outArgs.get_WPrec();
693 for (
int i=0; i<outArgs.Ng(); i++) {
695 for (
int j=0;
j<outArgs.Np();
j++)
696 if (!outArgs.supports(OUT_ARG_DgDp, i,
j).none())
697 done = done && (outArgs.get_DgDp(i,
j).isEmpty());
704 InArgs me_inargs = me->createInArgs();
706 x_sg_blocks->getBlockVector()->Import(*x, *sg_overlapped_x_importer,
708 me_inargs.set_x_sg(x_sg_blocks);
711 x_dot_sg_blocks->getBlockVector()->Import(*x_dot, *sg_overlapped_x_importer,
713 me_inargs.set_x_dot_sg(x_dot_sg_blocks);
715 if (me_inargs.supports(IN_ARG_alpha))
716 me_inargs.set_alpha(inArgs.get_alpha());
717 if (me_inargs.supports(IN_ARG_beta))
718 me_inargs.set_beta(inArgs.get_beta());
719 if (me_inargs.supports(IN_ARG_t))
720 me_inargs.set_t(inArgs.get_t());
721 if (me_inargs.supports(IN_ARG_sg_basis)) {
723 me_inargs.set_sg_basis(inArgs.get_sg_basis());
725 me_inargs.set_sg_basis(sg_basis);
727 if (me_inargs.supports(IN_ARG_sg_quadrature)) {
729 me_inargs.set_sg_quadrature(inArgs.get_sg_quadrature());
731 me_inargs.set_sg_quadrature(sg_quad);
733 if (me_inargs.supports(IN_ARG_sg_expansion)) {
735 me_inargs.set_sg_expansion(inArgs.get_sg_expansion());
737 me_inargs.set_sg_expansion(sg_exp);
741 for (
int i=0; i<num_p; i++)
742 me_inargs.set_p(i, inArgs.get_p(i));
743 for (
int i=0; i<num_p_sg; i++) {
749 p = sg_p_init[i]->getBlockVector();
753 create_p_sg(sg_p_index_map[i],
View, p.
get());
754 me_inargs.set_p_sg(sg_p_index_map[i], p_sg);
758 OutArgs me_outargs = me->createOutArgs();
762 me_outargs.set_f_sg(f_sg_blocks);
764 me_outargs.set_W_sg(W_sg_blocks);
769 me_outargs.set_W_sg(W_sg_blocks);
772 for (
int i=0; i<num_p; i++) {
773 if (!outArgs.supports(OUT_ARG_DfDp, i).none()) {
774 Derivative dfdp = outArgs.get_DfDp(i);
777 if (dfdp.getMultiVectorOrientation() == DERIV_MV_BY_COL)
780 sg_basis, overlapped_stoch_row_map,
781 me->get_f_map(), sg_overlapped_f_map, sg_comm,
782 me->get_p_map(i)->NumMyElements()));
783 else if (dfdp.getMultiVectorOrientation() == DERIV_TRANS_MV_BY_ROW)
786 sg_basis, overlapped_stoch_row_map,
787 me->get_p_map(i), sg_comm,
788 me->get_f_map()->NumMyElements()));
789 me_outargs.set_DfDp_sg(
790 i, SGDerivative(dfdp_sg, dfdp.getMultiVectorOrientation()));
795 me_outargs.set_DfDp_sg(i, SGDerivative(dfdp_sg));
801 for (
int i=0; i<num_p_sg; i++) {
802 if (!outArgs.supports(OUT_ARG_DfDp, i+num_p).none()) {
803 Derivative dfdp = outArgs.get_DfDp(i+num_p);
809 int ii = sg_p_index_map[i];
810 if (me_outargs.supports(OUT_ARG_DfDp_sg,ii).supports(DERIV_LINEAR_OP))
811 me_outargs.set_DfDp_sg(ii, SGDerivative(dfdp_op_sg));
817 if (me_outargs.supports(OUT_ARG_DfDp_sg,ii).supports(DERIV_MV_BY_COL))
818 me_outargs.set_DfDp_sg(
819 ii, SGDerivative(dfdp_sg, DERIV_MV_BY_COL));
821 me_outargs.set_DfDp_sg(
822 ii, SGDerivative(dfdp_sg, DERIV_TRANS_MV_BY_ROW));
826 dfdp.getLinearOp() ==
Teuchos::null && dfdp.isEmpty() ==
false,
828 "Error! Stokhos::SGModelEvaluator::evalModel: " <<
829 "Operator form of df/dp(" << i+num_p <<
") is required!");
834 for (
int i=0; i<num_g_sg; i++) {
835 int ii = sg_g_index_map[i];
841 create_g_sg(sg_g_index_map[i],
View, g.
get());
842 me_outargs.set_g_sg(ii, g_sg);
846 if (outArgs.supports(OUT_ARG_DgDx_dot, i).supports(DERIV_LINEAR_OP)) {
847 Derivative dgdx_dot = outArgs.get_DgDx_dot(i);
851 dgdx_dot.getLinearOp(),
true);
854 if (me_outargs.supports(OUT_ARG_DgDx, ii).supports(DERIV_LINEAR_OP))
855 me_outargs.set_DgDx_dot_sg(ii, sg_blocks);
861 if (me_outargs.supports(OUT_ARG_DgDx_dot_sg, ii).supports(DERIV_MV_BY_COL))
862 me_outargs.set_DgDx_dot_sg(ii, SGDerivative(dgdx_dot_sg,
865 me_outargs.set_DgDx_dot_sg(ii, SGDerivative(dgdx_dot_sg,
866 DERIV_TRANS_MV_BY_ROW));
870 dgdx_dot.getLinearOp() ==
Teuchos::null && dgdx_dot.isEmpty() ==
false,
872 "Error! Stokhos::SGModelEvaluator::evalModel: " <<
873 "Operator form of dg/dxdot(" << i <<
") is required!");
877 if (outArgs.supports(OUT_ARG_DgDx, i).supports(DERIV_LINEAR_OP)) {
878 Derivative dgdx = outArgs.get_DgDx(i);
882 dgdx.getLinearOp(),
true);
885 if (me_outargs.supports(OUT_ARG_DgDx, ii).supports(DERIV_LINEAR_OP))
886 me_outargs.set_DgDx_sg(ii, sg_blocks);
892 if (me_outargs.supports(OUT_ARG_DgDx_sg, ii).supports(DERIV_MV_BY_COL))
893 me_outargs.set_DgDx_sg(ii, SGDerivative(dgdx_sg,
896 me_outargs.set_DgDx_sg(ii, SGDerivative(dgdx_sg,
897 DERIV_TRANS_MV_BY_ROW));
901 dgdx.getLinearOp() ==
Teuchos::null && dgdx.isEmpty() ==
false,
903 "Error! Stokhos::SGModelEvaluator::evalModel: " <<
904 "Operator form of dg/dx(" << i <<
") is required!");
908 for (
int j=0;
j<num_p;
j++) {
909 if (!outArgs.supports(OUT_ARG_DgDp, i,
j).none()) {
910 Derivative dgdp = outArgs.get_DgDp(i,
j);
913 if (dgdp.getMultiVectorOrientation() == DERIV_MV_BY_COL)
916 sg_basis, overlapped_stoch_row_map,
917 me->get_g_map(ii), sg_g_map[i], sg_comm,
918 View, *(dgdp.getMultiVector())));
919 else if (dgdp.getMultiVectorOrientation() == DERIV_TRANS_MV_BY_ROW) {
924 sg_basis, overlapped_stoch_row_map,
925 me->get_p_map(
j), product_map, sg_comm,
926 View, *(dgdp.getMultiVector())));
928 me_outargs.set_DgDp_sg(
929 ii,
j, SGDerivative(dgdp_sg, dgdp.getMultiVectorOrientation()));
934 me_outargs.set_DgDp_sg(ii,
j, SGDerivative(dgdp_sg));
940 for (
int j=0;
j<num_p_sg;
j++) {
941 if (!outArgs.supports(OUT_ARG_DgDp, i,
j+num_p).none()) {
942 Derivative dgdp = outArgs.get_DgDp(i,
j+num_p);
948 int jj = sg_p_index_map[
j];
949 if (me_outargs.supports(OUT_ARG_DgDp_sg,ii,jj).supports(DERIV_LINEAR_OP))
950 me_outargs.set_DgDp_sg(ii, jj, SGDerivative(dgdp_op_sg));
956 if (me_outargs.supports(OUT_ARG_DgDp_sg,ii,jj).supports(DERIV_MV_BY_COL))
957 me_outargs.set_DgDp_sg(
958 ii, jj, SGDerivative(dgdp_sg, DERIV_MV_BY_COL));
960 me_outargs.set_DgDp_sg(
961 ii, jj, SGDerivative(dgdp_sg, DERIV_TRANS_MV_BY_ROW));
965 dgdp.getLinearOp() ==
Teuchos::null && dgdp.isEmpty() ==
false,
967 "Error! Stokhos::SGModelEvaluator::evalModel: " <<
968 "Operator form of dg/dp(" << i <<
"," <<
j+num_p <<
") is required!");
975 me->evalModel(me_inargs, me_outargs);
999 for (
int i=0; i<sg_basis->size(); i++)
1000 (*f_sg_blocks)[i].Scale(sg_basis->norm_squared(i));
1001 f_out->Export(*(f_sg_blocks->getBlockVector()), *sg_overlapped_f_exporter,
1006 for (
int i=0; i<num_p; i++) {
1007 if (!outArgs.supports(OUT_ARG_DfDp, i).none()) {
1008 Derivative dfdp = outArgs.get_DfDp(i);
1009 SGDerivative dfdp_sg = me_outargs.get_DfDp_sg(i);
1011 dfdp.getMultiVector()->Export(
1012 *(dfdp_sg.getMultiVector()->getBlockMultiVector()),
1013 *sg_overlapped_f_exporter,
Insert);
1030 *sg_x_init = x_sg_in;
1044 sg_p_index_map.end(),
1047 "Error! Invalid p map index " << i);
1048 int ii = it - sg_p_index_map.
begin();
1049 *sg_p_init[ii] = p_sg_in;
1056 sg_p_index_map.end(),
1059 "Error! Invalid p map index " << l);
1060 int ll = it - sg_p_index_map.
begin();
1061 return sg_p_init[ll];
1067 return sg_p_index_map;
1073 return sg_g_index_map;
1080 for (
int i=0; i<num_g; i++)
1081 base_maps[i] = me->get_g_map(i);
1088 return overlapped_stoch_row_map;
1094 return sg_overlapped_x_map;
1100 return sg_overlapped_x_importer;
1110 sg_basis, stoch_row_map, x_map, sg_x_map, sg_comm));
1113 sg_basis, stoch_row_map, x_map, sg_x_map, sg_comm,
1125 sg_basis, overlapped_stoch_row_map, x_map,
1126 sg_overlapped_x_map, sg_comm));
1129 sg_basis, overlapped_stoch_row_map, x_map,
1130 sg_overlapped_x_map, sg_comm, CV, *v));
1141 sg_basis, stoch_row_map, x_map, sg_x_map, sg_comm,
1145 sg_basis, stoch_row_map, x_map, sg_x_map, sg_comm,
1159 sg_basis, overlapped_stoch_row_map, x_map,
1160 sg_overlapped_x_map, sg_comm, num_vecs));
1163 sg_basis, overlapped_stoch_row_map, x_map,
1164 sg_overlapped_x_map, sg_comm, CV, *v));
1174 sg_p_index_map.end(),
1177 "Error! Invalid p map index " << l);
1178 int ll = it - sg_p_index_map.
begin();
1181 sg_basis, overlapped_stoch_p_map, me->get_p_map(l),
1182 sg_p_map[ll], sg_comm));
1185 sg_basis, overlapped_stoch_p_map, me->get_p_map(l),
1186 sg_p_map[ll], sg_comm, CV, *v));
1197 sg_basis, stoch_row_map, f_map, sg_f_map, sg_comm));
1200 sg_basis, stoch_row_map, f_map, sg_f_map, sg_comm,
1212 sg_basis, overlapped_stoch_row_map, f_map,
1213 sg_overlapped_f_map, sg_comm));
1216 sg_basis, overlapped_stoch_row_map, f_map,
1217 sg_overlapped_f_map, sg_comm, CV, *v));
1230 sg_basis, stoch_row_map, f_map, sg_f_map, sg_comm,
1234 sg_basis, stoch_row_map, f_map, sg_f_map, sg_comm,
1248 sg_basis, overlapped_stoch_row_map, f_map,
1249 sg_overlapped_f_map, sg_comm, num_vecs));
1252 sg_basis, overlapped_stoch_row_map, f_map,
1253 sg_overlapped_f_map, sg_comm, CV, *v));
1263 sg_g_index_map.end(),
1266 "Error! Invalid g map index " << l);
1267 int ll = it - sg_g_index_map.
begin();
1270 sg_basis, overlapped_stoch_row_map,
1272 sg_g_map[ll], sg_comm));
1275 sg_basis, overlapped_stoch_row_map,
1277 sg_g_map[ll], sg_comm, CV, *v));
1288 sg_g_index_map.end(),
1291 "Error! Invalid g map index " << l);
1292 int ll = it - sg_g_index_map.
begin();
1295 sg_basis, overlapped_stoch_row_map,
1297 sg_g_map[ll], sg_comm, num_vecs));
1300 sg_basis, overlapped_stoch_row_map,
1302 sg_g_map[ll], sg_comm, CV, *v));
1310 Teuchos::rcp(
new EpetraExt::BlockVector(*x_map, *sg_overlapped_x_map));
1311 x_overlapped->Import(x, *sg_overlapped_x_importer,
Insert);
1312 return x_overlapped;
1320 sg_basis, overlapped_stoch_row_map, x_map,
1321 sg_overlapped_x_map, sg_comm));
1322 sg_x_overlapped->
getBlockVector()->Import(x, *sg_overlapped_x_importer,
1324 return sg_x_overlapped;
1331 Teuchos::rcp(
new EpetraExt::BlockVector(*x_map, *sg_x_map));
1332 x->Export(x_overlapped, *sg_overlapped_x_importer,
Insert);
1340 Teuchos::rcp(
new EpetraExt::BlockVector(*f_map, *sg_overlapped_f_map));
1341 f_overlapped->Import(f, *sg_overlapped_f_exporter,
Insert);
1342 return f_overlapped;
1349 Teuchos::rcp(
new EpetraExt::BlockVector(*f_map, *sg_f_map));
1350 f->Export(f_overlapped, *sg_overlapped_f_exporter,
Insert);
Teuchos::RCP< const Stokhos::EpetraSparse3Tensor > epetraCijk
Epetra Cijk.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > create_x_sg(Epetra_DataAccess CV=Copy, const Epetra_Vector *v=NULL) const
Create vector orthog poly using x map and owned sg map.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > create_p_sg(int l, Epetra_DataAccess CV=Copy, const Epetra_Vector *v=NULL) const
Create vector orthog poly using p map.
Teuchos::RCP< Stokhos::EpetraOperatorOrthogPoly > W_sg_blocks
W stochastic Galerkin components.
Teuchos::RCP< const Epetra_Map > get_x_map() const
Return solution vector map.
Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > create_f_mv_sg_overlap(int num_vecs, Epetra_DataAccess CV=Copy, const Epetra_MultiVector *v=NULL) const
Create multi-vector orthog poly using f map and overlap sg map.
An Epetra operator representing the block stochastic Galerkin operator.
Teuchos::RCP< const Epetra_Map > sg_overlapped_f_map
Block SG overlapped residual map.
void setCoeffPtr(ordinal_type i, const Teuchos::RCP< coeff_type > &c)
Set coefficient i to c.
virtual void setupOperator(const Teuchos::RCP< Stokhos::EpetraOperatorOrthogPoly > &poly)=0
Setup operator.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > sg_x_init
SG initial x.
A container class storing an orthogonal polynomial whose coefficients are vectors, operators, or in general any type that would have an expensive copy constructor.
Teuchos::Array< int > sg_g_index_map
Index map between block-g and g_sg maps.
unsigned int num_sg_blocks
Number of stochastic blocks.
Teuchos::RCP< const Epetra_Map > get_g_map(int l) const
Return response map.
bool myGID(int i) const
Return whether global index i resides on this processor.
Teuchos::RCP< const Epetra_Map > x_map
Underlying unknown map.
Teuchos::RCP< const Epetra_Map > get_f_map() const
Return residual vector map.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > x_sg_blocks
x stochastic Galerkin components
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > f_sg_blocks
f stochastic Galerkin components
int num_p_sg
Number of stochastic parameter vectors.
T & get(ParameterList &l, const std::string &name)
bool eval_W_with_f
Whether to always evaluate W with f.
void evalModel(const InArgs &inArgs, const OutArgs &outArgs) const
Evaluate model on InArgs.
Teuchos::RCP< EpetraExt::BlockVector > getBlockVector()
Get block vector.
Teuchos::RCP< const Epetra_BlockMap > get_overlap_stochastic_map() const
Return overlap stochastic map.
Teuchos::RCP< const Epetra_Map > sg_overlapped_x_map
Block SG overlapped unknown map.
SGModelEvaluator(const Teuchos::RCP< EpetraExt::ModelEvaluator > &me, const Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > &sg_basis, const Teuchos::RCP< const Stokhos::Quadrature< int, double > > &sg_quad, const Teuchos::RCP< Stokhos::OrthogPolyExpansion< int, double > > &sg_exp, const Teuchos::RCP< const Stokhos::ParallelData > &sg_parallel_data, const Teuchos::RCP< Teuchos::ParameterList > ¶ms, bool scaleOP=true)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::Array< Teuchos::RCP< const Epetra_Map > > sg_g_map
Block SG response map.
Teuchos::RCP< const Stokhos::EpetraVectorOrthogPoly > get_p_sg_init(int l) const
Return initial SG parameters.
Teuchos::RCP< Epetra_Operator > create_DgDp_op(int j, int i) const
Create SG operator representing dg/dp.
unsigned int num_p_blocks
Number of p stochastic blocks (may be smaller than num_sg_blocks)
RCP< ParameterList > sublist(const RCP< ParameterList > ¶mList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Teuchos::RCP< const Stokhos::ParallelData > sg_parallel_data
Parallel SG data.
Teuchos::RCP< const Epetra_BlockMap > overlapped_stoch_p_map
Overlapped map for p stochastic blocks (local map)
virtual ordinal_type dimension() const =0
Return dimension of basis.
Teuchos::Array< Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > > sg_p_init
SG initial p.
Teuchos::RCP< const Stokhos::EpetraSparse3Tensor > serialCijk
Serial Epetra Cijk for dgdx*.
Teuchos::Array< int > get_p_sg_map_indices() const
Get indices of SG parameters.
Teuchos::RCP< const Epetra_Map > sg_f_map
Block SG residual map.
OutArgs createOutArgs() const
Create OutArgs.
Abstract base class for orthogonal polynomial-based expansions.
Teuchos::RCP< EpetraExt::BlockVector > import_solution(const Epetra_Vector &x) const
Import parallel solution vector.
int NumMyElements() const
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > create_g_sg(int l, Epetra_DataAccess CV=Copy, const Epetra_Vector *v=NULL) const
Create vector orthog poly using g map.
Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > create_f_mv_sg(int num_vecs, Epetra_DataAccess CV=Copy, const Epetra_MultiVector *v=NULL) const
Create multi-vector orthog poly using f map and owned sg map.
int num_g_sg
Number of stochastic response vectors.
Teuchos::RCP< const Epetra_BlockMap > stoch_row_map
Map for stochastic blocks.
Teuchos::RCP< const Epetra_BlockMap > get_x_sg_overlap_map() const
Return x sg overlap map.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
An abstract class to represent a generic stochastic Galerkin operator as an Epetra_Operator.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > x_dot_sg_blocks
x_dot stochastic Galerkin components
Teuchos::RCP< const Epetra_Vector > get_x_init() const
Return initial solution.
Teuchos::RCP< Stokhos::SGPreconditionerFactory > sg_prec_factory
Preconditioner factory.
A container class storing an orthogonal polynomial whose coefficients are vectors, operators, or in general any type that would have an expensive copy constructor.
virtual Teuchos::RCP< Stokhos::SGOperator > build(const Teuchos::RCP< const EpetraExt::MultiComm > &sg_comm, const Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > &sg_basis, const Teuchos::RCP< const Stokhos::EpetraSparse3Tensor > &epetraCijk, const Teuchos::RCP< const Epetra_Map > &domain_base_map, const Teuchos::RCP< const Epetra_Map > &range_base_map, const Teuchos::RCP< const Epetra_Map > &domain_sg_map, const Teuchos::RCP< const Epetra_Map > &range_sg_map)
Build preconditioner operator.
virtual Teuchos::RCP< Stokhos::EpetraOperatorOrthogPoly > getSGPolynomial()=0
Get SG polynomial.
Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > sg_basis
Stochastic Galerkin basis.
Teuchos::Array< Teuchos::RCP< const Epetra_Map > > sg_p_map
Block SG parameter map.
A container class storing an orthogonal polynomial whose coefficients are vectors, operators, or in general any type that would have an expensive copy constructor.
bool supports_x
Whether we support x (and thus f and W)
void set_p_sg_init(int i, const Stokhos::EpetraVectorOrthogPoly &p_sg_in)
Set initial parameter polynomial.
Teuchos::RCP< const Stokhos::EpetraVectorOrthogPoly > get_x_sg_init() const
Return initial SG x.
Teuchos::RCP< EpetraMultiVectorOrthogPoly > multiVectorOrthogPoly() const
Get multi vector orthog poly.
Teuchos::Array< int > get_g_sg_map_indices() const
Get indices of SG responses.
Factory for generating stochastic Galerkin preconditioners.
Teuchos::RCP< Epetra_Export > sg_overlapped_f_exporter
Exporter from SG-overlapped to SG maps.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > create_x_sg_overlap(Epetra_DataAccess CV=Copy, const Epetra_Vector *v=NULL) const
Create vector orthog poly using x map and overlap sg map.
virtual Teuchos::RCP< Stokhos::EpetraOperatorOrthogPoly > getSGPolynomial()
Get SG polynomial.
Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > create_x_mv_sg(int num_vecs, Epetra_DataAccess CV=Copy, const Epetra_MultiVector *v=NULL) const
Create vector orthog poly using x map and owned sg map.
Teuchos::Array< Teuchos::RCP< Teuchos::Array< std::string > > > sg_p_names
SG coefficient parameter names.
Teuchos::RCP< EpetraExt::ModelEvaluator > me
Underlying model evaluator.
Teuchos::RCP< const Epetra_Map > get_p_map(int l) const
Return parameter vector map.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > create_f_sg_overlap(Epetra_DataAccess CV=Copy, const Epetra_Vector *v=NULL) const
Create vector orthog poly using f map and overlap sg map.
std::vector< T >::const_iterator const_iterator
virtual void setupPreconditioner(const Teuchos::RCP< Stokhos::SGOperator > &sg_op, const Epetra_Vector &x)=0
Setup preconditioner.
Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > create_g_mv_sg(int l, int num_vecs, Epetra_DataAccess CV=Copy, const Epetra_MultiVector *v=NULL) const
Create multi-vector orthog poly using g map.
unsigned int num_W_blocks
Number of W stochastic blocks (may be smaller than num_sg_blocks)
InArgs createInArgs() const
Create InArgs.
void set_x_sg_init(const Stokhos::EpetraVectorOrthogPoly &x_sg_in)
Set initial solution polynomial.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > import_solution_poly(const Epetra_Vector &x) const
Import parallel solution vector.
Teuchos::RCP< EpetraExt::BlockVector > import_residual(const Epetra_Vector &f) const
Import parallel residual vector.
Teuchos::RCP< const Epetra_Import > get_x_sg_importer() const
Return x sg importer.
void push_back(const value_type &x)
Teuchos::RCP< const Epetra_BlockMap > overlapped_stoch_row_map
Overlapped map for stochastic blocks (local map)
ScalarType f(const Teuchos::Array< ScalarType > &x, double a, double b)
int num_g
Number of response vectors of underlying model evaluator.
Teuchos::RCP< Epetra_Operator > create_DgDx_dot_op(int j) const
Create SG operator representing dg/dxdot.
int num_p
Number of parameter vectors of underlying model evaluator.
Teuchos::RCP< Epetra_Import > sg_overlapped_x_importer
Importer from SG to SG-overlapped maps.
Teuchos::RCP< Epetra_Operator > create_DgDx_op(int j) const
Create SG operator representing dg/dx.
Factory for generating stochastic Galerkin preconditioners.
Teuchos::RCP< Epetra_Vector > my_x
x pointer for evaluating preconditioner
Teuchos::RCP< Teuchos::ParameterList > params
Algorithmic parameters.
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Return array of parameter names.
Teuchos::RCP< EpetraExt::BlockVector > export_residual(const Epetra_Vector &f_overlapped) const
Export parallel residual vector.
Teuchos::RCP< EpetraExt::BlockVector > export_solution(const Epetra_Vector &x_overlapped) const
Export parallel solution vector.
Teuchos::RCP< Epetra_Operator > create_W() const
Create W = alpha*M + beta*J matrix.
const Epetra_CrsGraph & Graph() const
An abstract class to represent a generic stochastic Galerkin preconditioner as an Epetra_Operator...
Teuchos::Array< int > sg_p_index_map
Index map between block-p and p_sg maps.
Teuchos::Array< Teuchos::RCP< const Epetra_Map > > get_g_sg_base_maps() const
Get base maps of SG responses.
Teuchos::RCP< const Epetra_Map > f_map
Underlying residual map.
std::vector< T >::iterator iterator
Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > create_x_mv_sg_overlap(int num_vecs, Epetra_DataAccess CV=Copy, const Epetra_MultiVector *v=NULL) const
Create vector orthog poly using x map and overlap sg map.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > create_f_sg(Epetra_DataAccess CV=Copy, const Epetra_Vector *v=NULL) const
Create vector orthog poly using f map and owned sg map.
Teuchos::RCP< const Epetra_Vector > get_p_init(int l) const
Return initial parameters.
Teuchos::RCP< EpetraExt::ModelEvaluator::Preconditioner > create_WPrec() const
Create preconditioner operator.
Teuchos::RCP< Epetra_Operator > create_DfDp_op(int i) const
Create SG operator representing df/dp.
ScalarType g(const Teuchos::Array< ScalarType > &x, const ScalarType &y)
Teuchos::RCP< const Epetra_Map > sg_x_map
Block SG unknown map.
Teuchos::RCP< const EpetraExt::MultiComm > sg_comm
Parallel SG communicator.
A container class storing an orthogonal polynomial whose coefficients are vectors, operators, or in general any type that would have an expensive copy constructor.