30 return me->get_x_map();
37 return me->get_f_map();
44 return me->get_p_map(l);
51 return me->get_g_map(l);
58 return me->get_p_names(l);
65 return me->get_x_init();
72 return me->get_p_init(l);
79 return me->create_W();
82 EpetraExt::ModelEvaluator::InArgs
87 InArgs me_inargs = me->createInArgs();
89 inArgs.setModelEvalDescription(this->description());
90 inArgs.set_Np(me_inargs.Np());
91 inArgs.setSupports(IN_ARG_x_dot, me_inargs.supports(IN_ARG_x_dot));
92 inArgs.setSupports(IN_ARG_x, me_inargs.supports(IN_ARG_x));
93 inArgs.setSupports(IN_ARG_t, me_inargs.supports(IN_ARG_t));
94 inArgs.setSupports(IN_ARG_alpha, me_inargs.supports(IN_ARG_alpha));
95 inArgs.setSupports(IN_ARG_beta, me_inargs.supports(IN_ARG_beta));
97 for (
int i=0; i<me_inargs.Np(); i++)
98 inArgs.setSupports(IN_ARG_p_mp, i,
true);
99 inArgs.setSupports(IN_ARG_x_mp, me_inargs.supports(IN_ARG_x));
100 inArgs.setSupports(IN_ARG_x_dot_mp, me_inargs.supports(IN_ARG_x_dot));
105 EpetraExt::ModelEvaluator::OutArgs
109 OutArgsSetup outArgs;
110 OutArgs me_outargs = me->createOutArgs();
112 outArgs.setModelEvalDescription(this->description());
113 outArgs.set_Np_Ng(me_outargs.Np(), me_outargs.Ng());
114 outArgs.setSupports(OUT_ARG_f, me_outargs.supports(OUT_ARG_f));
115 outArgs.setSupports(OUT_ARG_W, me_outargs.supports(OUT_ARG_W));
116 for (
int j=0;
j<me_outargs.Np();
j++)
117 outArgs.setSupports(OUT_ARG_DfDp,
j,
118 me_outargs.supports(OUT_ARG_DfDp,
j));
119 for (
int i=0; i<me_outargs.Ng(); i++) {
120 outArgs.setSupports(OUT_ARG_DgDx, i,
121 me_outargs.supports(OUT_ARG_DgDx, i));
122 outArgs.setSupports(OUT_ARG_DgDx_dot, i,
123 me_outargs.supports(OUT_ARG_DgDx_dot, i));
124 for (
int j=0;
j<me_outargs.Np();
j++)
125 outArgs.setSupports(OUT_ARG_DgDp, i,
j,
126 me_outargs.supports(OUT_ARG_DgDp, i,
j));
129 outArgs.setSupports(OUT_ARG_f_mp, me_outargs.supports(OUT_ARG_f));
130 if (me_outargs.supports(OUT_ARG_W)) {
131 outArgs.set_W_properties(me_outargs.get_W_properties());
132 outArgs.setSupports(OUT_ARG_W_mp,
true);
134 for (
int j=0;
j<me_outargs.Np();
j++)
135 outArgs.setSupports(OUT_ARG_DfDp_mp,
j,
136 me_outargs.supports(OUT_ARG_DfDp,
j));
137 for (
int i=0; i<me_outargs.Ng(); i++) {
138 outArgs.setSupports(OUT_ARG_g_mp, i,
true);
139 outArgs.setSupports(OUT_ARG_DgDx_mp, i,
140 me_outargs.supports(OUT_ARG_DgDx, i));
141 outArgs.setSupports(OUT_ARG_DgDx_dot_mp, i,
142 me_outargs.supports(OUT_ARG_DgDx_dot, i));
143 for (
int j=0;
j<me_outargs.Np();
j++)
144 outArgs.setSupports(OUT_ARG_DgDp_mp, i,
j,
145 me_outargs.supports(OUT_ARG_DgDp, i,
j));
153 evalModel(
const InArgs& inArgs,
const OutArgs& outArgs)
const
156 InArgs me_inargs = me->createInArgs();
157 if (me_inargs.supports(IN_ARG_x))
158 me_inargs.set_x(inArgs.get_x());
159 if (me_inargs.supports(IN_ARG_x_dot))
160 me_inargs.set_x_dot(inArgs.get_x_dot());
161 if (me_inargs.supports(IN_ARG_alpha))
162 me_inargs.set_alpha(inArgs.get_alpha());
163 if (me_inargs.supports(IN_ARG_beta))
164 me_inargs.set_beta(inArgs.get_beta());
165 if (me_inargs.supports(IN_ARG_t))
166 me_inargs.set_t(inArgs.get_t());
167 for (
int i=0; i<inArgs.Np(); i++)
168 me_inargs.set_p(i, inArgs.get_p(i));
171 OutArgs me_outargs = me->createOutArgs();
172 if (me_outargs.supports(OUT_ARG_f))
173 me_outargs.set_f(outArgs.get_f());
174 if (me_outargs.supports(OUT_ARG_W))
175 me_outargs.set_W(outArgs.get_W());
176 for (
int j=0;
j<outArgs.Np();
j++)
177 if (!outArgs.supports(OUT_ARG_DfDp,
j).none())
178 me_outargs.set_DfDp(
j, outArgs.get_DfDp(
j));
179 for (
int i=0; i<outArgs.Ng(); i++) {
180 me_outargs.set_g(i, outArgs.get_g(i));
181 if (!outArgs.supports(OUT_ARG_DgDx, i).none())
182 me_outargs.set_DgDx(i, outArgs.get_DgDx(i));
183 if (!outArgs.supports(OUT_ARG_DgDx_dot, i).none())
184 me_outargs.set_DgDx(i, outArgs.get_DgDx_dot(i));
185 for (
int j=0;
j<outArgs.Np();
j++)
186 if (!outArgs.supports(OUT_ARG_DgDp, i,
j).none())
187 me_outargs.set_DgDp(i,
j, outArgs.get_DgDp(i,
j));
190 mp_const_vector_t x_mp;
191 mp_const_vector_t x_dot_mp;
202 if (inArgs.supports(IN_ARG_x_mp)) {
203 x_mp = inArgs.get_x_mp();
205 num_mp = x_mp->
size();
208 if (inArgs.supports(IN_ARG_x_dot_mp)) {
209 x_dot_mp = inArgs.get_x_dot_mp();
211 num_mp = x_dot_mp->
size();
214 for (
int i=0; i<inArgs.Np(); i++) {
215 p_mp[i] = inArgs.get_p_mp(i);
217 num_mp = p_mp[i]->
size();
220 if (outArgs.supports(OUT_ARG_f_mp)) {
221 f_mp = outArgs.get_f_mp();
225 if (outArgs.supports(OUT_ARG_W_mp)) {
226 W_mp = outArgs.get_W_mp();
230 for (
int i=0; i<inArgs.Np(); i++) {
231 if (!outArgs.supports(OUT_ARG_DfDp_mp, i).none()) {
232 dfdp_mp[i] = outArgs.get_DfDp_mp(i);
234 dfdp_mp[i].getMultiVector()->init(0.0);
236 dfdp_mp[i].getLinearOp()->init(0.0);
240 for (
int i=0; i<outArgs.Ng(); i++) {
241 g_mp[i] = outArgs.get_g_mp(i);
245 if (!outArgs.supports(OUT_ARG_DgDx_mp, i).none()) {
246 dgdx_mp[i] = outArgs.get_DgDx_mp(i);
248 dgdx_mp[i].getMultiVector()->init(0.0);
250 dgdx_mp[i].getLinearOp()->init(0.0);
253 if (!outArgs.supports(OUT_ARG_DgDx_dot_mp, i).none()) {
254 dgdx_dot_mp[i] = outArgs.get_DgDx_dot_mp(i);
256 dgdx_dot_mp[i].getMultiVector()->init(0.0);
258 dgdx_dot_mp[i].getLinearOp()->init(0.0);
261 dgdp_mp[i].
resize(outArgs.Np());
262 for (
int j=0;
j<outArgs.Np();
j++) {
263 if (!outArgs.supports(OUT_ARG_DgDp_mp, i,
j).none()) {
264 dgdp_mp[i][
j] = outArgs.get_DgDp_mp(i,
j);
266 dgdp_mp[i][
j].getMultiVector()->init(0.0);
268 dgdp_mp[i][
j].getLinearOp()->init(0.0);
273 for (
int qp=0; qp<num_mp; qp++) {
277 me_inargs.set_x(x_mp->getCoeffPtr(qp));
279 me_inargs.set_x_dot(x_dot_mp->getCoeffPtr(qp));
280 for (
int i=0; i<inArgs.Np(); i++)
282 me_inargs.set_p(i, p_mp[i]->getCoeffPtr(qp));
286 me_outargs.set_f(f_mp->getCoeffPtr(qp));
288 me_outargs.set_W(W_mp->getCoeffPtr(qp));
290 for (
int i=0; i<inArgs.Np(); i++) {
291 if (!dfdp_mp[i].isEmpty()) {
293 Derivative deriv(dfdp_mp[i].getMultiVector()->getCoeffPtr(qp),
294 dfdp_mp[i].getMultiVectorOrientation());
295 me_outargs.set_DfDp(i, deriv);
298 Derivative deriv(dfdp_mp[i].getLinearOp()->getCoeffPtr(qp));
299 me_outargs.set_DfDp(i, deriv);
304 for (
int i=0; i<outArgs.Ng(); i++) {
306 me_outargs.set_g(i, g_mp[i]->getCoeffPtr(qp));
307 if (!dgdx_dot_mp[i].isEmpty()) {
309 Derivative deriv(dgdx_dot_mp[i].getMultiVector()->getCoeffPtr(qp),
310 dgdx_dot_mp[i].getMultiVectorOrientation());
311 me_outargs.set_DgDx_dot(i, deriv);
314 Derivative deriv(dgdx_dot_mp[i].getLinearOp()->getCoeffPtr(qp));
315 me_outargs.set_DgDx_dot(i, deriv);
318 if (!dgdx_mp[i].isEmpty()) {
320 Derivative deriv(dgdx_mp[i].getMultiVector()->getCoeffPtr(qp),
321 dgdx_mp[i].getMultiVectorOrientation());
322 me_outargs.set_DgDx(i, deriv);
325 Derivative deriv(dgdx_mp[i].getLinearOp()->getCoeffPtr(qp));
326 me_outargs.set_DgDx(i, deriv);
329 for (
int j=0;
j<outArgs.Np();
j++) {
330 if (!dgdp_mp[i][
j].isEmpty()) {
332 Derivative deriv(dgdp_mp[i][
j].getMultiVector()->getCoeffPtr(qp),
333 dgdp_mp[i][
j].getMultiVectorOrientation());
334 me_outargs.set_DgDp(i,
j, deriv);
337 Derivative deriv(dgdp_mp[i][
j].getLinearOp()->getCoeffPtr(qp));
338 me_outargs.set_DgDp(i,
j, deriv);
345 me->evalModel(me_inargs, me_outargs);
351 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.