18 template <
typename ScalarA,
typename ScalarX>
19 void func(
const ScalarA& a,
const ScalarX x[2], ScalarX y[2]) {
21 y[1] = x[1]*x[1] - x[0];
53 (*p_names)[0] =
"alpha";
58 indices[0] = 0; indices[1] = 1;
87 "Error! SimpleME::get_p_map(): " <<
88 "Invalid parameter index l = " << l << std::endl);
99 "Error! SimpleME::get_p_names(): " <<
100 "Invalid parameter index l = " << l << std::endl);
117 "Error! SimpleME::get_p_init(): " <<
118 "Invalid parameter index l = " << l << std::endl);
133 EpetraExt::ModelEvaluator::InArgs
137 inArgs.setModelEvalDescription(
"Simple Model Evaluator");
140 inArgs.setSupports(IN_ARG_x,
true);
144 inArgs.setSupports(IN_ARG_x_sg,
true);
145 inArgs.setSupports(IN_ARG_p_sg, 0,
true);
146 inArgs.setSupports(IN_ARG_sg_basis,
true);
147 inArgs.setSupports(IN_ARG_sg_quadrature,
true);
148 inArgs.setSupports(IN_ARG_sg_expansion,
true);
153 EpetraExt::ModelEvaluator::OutArgs
156 OutArgsSetup outArgs;
157 outArgs.setModelEvalDescription(
"Simple Model Evaluator");
160 outArgs.set_Np_Ng(1, 0);
161 outArgs.setSupports(OUT_ARG_f,
true);
162 outArgs.setSupports(OUT_ARG_W,
true);
165 outArgs.setSupports(OUT_ARG_f_sg,
true);
166 outArgs.setSupports(OUT_ARG_W_sg,
true);
182 double x0 = (*x_overlapped)[0];
183 double x1 = (*x_overlapped)[1];
197 double x[2] = { x0, x1 };
216 typedef Sacado::Fad::SFad<double,2>
fad_type;
224 int indices[2] = { 0, 1 };
241 InArgs::sg_const_vector_t x_sg = inArgs.get_x_sg();
246 inArgs.get_sg_basis();
248 inArgs.get_sg_expansion();
252 pce_type x0(expn), x1(expn);
253 for (
int i=0; i<basis->size(); i++) {
255 x0.fastAccessCoeff(i) = (*x_overlapped)[0];
256 x1.fastAccessCoeff(i) = (*x_overlapped)[1];
260 InArgs::sg_const_vector_t p_sg = inArgs.get_p_sg(0);
263 for (
int i=0; i<basis->size(); i++) {
264 a.fastAccessCoeff(i) = (*p_sg)[i][0];
271 OutArgs::sg_vector_t f_sg = outArgs.get_f_sg();
273 pce_type x[2] = { x0, x1 };
279 for (
int i=0; i<basis->size(); i++) {
280 double c = y[0].coeff(i);
281 (*f_sg)[i].ReplaceGlobalValues(1, &c, &row);
286 for (
int i=0; i<basis->size(); i++) {
287 double c = y[1].coeff(i);
288 (*f_sg)[i].ReplaceGlobalValues(1, &c, &row);
296 OutArgs::sg_operator_t W_sg = outArgs.get_W_sg();
298 typedef Sacado::Fad::SFad<pce_type,2>
fad_type;
304 for (
int i=0; i<basis->size(); i++) {
308 int indices[2] = { 0, 1 };
311 double values[2] = { y[0].dx(0).coeff(i), y[0].dx(1).coeff(i) };
316 double values[2] = { y[1].dx(0).coeff(i), y[1].dx(1).coeff(i) };
Teuchos::RCP< const Epetra_Vector > get_x_init() const
Return initial solution.
Stokhos::StandardStorage< int, double > storage_type
Sacado::ETPCE::OrthogPoly< double, Stokhos::StandardStorage< int, double > > pce_type
Teuchos::RCP< Epetra_Vector > x_init
Initial guess.
Teuchos::RCP< const Epetra_Map > get_f_map() const
Return residual vector map.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
SimpleME(const Teuchos::RCP< const Epetra_Comm > &comm)
Constructor.
Teuchos::RCP< const Epetra_Map > get_x_map() const
Return solution vector map.
Teuchos::RCP< Epetra_Vector > p_init
Initial parameters.
InArgs createInArgs() const
Create InArgs.
Teuchos::RCP< Epetra_Vector > x_overlapped
Overlapped solution vector.
Teuchos::RCP< Epetra_Map > x_map
Solution vector map.
int InsertGlobalIndices(int_type GlobalRow, int NumIndices, int_type *Indices)
int FillComplete(bool OptimizeDataStorage=true)
int ReplaceGlobalValues(int NumEntries, const double *Values, const int *Indices)
void evalModel(const InArgs &inArgs, const OutArgs &outArgs) const
Evaluate model on InArgs.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< Epetra_Map > p_map
Parameter vector map.
bool MyGID(int GID_in) const
Teuchos::RCP< Teuchos::Array< std::string > > p_names
Parameter names.
Teuchos::RCP< Epetra_CrsGraph > graph
Jacobian graph.
ScalarType f(const Teuchos::Array< ScalarType > &x, double a, double b)
Teuchos::RCP< const Epetra_Map > get_p_map(int l) const
Return parameter vector map.
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Return array of parameter names.
Teuchos::RCP< Epetra_Import > importer
Importer to overlapped distribution.
virtual int ReplaceGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
OutArgs createOutArgs() const
Create OutArgs.
Sacado::Fad::DFad< double > fad_type
Teuchos::RCP< Epetra_Operator > create_W() const
Create W = alpha*M + beta*J matrix.
Teuchos::RCP< Epetra_Map > x_overlapped_map
Overlapped solution vector map.
Teuchos::RCP< const Epetra_Vector > get_p_init(int l) const
Return initial parameters.