Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DefaultFinalPointCaptureModelEvaluator.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef THYRA_DEFAULT_FINAL_POINT_CAPTURE_MODEL_EVALUATOR_HPP
11 #define THYRA_DEFAULT_FINAL_POINT_CAPTURE_MODEL_EVALUATOR_HPP
12 
13 #include "Thyra_ModelEvaluatorDelegatorBase.hpp"
14 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
15 #include "Teuchos_Time.hpp"
16 
17 
18 //#define THYRA_DEFAULT_FINAL_POINT_CAPTURE_MODEL_EVALUATOR_DUMP_ALL
19 
20 
21 namespace Thyra {
22 
23 
31 template<class Scalar>
33  : virtual public ModelEvaluatorDelegatorBase<Scalar>
34 {
35 public:
36 
39 
42 
45 
48  const Teuchos::RCP<ModelEvaluator<Scalar> > &thyraModel
49  );
50 
53 
55  bool finalPointWasSolved() const;
56 
58 
61 
63  std::string description() const;
64 
66 
69 
71  void reportFinalPoint(
72  const ModelEvaluatorBase::InArgs<Scalar> &finalPoint,
73  const bool wasSolved
74  );
75 
77 
78 private:
79 
82 
84  void evalModelImpl(
87  ) const;
88 
90 
91 private:
92 
94  bool finalPointWasSolved_;
95 
96 };
97 
98 
99 // /////////////////////////////////
100 // Implementations
101 
102 
103 // Constructors/initializers/accessors/utilities
104 
105 
106 template<class Scalar>
108  :finalPointWasSolved_(false)
109 {}
110 
111 
112 template<class Scalar>
114  const Teuchos::RCP<ModelEvaluator<Scalar> > &thyraModel
115  )
116 {
118  finalPoint_ = thyraModel->createInArgs();
119  finalPoint_.setArgs(thyraModel->getNominalValues());
120  finalPointWasSolved_ = false;
121 }
122 
123 
124 template<class Scalar>
127 {
128 #ifdef THYRA_DEFAULT_FINAL_POINT_CAPTURE_MODEL_EVALUATOR_DUMP_ALL
130  << "\nDefaultFinalPointCaptureModelEvaluator<Scalar>::getFinalPoint():"
131  << " finalPoint =\n" << Teuchos::describe(finalPoint_,Teuchos::VERB_EXTREME);
132 #endif
133  return finalPoint_;
134 }
135 
136 
137 template<class Scalar>
139 {
140  return finalPointWasSolved_;
141 }
142 
143 
144 // Public functions overridden from Teuchos::Describable
145 
146 
147 template<class Scalar>
149 {
151  thyraModel = this->getUnderlyingModel();
152  std::ostringstream oss;
153  oss << "Thyra::DefaultFinalPointCaptureModelEvaluator{";
154  oss << "thyraModel=";
155  if(thyraModel.get())
156  oss << "\'"<<thyraModel->description()<<"\'";
157  else
158  oss << "NULL";
159  oss << "}";
160  return oss.str();
161 }
162 
163 
164 // Overridden from ModelEvaulator.
165 
166 
167 template<class Scalar>
169  const ModelEvaluatorBase::InArgs<Scalar> &finalPoint,
170  const bool wasSolved
171  )
172 {
173  finalPoint_.setArgs(finalPoint);
174  finalPointWasSolved_ = wasSolved;
175  if(!this->isUnderlyingModelConst())
176  this->getNonconstUnderlyingModel()->reportFinalPoint(finalPoint,wasSolved);
177 #ifdef THYRA_DEFAULT_FINAL_POINT_CAPTURE_MODEL_EVALUATOR_DUMP_ALL
179  << "\nDefaultFinalPointCaptureModelEvaluator<Scalar>::reportFinalPoint(...):"
180  << " finalPoint =\n" << Teuchos::describe(finalPoint_,Teuchos::VERB_EXTREME);
181 #endif
182 }
183 
184 
185 // Private functions overridden from ModelEvaulatorDefaultBase
186 
187 
188 template<class Scalar>
192  ) const
193 {
194 
195  THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_BEGIN(
196  "Thyra::DefaultFinalPointCaptureModelEvaluator",inArgs,outArgs
197  );
198 
199  thyraModel->evalModel(inArgs,outArgs);
200 
201  THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_END();
202 
203 }
204 
205 
206 } // namespace Thyra
207 
208 
209 #endif // THYRA_DEFAULT_FINAL_POINT_CAPTURE_MODEL_EVALUATOR_HPP
void reportFinalPoint(const ModelEvaluatorBase::InArgs< Scalar > &finalPoint, const bool wasSolved)
Pure abstract base interface for evaluating a stateless &quot;model&quot; that can be mapped into a number of d...
Concrete aggregate class for all output arguments computable by a ModelEvaluator subclass object...
This is a base class that delegetes almost all function to a wrapped model evaluator object...
void initialize(const RCP< ModelEvaluator< Scalar > > &model)
Initialize given a non-const model evaluator.
T * get() const
const ModelEvaluatorBase::InArgs< Scalar > & getFinalPoint() const
static RCP< FancyOStream > getDefaultOStream()
This class wraps any ModelEvaluator object and allows the client to capture the final point that is r...
Concrete aggregate class for all input arguments computable by a ModelEvaluator subclass object...