Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Tempus_Test::HarmonicOscillatorModel< Scalar > Class Template Reference

Consider the ODE:

\[ m\ddot{x} + c\dot{x} + kx=f \]

where $k \geq 0$ is a constant, $c$ is a constant damping parameter, $f$ is a constant forcing parameter, and $m>0$ is a constant mass parameter, with initial conditions are:

\begin{eqnarray*} x(0) & = & 0\\ \dot{x}(0) & = & 1 \end{eqnarray*}

It is straight-forward to show that the exact solution to this ODE is:

\begin{eqnarray*} x(t) & = & t(1+0.5\tilde{f}t), \hspace{3.6cm} if \hspace{0.2cm} k = c = 0 \\ & = & \frac{(\tilde{c}-\tilde{f})}{\tilde{c}^2}(1-e^{-\tilde{c}t}) + \frac{f}{c}t, \hspace{1.9cm} if \hspace{0.2cm} k = 0, c\neq 0 \\ & = & \frac{1}{\sqrt{\tilde{k}}}\sin(\sqrt{\tilde{k}}t) + \frac{f}{k}\left(1-\cos(\sqrt{\tilde{k}}t) \right), \hspace{0.2cm} if \hspace{0.2cm} k > 0, c = 0 \end{eqnarray*}

where $\tilde{c}\equiv c/m$, $\tilde{k}\equiv k/m$ and $\tilde{f}\equiv f/m$. While it is possible to derive the solution to this ODE for the case when $k > 0$ and $c \neq 0$, we do not consider that case here. When $c = k = 0$, $m=1$, and $f=-1$, our ODE simplies to a canonical differential equation model of a ball thrown up in the air, with a parabolic trajectory solution, namely

\[ x(t) = t(1-0.5t) \]

where $t\in [0,2]$. An EpetraExt version of this simplified version of the test is implemented in Piro::MockModelEval_B (see Trilinos/packages/piro/test), where it is used to test the Piro (EpetraExt) Newmark-Beta scheme (see input_Solver_NB.xml input file). When $c = f = 0$ and $m=k = 1$, this test is equivalent to the SinCos model.. More...

#include <HarmonicOscillatorModel_decl.hpp>

Inheritance diagram for Tempus_Test::HarmonicOscillatorModel< Scalar >:
Thyra::StateFuncModelEvaluatorBase< Scalar > Teuchos::ParameterListAcceptorDefaultBase Thyra::ModelEvaluatorDefaultBase< Scalar > Teuchos::ParameterListAcceptor Thyra::ModelEvaluator< class > Thyra::ModelEvaluatorBase Teuchos::Describable Teuchos::LabeledObject

Public Member Functions

 HarmonicOscillatorModel (Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null, const bool use_accel_IC=false)
 
Thyra::ModelEvaluatorBase::InArgs
< Scalar > 
getExactSolution (double t) const
 
- Public Member Functions inherited from Thyra::StateFuncModelEvaluatorBase< Scalar >
RCP< const VectorSpaceBase
< Scalar > > 
get_p_space (int l) const
 
RCP< const Teuchos::Array
< std::string > > 
get_p_names (int l) const
 
RCP< const VectorSpaceBase
< Scalar > > 
get_g_space (int j) const
 
Teuchos::ArrayView< const
std::string > 
get_g_names (int j) const
 
ModelEvaluatorBase::InArgs
< Scalar > 
getNominalValues () const
 
ModelEvaluatorBase::InArgs
< Scalar > 
getLowerBounds () const
 
ModelEvaluatorBase::InArgs
< Scalar > 
getUpperBounds () const
 
RCP< LinearOpBase< Scalar > > create_W_op () const
 
RCP< PreconditionerBase< Scalar > > create_W_prec () const
 
RCP< const
LinearOpWithSolveFactoryBase
< Scalar > > 
get_W_factory () const
 
void reportFinalPoint (const ModelEvaluatorBase::InArgs< Scalar > &finalPoint, const bool wasSolved)
 
