9 #ifndef Tempus_SolutionState_impl_hpp
10 #define Tempus_SolutionState_impl_hpp
12 #include "Thyra_VectorStdOps.hpp"
17 template<
class Scalar>
20 x_nc_ (Teuchos::null),
21 xdot_ (Teuchos::null),
22 xdot_nc_ (Teuchos::null),
23 xdotdot_ (Teuchos::null),
24 xdotdot_nc_ (Teuchos::null),
25 stepperState_ (Teuchos::null),
26 stepperState_nc_(Teuchos::null),
27 physicsState_ (Teuchos::null),
28 physicsState_nc_(Teuchos::null)
39 template<
class Scalar>
41 const Teuchos::RCP<Thyra::VectorBase<Scalar> >& x,
42 const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xdot,
43 const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xdotdot,
51 xdotdot_nc_ (xdotdot),
52 stepperState_ (stepperState),
53 stepperState_nc_(stepperState),
54 physicsState_ (physicsState),
55 physicsState_nc_(physicsState)
69 template<
class Scalar>
71 const Teuchos::RCP<
const Thyra::VectorBase<Scalar> >& x,
72 const Teuchos::RCP<
const Thyra::VectorBase<Scalar> >& xdot,
73 const Teuchos::RCP<
const Thyra::VectorBase<Scalar> >& xdotdot,
77 x_nc_ (Teuchos::null),
79 xdot_nc_ (Teuchos::null),
81 xdotdot_nc_ (Teuchos::null),
82 stepperState_ (stepperState),
83 stepperState_nc_(Teuchos::null),
84 physicsState_ (physicsState),
85 physicsState_nc_(Teuchos::null)
90 using Teuchos::rcp_const_cast;
106 template<
class Scalar>
109 const Teuchos::RCP<Thyra::VectorBase<Scalar> >& x,
110 const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xdot,
111 const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xdotdot,
114 : metaData_ (metaData),
115 metaData_nc_ (metaData),
121 xdotdot_nc_ (xdotdot),
122 stepperState_ (stepperState),
123 stepperState_nc_(stepperState),
124 physicsState_ (physicsState),
125 physicsState_nc_(physicsState)
137 template<
class Scalar>
140 const Teuchos::RCP<
const Thyra::VectorBase<Scalar> >& x,
141 const Teuchos::RCP<
const Thyra::VectorBase<Scalar> >& xdot,
142 const Teuchos::RCP<
const Thyra::VectorBase<Scalar> >& xdotdot,
145 : metaData_ (metaData),
146 metaData_nc_ (Teuchos::null),
148 x_nc_ (Teuchos::null),
150 xdot_nc_ (Teuchos::null),
152 xdotdot_nc_ (Teuchos::null),
153 stepperState_ (stepperState),
154 stepperState_nc_(Teuchos::null),
155 physicsState_ (physicsState),
156 physicsState_nc_(Teuchos::null)
169 template<
class Scalar>
171 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& model,
175 typedef Thyra::ModelEvaluatorBase MEB;
176 using Teuchos::rcp_const_cast;
180 metaData_ = metaData_nc_;
182 MEB::InArgs<Scalar> inArgs = model->getNominalValues();
185 x_nc_ = rcp_const_cast<Thyra::VectorBase<Scalar> > (inArgs.get_x());
192 if (inArgs.supports(MEB::IN_ARG_x_dot)) {
193 xdot_nc_ = rcp_const_cast<Thyra::VectorBase<Scalar> >(inArgs.get_x_dot());
196 xdot_nc_ = Teuchos::null;
201 if (inArgs.supports(MEB::IN_ARG_x_dot_dot)) {
203 rcp_const_cast<Thyra::VectorBase<Scalar> > (inArgs.get_x_dot_dot());
204 xdotdot_ = xdotdot_nc_;
206 xdotdot_nc_ = Teuchos::null;
207 xdotdot_ = xdotdot_nc_;
210 if (stepperState_ == Teuchos::null) {
212 stepperState_ = stepperState_nc_;
214 stepperState_nc_ = stepperState;
215 stepperState_ = stepperState;
218 if (physicsState_ == Teuchos::null) {
220 physicsState_ = physicsState_nc_;
222 physicsState_nc_ = physicsState;
223 physicsState_ = physicsState;
227 template<
class Scalar>
229 :metaData_ (ss_.metaData_),
230 metaData_nc_ (ss_.metaData_nc_),
234 xdot_nc_ (ss_.xdot_nc_),
235 xdotdot_ (ss_.xdotdot_),
236 xdotdot_nc_ (ss_.xdotdot_nc_),
237 stepperState_ (ss_.stepperState_),
238 stepperState_nc_(ss_.stepperState_nc_),
239 physicsState_ (ss_.physicsState_),
240 physicsState_nc_(ss_.physicsState_nc_)
244 template<
class Scalar>
249 RCP<SolutionStateMetaData<Scalar> > metaData_out;
250 if (!Teuchos::is_null(metaData_)) metaData_out = metaData_->clone();
252 RCP<Thyra::VectorBase<Scalar> > x_out;
253 if (!Teuchos::is_null(x_)) x_out = x_->clone_v();
255 RCP<Thyra::VectorBase<Scalar> > xdot_out;
256 if (!Teuchos::is_null(xdot_)) xdot_out = xdot_->clone_v();
258 RCP<Thyra::VectorBase<Scalar> > xdotdot_out;
259 if (!Teuchos::is_null(xdotdot_)) xdotdot_out = xdotdot_->clone_v();
261 RCP<StepperState<Scalar> > sS_out;
262 if (!Teuchos::is_null(stepperState_)) sS_out=stepperState_->clone();
264 RCP<PhysicsState<Scalar> > pS_out;
265 if (!Teuchos::is_null(physicsState_)) pS_out=physicsState_->clone();
268 metaData_out, x_out, xdot_out, xdotdot_out, sS_out, pS_out));
274 template<
class Scalar>
278 metaData_nc_->copy(ss->metaData_);
279 this->copySolutionData(ss);
283 template<
class Scalar>
287 if (ss->x_ == Teuchos::null)
288 x_nc_ = Teuchos::null;
290 if (x_nc_ == Teuchos::null) {
291 x_nc_ = ss->x_->clone_v();
294 Thyra::V_V(x_nc_.ptr(), *(ss->x_));
298 if (ss->xdot_ == Teuchos::null)
299 xdot_nc_ = Teuchos::null;
301 if (xdot_nc_ == Teuchos::null)
302 xdot_nc_ = ss->xdot_->clone_v();
304 Thyra::V_V(xdot_nc_.ptr(), *(ss->xdot_));
308 if (ss->xdotdot_ == Teuchos::null)
309 xdotdot_nc_ = Teuchos::null;
311 if (xdotdot_nc_ == Teuchos::null)
312 xdotdot_nc_ = ss->xdotdot_->clone_v();
314 Thyra::V_V(xdotdot_nc_.ptr(), *(ss->xdotdot_));
316 xdotdot_ = xdotdot_nc_;
318 stepperState_nc_->copy(ss->stepperState_);
319 physicsState_nc_->copy(ss->physicsState_);
322 template<
class Scalar>
325 return (this->metaData_->getTime() < ss.
metaData_->getTime());
328 template<
class Scalar>
331 return (this->metaData_->getTime() <= ss.
metaData_->getTime());
334 template<
class Scalar>
337 return (this->metaData_->getTime() < t);
340 template<
class Scalar>
343 return (this->metaData_->getTime() <= t);
346 template<
class Scalar>
349 return (this->metaData_->getTime() > ss.
metaData_->getTime());
352 template<
class Scalar>
355 return (this->metaData_->getTime() >= ss.
metaData_->getTime());
358 template<
class Scalar>
361 return (this->metaData_->getTime() > t);
364 template<
class Scalar>
367 return (this->metaData_->getTime() >= t);
370 template<
class Scalar>
373 return (this->metaData_->getTime() == ss.
metaData_->getTime());
376 template<
class Scalar>
379 return (this->metaData_->getTime() == t);
382 template<
class Scalar>
385 std::string name =
"Tempus::SolutionState";
389 template<
class Scalar>
391 Teuchos::FancyOStream &out,
392 const Teuchos::EVerbosityLevel verbLevel)
const
394 if (verbLevel == Teuchos::VERB_EXTREME) {
395 out << description() <<
"::describe:" << std::endl
396 <<
"metaData = " << std::endl;
397 metaData_->describe(out,verbLevel);
398 out <<
"x = " << std::endl;
399 x_->describe(out,verbLevel);
400 if (xdot_ != Teuchos::null) {
401 out <<
"xdot_ = " << std::endl;
402 xdot_->describe(out,verbLevel);
404 if (xdotdot_ != Teuchos::null) {
405 out <<
"xdotdot = " << std::endl;
406 xdotdot_->describe(out,verbLevel);
408 if (stepperState_ != Teuchos::null) {
409 out <<
"stepperState = " << std::endl;
410 stepperState_->describe(out,verbLevel);
412 if (physicsState_ != Teuchos::null) {
413 out <<
"stepperState = " << std::endl;
414 physicsState_->describe(out,verbLevel);
420 #endif // Tempus_SolutionState_impl_hpp
PhysicsState is a simple class to hold information about the physics.
Teuchos::RCP< const SolutionStateMetaData< Scalar > > metaData_
Meta Data for the solution state.
Teuchos::RCP< Tempus::PhysicsState< Scalar > > physicsState_nc_
Teuchos::RCP< const Tempus::StepperState< Scalar > > stepperState_
StepperState for this SolutionState.
Teuchos::RCP< const Tempus::PhysicsState< Scalar > > physicsState_
PhysicsState for this SolutionState.
StepperState is a simple class to hold state information about the stepper.
bool operator>(const SolutionState< Scalar > &ss) const
Less than comparison for sorting based on time.
virtual void copySolutionData(const Teuchos::RCP< const SolutionState< Scalar > > &s)
Deep copy solution data, but keep metaData untouched.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
SolutionState()
Default Constructor – Not meant for immediate adding to SolutionHistory. This constructor does not se...
bool operator>=(const SolutionState< Scalar > &ss) const
Less than comparison for sorting based on time.
bool operator==(const SolutionState< Scalar > &ss) const
Equality comparison for matching.
bool operator<=(const SolutionState< Scalar > &ss) const
Less than comparison for sorting based on time.
virtual Teuchos::RCP< SolutionState< Scalar > > clone() const
This is a deep copy constructor.
bool operator<(const SolutionState< Scalar > &ss) const
Less than comparison for sorting based on time.
Teuchos::RCP< Tempus::StepperState< Scalar > > stepperState_nc_
virtual std::string description() const
Solution state for integrators and steppers. SolutionState contains the metadata for solutions and th...
Teuchos::RCP< SolutionStateMetaData< Scalar > > metaData_nc_
virtual void copy(const Teuchos::RCP< const SolutionState< Scalar > > &ss)
This is a deep copy.