62 return me->get_x_map();
69 return me->get_f_map();
76 return me->get_p_map(l);
83 return me->get_g_map(l);
90 return me->get_p_names(l);
97 return me->get_x_init();
104 return me->get_p_init(l);
111 return me->create_W();
114 EpetraExt::ModelEvaluator::InArgs
119 InArgs me_inargs = me->createInArgs();
121 inArgs.setModelEvalDescription(this->description());
122 inArgs.set_Np(me_inargs.Np());
123 inArgs.setSupports(IN_ARG_x_dot, me_inargs.supports(IN_ARG_x_dot));
124 inArgs.setSupports(IN_ARG_x, me_inargs.supports(IN_ARG_x));
125 inArgs.setSupports(IN_ARG_t, me_inargs.supports(IN_ARG_t));
126 inArgs.setSupports(IN_ARG_alpha, me_inargs.supports(IN_ARG_alpha));
127 inArgs.setSupports(IN_ARG_beta, me_inargs.supports(IN_ARG_beta));
129 for (
int i=0; i<me_inargs.Np(); i++)
130 inArgs.setSupports(IN_ARG_p_mp, i,
true);
131 inArgs.setSupports(IN_ARG_x_mp, me_inargs.supports(IN_ARG_x));
132 inArgs.setSupports(IN_ARG_x_dot_mp, me_inargs.supports(IN_ARG_x_dot));
137 EpetraExt::ModelEvaluator::OutArgs
141 OutArgsSetup outArgs;
142 OutArgs me_outargs = me->createOutArgs();
144 outArgs.setModelEvalDescription(this->description());
145 outArgs.set_Np_Ng(me_outargs.Np(), me_outargs.Ng());
146 outArgs.setSupports(OUT_ARG_f, me_outargs.supports(OUT_ARG_f));
147 outArgs.setSupports(OUT_ARG_W, me_outargs.supports(OUT_ARG_W));
148 for (
int j=0;
j<me_outargs.Np();
j++)
149 outArgs.setSupports(OUT_ARG_DfDp,
j,
150 me_outargs.supports(OUT_ARG_DfDp,
j));
151 for (
int i=0; i<me_outargs.Ng(); i++) {
152 outArgs.setSupports(OUT_ARG_DgDx, i,
153 me_outargs.supports(OUT_ARG_DgDx, i));
154 outArgs.setSupports(OUT_ARG_DgDx_dot, i,
155 me_outargs.supports(OUT_ARG_DgDx_dot, i));
156 for (
int j=0;
j<me_outargs.Np();
j++)
157 outArgs.setSupports(OUT_ARG_DgDp, i,
j,
158 me_outargs.supports(OUT_ARG_DgDp, i,
j));
161 outArgs.setSupports(OUT_ARG_f_mp, me_outargs.supports(OUT_ARG_f));
162 if (me_outargs.supports(OUT_ARG_W)) {
163 outArgs.set_W_properties(me_outargs.get_W_properties());
164 outArgs.setSupports(OUT_ARG_W_mp,
true);
166 for (
int j=0;
j<me_outargs.Np();
j++)
167 outArgs.setSupports(OUT_ARG_DfDp_mp,
j,
168 me_outargs.supports(OUT_ARG_DfDp,
j));
169 for (
int i=0; i<me_outargs.Ng(); i++) {
170 outArgs.setSupports(OUT_ARG_g_mp, i,
true);
171 outArgs.setSupports(OUT_ARG_DgDx_mp, i,
172 me_outargs.supports(OUT_ARG_DgDx, i));
173 outArgs.setSupports(OUT_ARG_DgDx_dot_mp, i,
174 me_outargs.supports(OUT_ARG_DgDx_dot, i));
175 for (
int j=0;
j<me_outargs.Np();
j++)
176 outArgs.setSupports(OUT_ARG_DgDp_mp, i,
j,
177 me_outargs.supports(OUT_ARG_DgDp, i,
j));
185 evalModel(
const InArgs& inArgs,
const OutArgs& outArgs)
const
188 InArgs me_inargs = me->createInArgs();
189 if (me_inargs.supports(IN_ARG_x))
190 me_inargs.set_x(inArgs.get_x());
191 if (me_inargs.supports(IN_ARG_x_dot))
192 me_inargs.set_x_dot(inArgs.get_x_dot());
193 if (me_inargs.supports(IN_ARG_alpha))
194 me_inargs.set_alpha(inArgs.get_alpha());
195 if (me_inargs.supports(IN_ARG_beta))
196 me_inargs.set_beta(inArgs.get_beta());
197 if (me_inargs.supports(IN_ARG_t))
198 me_inargs.set_t(inArgs.get_t());
199 for (
int i=0; i<inArgs.Np(); i++)
200 me_inargs.set_p(i, inArgs.get_p(i));
203 OutArgs me_outargs = me->createOutArgs();
204 if (me_outargs.supports(OUT_ARG_f))
205 me_outargs.set_f(outArgs.get_f());
206 if (me_outargs.supports(OUT_ARG_W))
207 me_outargs.set_W(outArgs.get_W());
208 for (
int j=0;
j<outArgs.Np();
j++)
209 if (!outArgs.supports(OUT_ARG_DfDp,
j).none())
210 me_outargs.set_DfDp(
j, outArgs.get_DfDp(
j));
211 for (
int i=0; i<outArgs.Ng(); i++) {
212 me_outargs.set_g(i, outArgs.get_g(i));
213 if (!outArgs.supports(OUT_ARG_DgDx, i).none())
214 me_outargs.set_DgDx(i, outArgs.get_DgDx(i));
215 if (!outArgs.supports(OUT_ARG_DgDx_dot, i).none())
216 me_outargs.set_DgDx(i, outArgs.get_DgDx_dot(i));
217 for (
int j=0;
j<outArgs.Np();
j++)
218 if (!outArgs.supports(OUT_ARG_DgDp, i,
j).none())
219 me_outargs.set_DgDp(i,
j, outArgs.get_DgDp(i,
j));
222 mp_const_vector_t x_mp;
223 mp_const_vector_t x_dot_mp;
234 if (inArgs.supports(IN_ARG_x_mp)) {
235 x_mp = inArgs.get_x_mp();
237 num_mp = x_mp->
size();
240 if (inArgs.supports(IN_ARG_x_dot_mp)) {
241 x_dot_mp = inArgs.get_x_dot_mp();
243 num_mp = x_dot_mp->
size();
246 for (
int i=0; i<inArgs.Np(); i++) {
247 p_mp[i] = inArgs.get_p_mp(i);
249 num_mp = p_mp[i]->
size();
252 if (outArgs.supports(OUT_ARG_f_mp)) {
253 f_mp = outArgs.get_f_mp();
257 if (outArgs.supports(OUT_ARG_W_mp)) {
258 W_mp = outArgs.get_W_mp();
262 for (
int i=0; i<inArgs.Np(); i++) {
263 if (!outArgs.supports(OUT_ARG_DfDp_mp, i).none()) {
264 dfdp_mp[i] = outArgs.get_DfDp_mp(i);
266 dfdp_mp[i].getMultiVector()->init(0.0);
268 dfdp_mp[i].getLinearOp()->init(0.0);
272 for (
int i=0; i<outArgs.Ng(); i++) {
273 g_mp[i] = outArgs.get_g_mp(i);
277 if (!outArgs.supports(OUT_ARG_DgDx_mp, i).none()) {
278 dgdx_mp[i] = outArgs.get_DgDx_mp(i);
280 dgdx_mp[i].getMultiVector()->init(0.0);
282 dgdx_mp[i].getLinearOp()->init(0.0);
285 if (!outArgs.supports(OUT_ARG_DgDx_dot_mp, i).none()) {
286 dgdx_dot_mp[i] = outArgs.get_DgDx_dot_mp(i);
288 dgdx_dot_mp[i].getMultiVector()->init(0.0);
290 dgdx_dot_mp[i].getLinearOp()->init(0.0);
293 dgdp_mp[i].
resize(outArgs.Np());
294 for (
int j=0;
j<outArgs.Np();
j++) {
295 if (!outArgs.supports(OUT_ARG_DgDp_mp, i,
j).none()) {
296 dgdp_mp[i][
j] = outArgs.get_DgDp_mp(i,
j);
298 dgdp_mp[i][
j].getMultiVector()->init(0.0);
300 dgdp_mp[i][
j].getLinearOp()->init(0.0);
305 for (
int qp=0; qp<num_mp; qp++) {
309 me_inargs.set_x(x_mp->getCoeffPtr(qp));
311 me_inargs.set_x_dot(x_dot_mp->getCoeffPtr(qp));
312 for (
int i=0; i<inArgs.Np(); i++)
314 me_inargs.set_p(i, p_mp[i]->getCoeffPtr(qp));
318 me_outargs.set_f(f_mp->getCoeffPtr(qp));
320 me_outargs.set_W(W_mp->getCoeffPtr(qp));
322 for (
int i=0; i<inArgs.Np(); i++) {
323 if (!dfdp_mp[i].isEmpty()) {
325 Derivative deriv(dfdp_mp[i].getMultiVector()->getCoeffPtr(qp),
326 dfdp_mp[i].getMultiVectorOrientation());
327 me_outargs.set_DfDp(i, deriv);
330 Derivative deriv(dfdp_mp[i].getLinearOp()->getCoeffPtr(qp));
331 me_outargs.set_DfDp(i, deriv);
336 for (
int i=0; i<outArgs.Ng(); i++) {
338 me_outargs.set_g(i, g_mp[i]->getCoeffPtr(qp));
339 if (!dgdx_dot_mp[i].isEmpty()) {
341 Derivative deriv(dgdx_dot_mp[i].getMultiVector()->getCoeffPtr(qp),
342 dgdx_dot_mp[i].getMultiVectorOrientation());
343 me_outargs.set_DgDx_dot(i, deriv);
346 Derivative deriv(dgdx_dot_mp[i].getLinearOp()->getCoeffPtr(qp));
347 me_outargs.set_DgDx_dot(i, deriv);
350 if (!dgdx_mp[i].isEmpty()) {
352 Derivative deriv(dgdx_mp[i].getMultiVector()->getCoeffPtr(qp),
353 dgdx_mp[i].getMultiVectorOrientation());
354 me_outargs.set_DgDx(i, deriv);
357 Derivative deriv(dgdx_mp[i].getLinearOp()->getCoeffPtr(qp));
358 me_outargs.set_DgDx(i, deriv);
361 for (
int j=0;
j<outArgs.Np();
j++) {
362 if (!dgdp_mp[i][
j].isEmpty()) {
364 Derivative deriv(dgdp_mp[i][
j].getMultiVector()->getCoeffPtr(qp),
365 dgdp_mp[i][
j].getMultiVectorOrientation());
366 me_outargs.set_DgDp(i,
j, deriv);
369 Derivative deriv(dgdp_mp[i][
j].getLinearOp()->getCoeffPtr(qp));
370 me_outargs.set_DgDp(i,
j, deriv);
377 me->evalModel(me_inargs, me_outargs);
383 me->evalModel(me_inargs, me_outargs);
Teuchos::RCP< const Epetra_Map > get_g_map(int l) const
Return observation vector map.
MPModelEvaluatorAdapter(const Teuchos::RCP< EpetraExt::ModelEvaluator > &me)
Teuchos::RCP< const Epetra_Map > get_f_map() const
Return residual vector map.
void evalModel(const InArgs &inArgs, const OutArgs &outArgs) const
Evaluate model on InArgs.
Teuchos::RCP< const Epetra_Vector > get_x_init() const
Return initial solution.
Teuchos::RCP< const Epetra_Map > get_x_map() const
Return solution vector map.
Teuchos::RCP< const Epetra_Map > get_p_map(int l) const
Return parameter vector map.
void resize(size_type new_size, const value_type &x=value_type())
Teuchos::RCP< const Epetra_Vector > get_p_init(int l) const
Return initial parameters.
InArgs createInArgs() const
Create InArgs.
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Return array of parameter names.
Teuchos::RCP< Epetra_Operator > create_W() const
Create W = alpha*M + beta*J matrix.
OutArgs createOutArgs() const
Create OutArgs.