- Public Member Functions inherited from Thyra::ModelEvaluator< class >
virtual int Np () const =0
 
virtual int Ng () const =0
 
virtual RCP< const
VectorSpaceBase< Scalar > > 
get_f_multiplier_space () const =0
 
virtual RCP< const
VectorSpaceBase< Scalar > > 
get_g_multiplier_space (int j) const =0
 
virtual RCP< LinearOpBase
< Scalar > > 
create_DfDp_op (int l) const =0
 
virtual RCP< LinearOpBase
< Scalar > > 
create_DgDx_dot_op (int j) const =0
 
virtual RCP< LinearOpBase
< Scalar > > 
create_DgDx_op (int j) const =0
 
virtual RCP< LinearOpBase
< Scalar > > 
create_DgDp_op (int j, int l) const =0
 
virtual
ModelEvaluatorBase::OutArgs
< Scalar > 
createOutArgs () const =0
 
virtual void evalModel (const ModelEvaluatorBase::InArgs< Scalar > &inArgs, const ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const =0
 
 ModelEvaluatorBase ()
 
std::string toString (ModelEvaluatorBase::EInArgsMembers)
 
std::string toString (ModelEvaluatorBase::EOutArgsMembers)
 
std::string toString (ModelEvaluatorBase::EDerivativeMultiVectorOrientation orientation)
 
ModelEvaluatorBase::EDerivativeMultiVectorOrientation getOtherDerivativeMultiVectorOrientation (ModelEvaluatorBase::EDerivativeMultiVectorOrientation orientation)
 
- Public Member Functions inherited from Teuchos::Describable
virtual std::string description () const
 
virtual void describe (FancyOStream &out, const EVerbosityLevel verbLevel=verbLevel_default) const
 
void describe (std::ostream &out, const EVerbosityLevel verbLevel=verbLevel_default) const
 
virtual ~Describable ()
 
 LabeledObject ()
 
virtual ~LabeledObject ()
 
virtual void setObjectLabel (const std::string &objectLabel)
 
virtual std::string getObjectLabel () const
 
DescribableStreamManipulatorState describe (const Describable &describable, const EVerbosityLevel verbLevel=Describable::verbLevel_default)
 
std::ostream & operator<< (std::ostream &os, const DescribableStreamManipulatorState &d)
 
- Public Member Functions inherited from Teuchos::ParameterListAcceptorDefaultBase
RCP< ParameterListgetNonconstParameterList ()
 
RCP< ParameterListunsetParameterList ()
 
RCP< const ParameterListgetParameterList () const
 

Private Member Functions

void setupInOutArgs_ () const
 

Private Attributes

Teuchos::RCP< const
Thyra::VectorSpaceBase< Scalar > > 
x_space_
 
Teuchos::RCP< const
Thyra::VectorSpaceBase< Scalar > > 
p_space_
 
Teuchos::RCP< const
Thyra::VectorSpaceBase< Scalar > > 
g_space_
 
Teuchos::RCP
< Thyra::VectorBase< Scalar > > 
x_vec_
 
Teuchos::RCP
< Thyra::VectorBase< Scalar > > 
x_dot_vec_
 
Teuchos::RCP
< Thyra::VectorBase< Scalar > > 
x_dot_dot_vec_
 
Teuchos::RCP
< Thyra::VectorBase< Scalar > > 
p_init_
 
int vecLength_
 
int numResponses_
 
Thyra::ModelEvaluatorBase::InArgs
< Scalar > 
inArgs_
 
Thyra::ModelEvaluatorBase::OutArgs
< Scalar > 
outArgs_
 
Thyra::ModelEvaluatorBase::InArgs
< Scalar > 
nominalValues_
 
bool isInitialized_
 
double c_
 
double f_
 
double k_
 
double m_
 
Teuchos::RCP
< Teuchos::FancyOStream
out_
 

Public functions overridden from ModelEvaluator.

Teuchos::RCP< const
Thyra::VectorSpaceBase< Scalar > > 
get_x_space () const
 
Teuchos::RCP< const
Thyra::VectorSpaceBase< Scalar > > 
get_f_space () const
 
Thyra::ModelEvaluatorBase::InArgs
< Scalar > 
getNominalValues () const
 
Teuchos::RCP
< Thyra::LinearOpWithSolveBase
< Scalar > > 
create_W () const
 
Teuchos::RCP
< Thyra::LinearOpBase< Scalar > > 
create_W_op () const
 
Teuchos::RCP< const
Thyra::LinearOpWithSolveFactoryBase
< Scalar > > 
get_W_factory () const
 
Thyra::ModelEvaluatorBase::InArgs
< Scalar > 
createInArgs () const
 
Teuchos::RCP< const
Thyra::VectorSpaceBase< Scalar > > 
get_p_space (int l) const
 
Teuchos::RCP< const
Teuchos::Array< std::string > > 
get_p_names (int l) const
 
Teuchos::RCP< const
Thyra::VectorSpaceBase< Scalar > > 
get_g_space (int j) const
 

Public functions overridden from ParameterListAcceptor.

void setParameterList (Teuchos::RCP< Teuchos::ParameterList > const &paramList)
 
Teuchos::RCP< const
Teuchos::ParameterList
getValidParameters () const
 

Private functions overridden from ModelEvaluatorDefaultBase.

Thyra::ModelEvaluatorBase::OutArgs
< Scalar > 
createOutArgsImpl () const
 
void evalModelImpl (const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs_bar, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs_bar) const
 

Additional Inherited Members

- Public Types inherited from Thyra::ModelEvaluator< class >
enum  EInArgsMembers
 
enum  EInArgs_p_mp
 
enum  EEvalType
 
enum  EDerivativeMultiVectorOrientation
 
enum  EDerivativeLinearOp
 
enum  EDerivativeLinearity
 
enum  ERankStatus
 
enum  EOutArgsMembers
 
enum  EOutArgsDfDp
 
enum  EOutArgsDgDx_dot
 
enum  EOutArgsDgDx
 
enum  EOutArgsDgDp
 
enum  EOutArgsDfDp_mp
 
enum  EOutArgs_g_mp
 
enum  EOutArgsDgDx_dot_mp
 
enum  EOutArgsDgDx_mp
 
enum  EOutArgsDgDp_mp
 
typedef Teuchos::ScalarTraits
< Scalar >::magnitudeType 
ScalarMag
 
- Static Public Attributes inherited from Thyra::ModelEvaluator< class >
static const int NUM_E_IN_ARGS_MEMBERS
 
static const int NUM_E_OUT_ARGS_MEMBERS
 
- Static Public Attributes inherited from Teuchos::Describable
static const EVerbosityLevel verbLevel_default
 
- Protected Member Functions inherited from Teuchos::ParameterListAcceptorDefaultBase
void setMyParamList (const RCP< ParameterList > &paramList)
 
RCP< ParameterListgetMyNonconstParamList ()
 
RCP< const ParameterListgetMyParamList () const
 

Detailed Description

template<class Scalar>
class Tempus_Test::HarmonicOscillatorModel< Scalar >

Consider the ODE:

\[ m\ddot{x} + c\dot{x} + kx=f \]

where $k \geq 0$ is a constant, $c$ is a constant damping parameter, $f$ is a constant forcing parameter, and $m>0$ is a constant mass parameter, with initial conditions are:

\begin{eqnarray*} x(0) & = & 0\\ \dot{x}(0) & = & 1 \end{eqnarray*}

It is straight-forward to show that the exact solution to this ODE is:

\begin{eqnarray*} x(t) & = & t(1+0.5\tilde{f}t), \hspace{3.6cm} if \hspace{0.2cm} k = c = 0 \\ & = & \frac{(\tilde{c}-\tilde{f})}{\tilde{c}^2}(1-e^{-\tilde{c}t}) + \frac{f}{c}t, \hspace{1.9cm} if \hspace{0.2cm} k = 0, c\neq 0 \\ & = & \frac{1}{\sqrt{\tilde{k}}}\sin(\sqrt{\tilde{k}}t) + \frac{f}{k}\left(1-\cos(\sqrt{\tilde{k}}t) \right), \hspace{0.2cm} if \hspace{0.2cm} k > 0, c = 0 \end{eqnarray*}

where $\tilde{c}\equiv c/m$, $\tilde{k}\equiv k/m$ and $\tilde{f}\equiv f/m$. While it is possible to derive the solution to this ODE for the case when $k > 0$ and $c \neq 0$, we do not consider that case here. When $c = k = 0$, $m=1$, and $f=-1$, our ODE simplies to a canonical differential equation model of a ball thrown up in the air, with a parabolic trajectory solution, namely

\[ x(t) = t(1-0.5t) \]

where $t\in [0,2]$. An EpetraExt version of this simplified version of the test is implemented in Piro::MockModelEval_B (see Trilinos/packages/piro/test), where it is used to test the Piro (EpetraExt) Newmark-Beta scheme (see input_Solver_NB.xml input file). When $c = f = 0$ and $m=k = 1$, this test is equivalent to the SinCos model..

Definition at line 55 of file HarmonicOscillatorModel_decl.hpp.

Constructor & Destructor Documentation

template<class Scalar >
Tempus_Test::HarmonicOscillatorModel< Scalar >::HarmonicOscillatorModel ( Teuchos::RCP< Teuchos::ParameterList pList = Teuchos::null,
const bool  use_accel_IC = false 
)

Definition at line 27 of file HarmonicOscillatorModel_impl.hpp.

Member Function Documentation

template<class Scalar >
Thyra::ModelEvaluatorBase::InArgs< Scalar > Tempus_Test::HarmonicOscillatorModel< Scalar >::getExactSolution ( double  t) const

Definition at line 73 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > Tempus_Test::HarmonicOscillatorModel< Scalar >::get_x_space ( ) const
virtual

Implements Thyra::ModelEvaluator< class >.

Definition at line 132 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > Tempus_Test::HarmonicOscillatorModel< Scalar >::get_f_space ( ) const
virtual

Implements Thyra::ModelEvaluator< class >.

Definition at line 139 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Thyra::ModelEvaluatorBase::InArgs< Scalar > Tempus_Test::HarmonicOscillatorModel< Scalar >::getNominalValues ( ) const
virtual

Implements Thyra::ModelEvaluator< class >.

Definition at line 146 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< Thyra::LinearOpWithSolveBase< Scalar > > Tempus_Test::HarmonicOscillatorModel< Scalar >::create_W ( ) const
virtual

Implements Thyra::ModelEvaluator< class >.

Definition at line 155 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > Tempus_Test::HarmonicOscillatorModel< Scalar >::create_W_op ( ) const
virtual

Implements Thyra::ModelEvaluator< class >.

Definition at line 172 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > Tempus_Test::HarmonicOscillatorModel< Scalar >::get_W_factory ( ) const
virtual

Implements Thyra::ModelEvaluator< class >.

Definition at line 181 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Thyra::ModelEvaluatorBase::InArgs< Scalar > Tempus_Test::HarmonicOscillatorModel< Scalar >::createInArgs ( ) const
virtual

Implements Thyra::ModelEvaluator< class >.

Definition at line 190 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > Tempus_Test::HarmonicOscillatorModel< Scalar >::get_p_space ( int  l) const
virtual

Implements Thyra::ModelEvaluator< class >.

Definition at line 297 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Teuchos::Array< std::string > > Tempus_Test::HarmonicOscillatorModel< Scalar >::get_p_names ( int  l) const
virtual

Implements Thyra::ModelEvaluator< class >.

Definition at line 307 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > Tempus_Test::HarmonicOscillatorModel< Scalar >::get_g_space ( int  j) const
virtual

Implements Thyra::ModelEvaluator< class >.

Definition at line 317 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
void Tempus_Test::HarmonicOscillatorModel< Scalar >::setParameterList ( Teuchos::RCP< Teuchos::ParameterList > const &  paramList)
virtual

Implements Teuchos::ParameterListAcceptor.

Definition at line 370 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Teuchos::ParameterList > Tempus_Test::HarmonicOscillatorModel< Scalar >::getValidParameters ( ) const
virtual

Reimplemented from Teuchos::ParameterListAcceptor.

Definition at line 408 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
void Tempus_Test::HarmonicOscillatorModel< Scalar >::setupInOutArgs_ ( ) const
private

Definition at line 329 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Thyra::ModelEvaluatorBase::OutArgs< Scalar > Tempus_Test::HarmonicOscillatorModel< Scalar >::createOutArgsImpl ( ) const
private

Definition at line 200 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
void Tempus_Test::HarmonicOscillatorModel< Scalar >::evalModelImpl ( const Thyra::ModelEvaluatorBase::InArgs< Scalar > &  inArgs_bar,
const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &  outArgs_bar 
) const
private

Definition at line 207 of file HarmonicOscillatorModel_impl.hpp.

Member Data Documentation

template<class Scalar >
Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > Tempus_Test::HarmonicOscillatorModel< Scalar >::x_space_
private

Definition at line 103 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > Tempus_Test::HarmonicOscillatorModel< Scalar >::p_space_
private

Definition at line 104 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > Tempus_Test::HarmonicOscillatorModel< Scalar >::g_space_
private

Definition at line 105 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<Thyra::VectorBase<Scalar> > Tempus_Test::HarmonicOscillatorModel< Scalar >::x_vec_
private

Definition at line 106 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<Thyra::VectorBase<Scalar> > Tempus_Test::HarmonicOscillatorModel< Scalar >::x_dot_vec_
private

Definition at line 107 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<Thyra::VectorBase<Scalar> > Tempus_Test::HarmonicOscillatorModel< Scalar >::x_dot_dot_vec_
private

Definition at line 108 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<Thyra::VectorBase<Scalar> > Tempus_Test::HarmonicOscillatorModel< Scalar >::p_init_
private

Definition at line 109 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
int Tempus_Test::HarmonicOscillatorModel< Scalar >::vecLength_
private

Definition at line 110 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
int Tempus_Test::HarmonicOscillatorModel< Scalar >::numResponses_
private

Definition at line 111 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Thyra::ModelEvaluatorBase::InArgs<Scalar> Tempus_Test::HarmonicOscillatorModel< Scalar >::inArgs_
mutableprivate

Definition at line 112 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Thyra::ModelEvaluatorBase::OutArgs<Scalar> Tempus_Test::HarmonicOscillatorModel< Scalar >::outArgs_
mutableprivate

Definition at line 113 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Thyra::ModelEvaluatorBase::InArgs<Scalar> Tempus_Test::HarmonicOscillatorModel< Scalar >::nominalValues_
mutableprivate

Definition at line 114 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
bool Tempus_Test::HarmonicOscillatorModel< Scalar >::isInitialized_
mutableprivate

Definition at line 115 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
double Tempus_Test::HarmonicOscillatorModel< Scalar >::c_
private

Definition at line 116 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
double Tempus_Test::HarmonicOscillatorModel< Scalar >::f_
private

Definition at line 117 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
double Tempus_Test::HarmonicOscillatorModel< Scalar >::k_
private

Definition at line 118 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
double Tempus_Test::HarmonicOscillatorModel< Scalar >::m_
private

Definition at line 119 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<Teuchos::FancyOStream> Tempus_Test::HarmonicOscillatorModel< Scalar >::out_
private

Definition at line 120 of file HarmonicOscillatorModel_decl.hpp.


The documentation for this class was generated from the following files: