50 template <
typename ScalarA,
typename ScalarX>
51 void func(
const ScalarA& a,
const ScalarX x[2], ScalarX y[2]) {
53 y[1] = x[1]*x[1] - x[0];
85 (*p_names)[0] =
"alpha";
90 indices[0] = 0; indices[1] = 1;
119 "Error! SimpleME::get_p_map(): " <<
120 "Invalid parameter index l = " << l << std::endl);
131 "Error! SimpleME::get_p_names(): " <<
132 "Invalid parameter index l = " << l << std::endl);
149 "Error! SimpleME::get_p_init(): " <<
150 "Invalid parameter index l = " << l << std::endl);
165 EpetraExt::ModelEvaluator::InArgs
169 inArgs.setModelEvalDescription(
"Simple Model Evaluator");
172 inArgs.setSupports(IN_ARG_x,
true);
176 inArgs.setSupports(IN_ARG_x_sg,
true);
177 inArgs.setSupports(IN_ARG_p_sg, 0,
true);
178 inArgs.setSupports(IN_ARG_sg_basis,
true);
179 inArgs.setSupports(IN_ARG_sg_quadrature,
true);
180 inArgs.setSupports(IN_ARG_sg_expansion,
true);
185 EpetraExt::ModelEvaluator::OutArgs
188 OutArgsSetup outArgs;
189 outArgs.setModelEvalDescription(
"Simple Model Evaluator");
192 outArgs.set_Np_Ng(1, 0);
193 outArgs.setSupports(OUT_ARG_f,
true);
194 outArgs.setSupports(OUT_ARG_W,
true);
197 outArgs.setSupports(OUT_ARG_f_sg,
true);
198 outArgs.setSupports(OUT_ARG_W_sg,
true);
214 double x0 = (*x_overlapped)[0];
215 double x1 = (*x_overlapped)[1];
229 double x[2] = { x0, x1 };
248 typedef Sacado::Fad::SFad<double,2>
fad_type;
256 int indices[2] = { 0, 1 };
273 InArgs::sg_const_vector_t x_sg = inArgs.get_x_sg();
278 inArgs.get_sg_basis();
280 inArgs.get_sg_expansion();
284 pce_type x0(expn), x1(expn);
285 for (
int i=0; i<basis->size(); i++) {
287 x0.fastAccessCoeff(i) = (*x_overlapped)[0];
288 x1.fastAccessCoeff(i) = (*x_overlapped)[1];
292 InArgs::sg_const_vector_t p_sg = inArgs.get_p_sg(0);
295 for (
int i=0; i<basis->size(); i++) {
296 a.fastAccessCoeff(i) = (*p_sg)[i][0];
303 OutArgs::sg_vector_t f_sg = outArgs.get_f_sg();
305 pce_type x[2] = { x0, x1 };
311 for (
int i=0; i<basis->size(); i++) {
312 double c = y[0].coeff(i);
313 (*f_sg)[i].ReplaceGlobalValues(1, &c, &row);
318 for (
int i=0; i<basis->size(); i++) {
319 double c = y[1].coeff(i);
320 (*f_sg)[i].ReplaceGlobalValues(1, &c, &row);
328 OutArgs::sg_operator_t W_sg = outArgs.get_W_sg();
330 typedef Sacado::Fad::SFad<pce_type,2>
fad_type;
336 for (
int i=0; i<basis->size(); i++) {
340 int indices[2] = { 0, 1 };
343 double values[2] = { y[0].dx(0).coeff(i), y[0].dx(1).coeff(i) };
348 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.