41 (*p_names)[0] =
"alpha";
46 indices[0] = 0; indices[1] = 1;
75 "Error! SimpleME::get_p_map(): " <<
76 "Invalid parameter index l = " << l << std::endl);
87 "Error! SimpleME::get_p_names(): " <<
88 "Invalid parameter index l = " << l << std::endl);
105 "Error! SimpleME::get_p_init(): " <<
106 "Invalid parameter index l = " << l << std::endl);
121 EpetraExt::ModelEvaluator::InArgs
125 inArgs.setModelEvalDescription(
"Simple Model Evaluator");
128 inArgs.setSupports(IN_ARG_x,
true);
132 inArgs.setSupports(IN_ARG_x_sg,
true);
133 inArgs.setSupports(IN_ARG_p_sg, 0,
true);
134 inArgs.setSupports(IN_ARG_sg_basis,
true);
135 inArgs.setSupports(IN_ARG_sg_quadrature,
true);
136 inArgs.setSupports(IN_ARG_sg_expansion,
true);
141 EpetraExt::ModelEvaluator::OutArgs
144 OutArgsSetup outArgs;
145 outArgs.setModelEvalDescription(
"Simple Model Evaluator");
148 outArgs.set_Np_Ng(1, 0);
149 outArgs.setSupports(OUT_ARG_f,
true);
150 outArgs.setSupports(OUT_ARG_W,
true);
153 outArgs.setSupports(OUT_ARG_f_sg,
true);
154 outArgs.setSupports(OUT_ARG_W_sg,
true);
170 double x0 = (*x_overlapped)[0];
171 double x1 = (*x_overlapped)[1];
206 int indices[2] = { 0, 1 };
209 values[0] = -1.0; values[1] = 0.0;
213 values[0] = -1.0; values[1] = 2.0*x1;
224 inArgs.get_sg_basis();
226 inArgs.get_sg_expansion();
229 InArgs::sg_const_vector_t x_sg = inArgs.get_x_sg();
232 for (
int i=0; i<basis->size(); i++) {
234 x0_sg[i] = (*x_overlapped)[0];
235 x1_sg[i] = (*x_overlapped)[1];
240 InArgs::sg_const_vector_t p_sg = inArgs.get_p_sg(0);
243 for (
int i=0; i<basis->size(); i++) {
244 a_sg[i] = (*p_sg)[i][0];
251 OutArgs::sg_vector_t f_sg = outArgs.get_f_sg();
257 expn->times(tmp0_sg, a_sg, a_sg);
258 expn->minus(tmp1_sg, tmp0_sg, x0_sg);
259 for (
int i=0; i<basis->size(); i++)
260 (*f_sg)[i].ReplaceGlobalValues(1, &tmp1_sg[i], &row);
264 expn->times(tmp0_sg, x1_sg, x1_sg);
265 expn->minus(tmp1_sg, tmp0_sg, x0_sg);
266 for (
int i=0; i<basis->size(); i++)
267 (*f_sg)[i].ReplaceGlobalValues(1, &tmp1_sg[i], &row);
274 OutArgs::sg_operator_t W_sg = outArgs.get_W_sg();
276 for (
int i=0; i<basis->size(); i++) {
279 int indices[2] = { 0, 1 };
294 values[1] = 2.0*x1_sg[i];
Teuchos::RCP< const Epetra_Vector > get_x_init() const
Return initial solution.
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.
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.