This file is indexed.

/usr/include/trilinos/Rythmos_SingleResidualModelEvaluator.hpp is in libtrilinos-rythmos-dev 12.12.1-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
//@HEADER
// ***********************************************************************
//
//                           Rythmos Package
//                 Copyright (2006) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
// USA
// Questions? Contact Todd S. Coffey (tscoffe@sandia.gov)
//
// ***********************************************************************
//@HEADER


#ifndef RYTHMOS_SINGLE_RESIDUAL_MODEL_EVALUATOR_HPP
#define RYTHMOS_SINGLE_RESIDUAL_MODEL_EVALUATOR_HPP


#include "Rythmos_SingleResidualModelEvaluatorBase.hpp"
#include "Thyra_ModelEvaluatorDelegatorBase.hpp"
#include "Thyra_ModelEvaluatorHelpers.hpp"
#include "Thyra_VectorStdOps.hpp"
#include "Thyra_TestingTools.hpp"
#include "Teuchos_as.hpp"


namespace Rythmos {


/** \brief Decorator subclass for a steady-state version of a DAE for single-residual
 * time stepper methods.
 *
 * This class provides a set of nonlinear equations of the form:
 *
 \verbatim

 f_bar(x_bar) = f( coeff_x_dot * x_bar + x_dot_base, coeff_x * x_bar + x_base, t_base ) = 0
 \endverbatim
 *
 * with initial starting guess <tt>x_bar_init</tt>.
 *
 * The Jacobian of this model is:

 \verbatim

 beta * d(f_bar)/d(x_bar) = (beta*coeff_x_dot) * d(f)/d(x_dot) + (beta*coeff_x) * d(f)/d(x)
 \endverbatim
 *
 * ToDo: Finish Documentation!
 */
template<class Scalar>
class SingleResidualModelEvaluator
  : virtual public SingleResidualModelEvaluatorBase<Scalar>,
    virtual public Thyra::ModelEvaluatorDelegatorBase<Scalar>
{
public:

  /** \name Constructors/initializers/accessors */
  //@{

  /** \brief . */
  SingleResidualModelEvaluator();

  //@}

  /** \name Overridden from SingleResidualModelEvaluatorBase */
  //@{

  /** \brief . */
  void initializeSingleResidualModel(
    const RCP<const Thyra::ModelEvaluator<Scalar> > &daeModel,
    const Thyra::ModelEvaluatorBase::InArgs<Scalar> &basePoint,
    const Scalar &coeff_x_dot,
    const RCP<const Thyra::VectorBase<Scalar> > &x_dot_base,
    const Scalar &coeff_x,
    const RCP<const Thyra::VectorBase<Scalar> > &x_base,
    const Scalar &t_base,
    const RCP<const Thyra::VectorBase<Scalar> > &x_bar_init
    );

  /** \brief . */
  Scalar get_coeff_x_dot() const;

  /** \brief . */
  RCP<const Thyra::VectorBase<Scalar> >
  get_x_dot_base() const;

  /** \brief . */
  Scalar get_coeff_x() const;

  /** \brief . */
  RCP<const Thyra::VectorBase<Scalar> >
  get_x_base() const;

  /** \brief . */
  Scalar get_t_base() const;

  //@}

  /** \name Public functions overridden from ModelEvaluator */
  //@{

  /** \breif . */
  Thyra::ModelEvaluatorBase::InArgs<Scalar> getNominalValues() const;
  /** \brief . */
  Thyra::ModelEvaluatorBase::InArgs<Scalar> createInArgs() const;

  //@}

private:

  /** \name Private functions overridden from ModelEvaluatorDefaultBase */
  //@{

  /** \brief . */
  Thyra::ModelEvaluatorBase::OutArgs<Scalar> createOutArgsImpl() const;
  /** \brief . */
  void evalModelImpl(
    const Thyra::ModelEvaluatorBase::InArgs<Scalar>& inArgs,
    const Thyra::ModelEvaluatorBase::OutArgs<Scalar>& outArgs
    ) const;

  //@}


private:

  Thyra::ModelEvaluatorBase::InArgs<Scalar> basePoint_;
  Scalar coeff_x_dot_;
  RCP<const Thyra::VectorBase<Scalar> > x_dot_base_;
  Scalar coeff_x_;
  RCP<const Thyra::VectorBase<Scalar> > x_base_;
  Scalar t_base_;

  Thyra::ModelEvaluatorBase::InArgs<Scalar> nominalValues_;

  // cache
  RCP<Thyra::VectorBase<Scalar> > x_;
  RCP<Thyra::VectorBase<Scalar> > x_dot_;

};


// ///////////////////////
// Definition


// Constructors/initializers/accessors


template<class Scalar>
SingleResidualModelEvaluator<Scalar>::SingleResidualModelEvaluator()
{}


// Overridden from SingleResidualModelEvaluatorBase


template<class Scalar>
void SingleResidualModelEvaluator<Scalar>::initializeSingleResidualModel(
  const RCP<const Thyra::ModelEvaluator<Scalar> > &daeModel,
  const Thyra::ModelEvaluatorBase::InArgs<Scalar> &basePoint,
  const Scalar &coeff_x_dot,
  const RCP<const Thyra::VectorBase<Scalar> > &x_dot_base,
  const Scalar &coeff_x,
  const RCP<const Thyra::VectorBase<Scalar> > &x_base,
  const Scalar &t_base,
  const RCP<const Thyra::VectorBase<Scalar> > &x_bar_init
  )
{
  this->Thyra::ModelEvaluatorDelegatorBase<Scalar>::initialize(daeModel);
  basePoint_ = basePoint;
  coeff_x_dot_ = coeff_x_dot;
  x_dot_base_ = x_dot_base;
  coeff_x_ = coeff_x;
  x_base_ = x_base;
  t_base_ = t_base;

  nominalValues_ = daeModel->getNominalValues();
  nominalValues_.set_x(x_bar_init);

  x_dot_ = createMember( daeModel->get_x_space() );
  x_ = createMember( daeModel->get_x_space() );

  // ToDo: Check that daeModel supports x_dot, x and maybe t

#ifdef THYRA_RYTHMOS_DEBUG
  std::cout << "----------------------------------------------------------------------" << std::endl;
  std::cout << "Rythmos::SingleResidualModelEvaluator::initialize" << std::endl;
  std::cout << "coeff_x_dot_ = " << coeff_x_dot_ << std::endl;
  std::cout << "x_dot_base_ = ";                  
  if ( x_dot_base_.get() ) 
    std::cout << "\n" << *x_dot_base_            << std::endl;
  else
    std::cout << "null"                          << std::endl;
  std::cout << "coeff_x_ = " << coeff_x_         << std::endl;
  std::cout << "x_base_ = ";                      
  if ( x_base_.get() )
    std::cout << "\n" << *x_base_                << std::endl;
  else
    std::cout << "null"                          << std::endl;
  std::cout << "t_base_ = " << t_base_           << std::endl;
  std::cout << "x_bar_init = ";                  
  if ( x_bar_init.get() )
    std::cout << "\n" <<  *x_bar_init_           << std::endl;
  else
    std::cout << "null"                          << std::endl;
  std::cout << "x_dot_ = ";                       
  if ( x_dot_.get() )
    std::cout << "\n" << *x_dot_                 << std::endl;
  else
    std::cout << "null"                          << std::endl;
  std::cout << "x_ = ";                           
  if ( x_.get() )
    std::cout << "\n" << *x_                     << std::endl;
  else
    std::cout << "null"                          << std::endl;
  std::cout << "----------------------------------------------------------------------" << std::endl;
#endif // THYRA_RYTHMOS_DEBUG
}


template<class Scalar>
Scalar SingleResidualModelEvaluator<Scalar>::get_coeff_x_dot() const
{
  return coeff_x_dot_;
}


template<class Scalar>
RCP<const Thyra::VectorBase<Scalar> >
SingleResidualModelEvaluator<Scalar>::get_x_dot_base() const
{
  return x_dot_base_;
}


template<class Scalar>
Scalar SingleResidualModelEvaluator<Scalar>::get_coeff_x() const
{
  return coeff_x_;
}


template<class Scalar>
RCP<const Thyra::VectorBase<Scalar> >
SingleResidualModelEvaluator<Scalar>::get_x_base() const
{
  return x_base_;
}


template<class Scalar>
Scalar SingleResidualModelEvaluator<Scalar>::get_t_base() const
{
  return t_base_;
}


// Overridden from ModelEvaluator


template<class Scalar>
Thyra::ModelEvaluatorBase::InArgs<Scalar>
SingleResidualModelEvaluator<Scalar>::getNominalValues() const
{
  return nominalValues_;
}


template<class Scalar>
Thyra::ModelEvaluatorBase::InArgs<Scalar>
SingleResidualModelEvaluator<Scalar>::createInArgs() const
{
  typedef Thyra::ModelEvaluatorBase MEB;
  MEB::InArgsSetup<Scalar> inArgs;
  inArgs.setModelEvalDescription(this->description());
  inArgs.setSupports(MEB::IN_ARG_x);
  return inArgs;
}


// Private functions overridden from ModelEvaluatorDefaultBase


template<class Scalar>
Thyra::ModelEvaluatorBase::OutArgs<Scalar>
SingleResidualModelEvaluator<Scalar>::createOutArgsImpl() const
{
  typedef Thyra::ModelEvaluatorBase MEB;
  const RCP<const Thyra::ModelEvaluator<Scalar> >
    daeModel = this->getUnderlyingModel();
  MEB::OutArgs<Scalar> daeOutArgs = daeModel->createOutArgs();
  MEB::OutArgsSetup<Scalar> outArgs;
  outArgs.setModelEvalDescription(this->description());
  outArgs.setSupports(MEB::OUT_ARG_f);
  if (daeOutArgs.supports(MEB::OUT_ARG_W_op)) {
    outArgs.setSupports(MEB::OUT_ARG_W_op);
  }
  if (daeOutArgs.supports(MEB::OUT_ARG_W)) {
    outArgs.setSupports(MEB::OUT_ARG_W);
  }
  return outArgs;
}


template<class Scalar>
void SingleResidualModelEvaluator<Scalar>::evalModelImpl(
  const Thyra::ModelEvaluatorBase::InArgs<Scalar>& inArgs_bar,
  const Thyra::ModelEvaluatorBase::OutArgs<Scalar>& outArgs_bar
  ) const
{

  using std::endl;
  using Teuchos::as;
  typedef Thyra::ModelEvaluatorBase MEB;

  const RCP<const Thyra::ModelEvaluator<Scalar> >
    daeModel = this->getUnderlyingModel();

  THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_BEGIN(
    "Rythmos::SingleResidualModelEvaluator",inArgs_bar,outArgs_bar
    );

  const bool dumpAll = ( as<int>(verbLevel) >= as<int>(Teuchos::VERB_EXTREME) );

  const Thyra::VectorBase<Scalar> &x_bar = *inArgs_bar.get_x(); 

  // x_dot = coeff_x_dot * x_bar + x_dot_base

  if (x_dot_base_.get())
    Thyra::V_StVpV( x_dot_.ptr(), coeff_x_dot_, x_bar, *x_dot_base_ );
  else
    Thyra::V_StV( x_dot_.ptr(), coeff_x_dot_, x_bar);

  if (dumpAll) {
    *out << "\nx_dot_ = coeff_x_dot_ * x_bar + x_dot_base_\n";
    *out << "\ncoeff_x_dot_ = " << coeff_x_dot_ << endl;
    *out << "\nx_bar = " << x_bar;
    *out << "\nx_dot_base_ = ";
    if ( x_dot_base_.get() )
      *out << *x_dot_base_;
    else
      *out << "null" << endl;
    *out << "\nx_dot_ = ";
    if ( x_dot_.get() )
      *out << *x_dot_;
    else
      *out << "null" << endl;
  }

  // x = coeff_x * x_bar + x_base

  if (x_base_.get())
    Thyra::V_StVpV( x_.ptr(), coeff_x_, x_bar, *x_base_ );
  else
    Thyra::V_StV( x_.ptr(), coeff_x_, x_bar);

  if (dumpAll) {
    *out << "\nx_ = coeff_x_ * x_bar + x_base_\n";
    *out << "\ncoeff_x_ = " << coeff_x_ << endl;
    *out << "\nx_bar = " << x_bar;
    *out << "\nx_base_ = ";
    if ( x_base_.get() )
      *out << *x_base_;
    else
      *out << "null" << endl;
    *out << "\nx_ = ";
    if ( x_.get() )
      *out << *x_;
    else
      *out << "null" << endl;
  }

  // Compute W and f

  if (as<int>(verbLevel) >= as<int>(Teuchos::VERB_LOW))
    *out << "\nEvaluating the underlying DAE model at (x_bar_dot,x_bar,t) ...\n";

  RCP<Thyra::LinearOpWithSolveBase<Scalar> > W;

  MEB::InArgs<Scalar> daeInArgs = daeModel->createInArgs();
  daeInArgs.setArgs(basePoint_);
  daeInArgs.set_x_dot(x_dot_);
  daeInArgs.set_x(x_);
  daeInArgs.set_t(t_base_);
  daeInArgs.set_alpha(coeff_x_dot_);
  daeInArgs.set_beta(coeff_x_);
  MEB::OutArgs<Scalar> daeOutArgs = daeModel->createOutArgs();
  daeOutArgs.set_f(outArgs_bar.get_f()); // can be null
  if (daeOutArgs.supports(MEB::OUT_ARG_W)) {
    daeOutArgs.set_W(outArgs_bar.get_W()); // can be null
  }
  if (daeOutArgs.supports(MEB::OUT_ARG_W_op)) {
    daeOutArgs.set_W_op(outArgs_bar.get_W_op()); // can be null
  }
  daeModel->evalModel(daeInArgs,daeOutArgs);

  THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_END();

}


} // namespace Rythmos


#endif // RYTHMOS_SINGLE_RESIDUAL_MODEL_EVALUATOR_HPP