This file is indexed.

/usr/include/trilinos/Thyra_DefaultNominalBoundsOverrideModelEvaluator.hpp is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.

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
// @HEADER
// ***********************************************************************
// 
//    Thyra: Interfaces and Support for Abstract Numerical Algorithms
//                 Copyright (2004) 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
// Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
// 
// ***********************************************************************
// @HEADER

#ifndef THYRA_DEFAULT_NOMINAL_BOUNDS_OVERRIDE_MODEL_EVALUATOR_HPP
#define THYRA_DEFAULT_NOMINAL_BOUNDS_OVERRIDE_MODEL_EVALUATOR_HPP


#include "Thyra_ModelEvaluatorDelegatorBase.hpp"
#include "Thyra_LinearOpWithSolveFactoryBase.hpp"
#include "Teuchos_Time.hpp"


namespace Thyra {


/** \brief This class wraps any ModelEvaluator object and allows the client to
 * overide the state contained in the nominal values and the upper and lower
 * bounds.
 *
 * To only override selected nominal values and bounds, do the following:
 *
 \code
 
   template<class Scalar>
   RCP<DefaultNominalBoundsOverrideModelEvaluator<Scalar> >
   override(
     const RCP<ModelEvaluator<Scalar> >   &thyraModel
     ...
     )
   {

     using Teuchos::rcp;
     typedef Thyra::ModelEvaluatorBase MEB;

     // Get the defaults
     RCP<MEB::InArgs<Scalar> >
       nominalValues = clone(thyraModel->getNominalValues()),
       lowerBounds = clone(thyraModel->getLowerBounds()),
       upperBounds = clone(thyraModel->getUpperBounds());

     // Override selected components ...
     ...

     // Initialize the overridden state
     RCP<DefaultNominalBoundsOverrideModelEvaluator<Scalar> >
       defaultOverridder = rcp(
         new DefaultNominalBoundsOverrideModelEvaluator<Scalar>(thyraModel));
     defaultOverridder->setNominalValues(nominalValues);
     defaultOverridder->setLowerBounds(lowerBounds);
     defaultOverridder->setUpperBounds(upperBounds);
     
     return defaultOverridder;

   }
 
 \endcode
 *
 * ToDo: Finish documentation!
 *
 * \ingroup Thyra_Nonlin_ME_support_grp
 */
template<class Scalar>
class DefaultNominalBoundsOverrideModelEvaluator
  : virtual public ModelEvaluatorDelegatorBase<Scalar>
{
public:

  /** \brief . */
  typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;

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

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

  /** \brief . */
  DefaultNominalBoundsOverrideModelEvaluator(
    const RCP<ModelEvaluator<Scalar> > &thyraModel,
    const RCP<const ModelEvaluatorBase::InArgs<Scalar> > &nominalValues,
    const RCP<const ModelEvaluatorBase::InArgs<Scalar> > &lowerBounds = Teuchos::null,
    const RCP<const ModelEvaluatorBase::InArgs<Scalar> > &upperBounds = Teuchos::null
    );

  /** \brief Initalize.
   *
   * \param thyraModel [in] Model being wrapped.
   *
   * \param nominalValues [in] Completely overrides
   * thyraModel->getNominalValues()
   *
   * \param lowerBounds [in] If non-null, completely overrides
   * thyraModel->getLowerBounds()
   *
   * \param upperBounds [in] If non-null, completely overrides
   * thyraModel->getUpperBounds()
   *
   * <b>Preconditions:</b><ul>
   * <li><tt>thyraModel.get()!=NULL</tt>
   * </ul>
   *
   * <b>Postconditions:</b><ul>
   * <li><tt>this->getUnderlyingModel.get() == thyraModel.get()</tt>
   * <li>[nominalValues.get()] <tt>this->getNominalValues()</tt> returns <tt>*nominalValues</tt>
   * <li>[lowerBounds.get()] <tt>this->getLowerBounds()</tt> returns <tt>*lowerBounds</tt>
   * <li>[upperBounds.get()] <tt>this->getUpperBounds()</tt> returns <tt>*upperBounds</tt>
   * </ul>
   */
  void initialize(
    const RCP<ModelEvaluator<Scalar> > &thyraModel,
    const RCP<const ModelEvaluatorBase::InArgs<Scalar> > &nominalValues,
    const RCP<const ModelEvaluatorBase::InArgs<Scalar> > &lowerBounds = Teuchos::null,
    const RCP<const ModelEvaluatorBase::InArgs<Scalar> > &upperBounds = Teuchos::null
    );
  
  /** \brief Set only nominal values. */
  void setNominalValues(
    const RCP<const ModelEvaluatorBase::InArgs<Scalar> >  &nominalValues
    );
  
  /** \brief Set only lower bounds. */
  void setLowerBounds(
    const RCP<const ModelEvaluatorBase::InArgs<Scalar> >  &lowerBounds
    );
  
  /** \brief Set only upper bounds. */
  void setUpperBounds(
    const RCP<const ModelEvaluatorBase::InArgs<Scalar> >  &upperBounds
    );
  
  // ToDo: Add functions to reset lower and upper bounds when needed!

  //@}

  /** \name Public functions overridden from Teuchos::Describable. */
  //@{

  /** \brief . */
  std::string description() const;

  //@}

  /** \name Public functions overridden from ModelEvaulator. */
  //@{

  /** \brief . */
  ModelEvaluatorBase::InArgs<Scalar> getNominalValues() const;
  /** \brief . */
  ModelEvaluatorBase::InArgs<Scalar> getLowerBounds() const;
  /** \brief . */
  ModelEvaluatorBase::InArgs<Scalar> getUpperBounds() const;

  //@}

private:

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

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

  //@}

private:

  RCP<const ModelEvaluatorBase::InArgs<Scalar> >  nominalValues_;
  RCP<const ModelEvaluatorBase::InArgs<Scalar> >  lowerBounds_;
  RCP<const ModelEvaluatorBase::InArgs<Scalar> >  upperBounds_;
  
};


// /////////////////////////////////
// Implementations


// Constructors/initializers/accessors/utilities


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


template<class Scalar>
DefaultNominalBoundsOverrideModelEvaluator<Scalar>::DefaultNominalBoundsOverrideModelEvaluator(
  const RCP<ModelEvaluator<Scalar> > &thyraModel,
  const RCP<const ModelEvaluatorBase::InArgs<Scalar> > &nominalValues,
  const RCP<const ModelEvaluatorBase::InArgs<Scalar> > &lowerBounds,
  const RCP<const ModelEvaluatorBase::InArgs<Scalar> > &upperBounds
  )
{
  initialize(thyraModel,nominalValues,lowerBounds,upperBounds);
}


template<class Scalar>
void DefaultNominalBoundsOverrideModelEvaluator<Scalar>::initialize(
  const RCP<ModelEvaluator<Scalar> > &thyraModel,
  const RCP<const ModelEvaluatorBase::InArgs<Scalar> > &nominalValues,
  const RCP<const ModelEvaluatorBase::InArgs<Scalar> > &lowerBounds,
  const RCP<const ModelEvaluatorBase::InArgs<Scalar> > &upperBounds
  )
{
  this->ModelEvaluatorDelegatorBase<Scalar>::initialize(thyraModel);
  nominalValues_ = nominalValues;
  lowerBounds_ = lowerBounds;
  upperBounds_ = upperBounds;
}


template<class Scalar>
void DefaultNominalBoundsOverrideModelEvaluator<Scalar>::setNominalValues(
  const RCP<const ModelEvaluatorBase::InArgs<Scalar> >  &nominalValues
  )
{
  nominalValues_ = nominalValues;
}


template<class Scalar>
void DefaultNominalBoundsOverrideModelEvaluator<Scalar>::setLowerBounds(
  const RCP<const ModelEvaluatorBase::InArgs<Scalar> >  &lowerBounds
  )
{
  lowerBounds_ = lowerBounds;
}


template<class Scalar>
void DefaultNominalBoundsOverrideModelEvaluator<Scalar>::setUpperBounds(
  const RCP<const ModelEvaluatorBase::InArgs<Scalar> >  &upperBounds
  )
{
  upperBounds_ = upperBounds;
}


// Public functions overridden from Teuchos::Describable


template<class Scalar>
std::string DefaultNominalBoundsOverrideModelEvaluator<Scalar>::description() const
{
  const RCP<const ModelEvaluator<Scalar> >
    thyraModel = this->getUnderlyingModel();
  std::ostringstream oss;
  oss << "Thyra::DefaultNominalBoundsOverrideModelEvaluator{";
  oss << "thyraModel=";
  if(thyraModel.get())
    oss << "\'"<<thyraModel->description()<<"\'";
  else
    oss << "NULL";
  oss << "}";
  return oss.str();
}


// Overridden from ModelEvaulator.


template<class Scalar>
ModelEvaluatorBase::InArgs<Scalar>
DefaultNominalBoundsOverrideModelEvaluator<Scalar>::getNominalValues() const
{
  if(nominalValues_.get())
    return *nominalValues_;
  return this->getUnderlyingModel()->getNominalValues();
}


template<class Scalar>
ModelEvaluatorBase::InArgs<Scalar>
DefaultNominalBoundsOverrideModelEvaluator<Scalar>::getLowerBounds() const
{
  if(lowerBounds_.get())
    return *lowerBounds_;
  return this->getUnderlyingModel()->getLowerBounds();
}


template<class Scalar>
ModelEvaluatorBase::InArgs<Scalar>
DefaultNominalBoundsOverrideModelEvaluator<Scalar>::getUpperBounds() const
{
  if(upperBounds_.get())
    return *upperBounds_;
  return this->getUnderlyingModel()->getUpperBounds();
}


// Private functions overridden from ModelEvaulatorDefaultBase


template<class Scalar>
void DefaultNominalBoundsOverrideModelEvaluator<Scalar>::evalModelImpl(
  const ModelEvaluatorBase::InArgs<Scalar> &inArgs,
  const ModelEvaluatorBase::OutArgs<Scalar> &outArgs
  ) const
{

  using Teuchos::rcp;
  using Teuchos::rcp_const_cast;
  using Teuchos::rcp_dynamic_cast;
  using Teuchos::OSTab;
  typedef ModelEvaluatorBase MEB;

  THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_BEGIN(
    "Thyra::DefaultNominalBoundsOverrideModelEvaluator",inArgs,outArgs
    );

  // First set the inArgs to what was overridden
  MEB::InArgs<Scalar>
    wrappedInArgs = ( !is_null(nominalValues_) ? *nominalValues_ : this->createInArgs() );

  if(out.get() && static_cast<int>(verbLevel) >= static_cast<int>(Teuchos::VERB_EXTREME))
    *out
      << "\nwrappedInArgs after assigning to nominalValues =\n" << Teuchos::describe(wrappedInArgs,verbLevel);

  // Reset those not at their nominal values
  wrappedInArgs.setArgs(inArgs);

  if(out.get() && static_cast<int>(verbLevel) >= static_cast<int>(Teuchos::VERB_EXTREME))
    *out
      << "\nwrappedInArgs after setting input values =\n" << Teuchos::describe(wrappedInArgs,verbLevel);

  thyraModel->evalModel(wrappedInArgs,outArgs);

  THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_END();
  
}


} // namespace Thyra


#endif // THYRA_DEFAULT_NOMINAL_BOUNDS_OVERRIDE_MODEL_EVALUATOR_HPP