Thyra_Simple2DModelEvaluator_def.hpp

00001 
00002 #ifndef THYRA_SIMPLE_2D_MODEL_EVALUATOR_DEF_HPP
00003 #define THYRA_SIMPLE_2D_MODEL_EVALUATOR_DEF_HPP
00004 
00005 
00006 #include "Thyra_Simple2DModelEvaluator_decl.hpp"
00007 #include "Thyra_DefaultSpmdVectorSpace.hpp"
00008 #include "Thyra_DefaultSerialDenseLinearOpWithSolveFactory.hpp"
00009 #include "Thyra_DetachedVectorView.hpp"
00010 #include "Thyra_MultiVectorStdOps.hpp"
00011 #include "Thyra_VectorStdOps.hpp"
00012 
00013 
00014 namespace Thyra {
00015 
00016 
00017 // Nonmember constuctors
00018 
00019 
00020 template<class Scalar>
00021 Teuchos::RCP<Simple2DModelEvaluator<Scalar> >
00022 simple2DModelEvaluator()
00023 {
00024   return Teuchos::rcp(new Simple2DModelEvaluator<Scalar>);
00025 }
00026 
00027 
00028 // Initializers/Accessors
00029 
00030 
00031 template<class Scalar>
00032 void Simple2DModelEvaluator<Scalar>::set_d(const Scalar &d)
00033 {
00034   d_ = d;
00035 }
00036 
00037 
00038 template<class Scalar>
00039 void Simple2DModelEvaluator<Scalar>::set_p(const Teuchos::ArrayView<const Scalar> &p)
00040 {
00041 #ifdef TEUCHOS_DEBUG
00042   TEUCHOS_ASSERT_EQUALITY(p_.size(), p.size());
00043 #endif
00044   p_().assign(p);
00045 }
00046 
00047 
00048 template<class Scalar>
00049 void Simple2DModelEvaluator<Scalar>::set_x0(const Teuchos::ArrayView<const Scalar> &x0_in)
00050 {
00051 #ifdef TEUCHOS_DEBUG
00052   TEUCHOS_ASSERT_EQUALITY(x_space_->dim(), x0_in.size());
00053 #endif
00054   Thyra::DetachedVectorView<Scalar> x0(x0_);
00055   x0.sv().values()().assign(x0_in);
00056 }
00057 
00058 
00059 template<class Scalar>
00060 void Simple2DModelEvaluator<Scalar>::setShowGetInvalidArgs(bool showGetInvalidArg)
00061 {
00062   showGetInvalidArg_ = showGetInvalidArg;
00063 }
00064 
00065 
00066 // Public functions overridden from ModelEvaulator
00067 
00068 
00069 template<class Scalar>
00070 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> >
00071 Simple2DModelEvaluator<Scalar>::get_x_space() const
00072 {
00073   return x_space_;
00074 }
00075 
00076 
00077 template<class Scalar>
00078 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> >
00079 Simple2DModelEvaluator<Scalar>::get_f_space() const
00080 {
00081   return f_space_;
00082 }
00083 
00084 
00085 template<class Scalar>
00086 Thyra::ModelEvaluatorBase::InArgs<Scalar>
00087 Simple2DModelEvaluator<Scalar>::getNominalValues() const
00088 {
00089   return nominalValues_;
00090 }
00091 
00092 
00093 template<class Scalar>
00094 Teuchos::RCP<Thyra::LinearOpBase<Scalar> >
00095 Simple2DModelEvaluator<Scalar>::create_W_op() const
00096 {
00097   return Thyra::createMembers(f_space_, x_space_->dim());
00098 }
00099 
00100 
00101 template<class Scalar>
00102 Teuchos::RCP<const Thyra::LinearOpWithSolveFactoryBase<Scalar> >
00103 Simple2DModelEvaluator<Scalar>::get_W_factory() const
00104 {
00105   return W_factory_;
00106 }
00107 
00108 
00109 template<class Scalar>
00110 Thyra::ModelEvaluatorBase::InArgs<Scalar>
00111 Simple2DModelEvaluator<Scalar>::createInArgs() const
00112 {
00113   return prototypeInArgs_;
00114 }
00115 
00116 
00117 // Private functions overridden from ModelEvaulatorDefaultBase
00118 
00119 
00120 template<class Scalar>
00121 Thyra::ModelEvaluatorBase::OutArgs<Scalar>
00122 Simple2DModelEvaluator<Scalar>::createOutArgsImpl() const
00123 {
00124   return prototypeOutArgs_;
00125 }
00126 
00127 
00128 template<class Scalar>
00129 void Simple2DModelEvaluator<Scalar>::evalModelImpl(
00130   const Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs,
00131   const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs
00132   ) const
00133 {
00134   TEST_FOR_EXCEPT(true);
00135 }
00136 
00137 
00138 // private
00139 
00140 
00141 template<class Scalar>
00142 Simple2DModelEvaluator<Scalar>::Simple2DModelEvaluator()
00143   : x_space_(Thyra::defaultSpmdVectorSpace<Scalar>(2)),
00144     f_space_(x_space_),
00145     W_factory_(Thyra::defaultSerialDenseLinearOpWithSolveFactory<Scalar>()),
00146     d_(0.0),
00147     p_(x_space_->dim(), Teuchos::ScalarTraits<Scalar>::zero()),
00148     showGetInvalidArg_(false)
00149 {
00150 
00151   using Teuchos::RCP;
00152   using Thyra::VectorBase;
00153   using Thyra::createMember;
00154   typedef Thyra::ModelEvaluatorBase MEB;
00155   typedef Teuchos::ScalarTraits<Scalar> ST;
00156   
00157   MEB::InArgsSetup<Scalar> inArgs;
00158   inArgs.setModelEvalDescription(this->description());
00159   inArgs.setSupports(MEB::IN_ARG_x);
00160   prototypeInArgs_ = inArgs;
00161   
00162   MEB::OutArgsSetup<Scalar> outArgs;
00163   outArgs.setModelEvalDescription(this->description());
00164   outArgs.setSupports(MEB::OUT_ARG_f);
00165   prototypeOutArgs_ = outArgs;
00166 
00167   nominalValues_ = inArgs;
00168   x0_ = createMember(x_space_);
00169   V_S(x0_.ptr(), ST::zero());
00170   nominalValues_.set_x(x0_);
00171 
00172   set_d(10.0);
00173   set_p(Teuchos::tuple<Scalar>(2.0, 0.0)());
00174   set_x0(Teuchos::tuple<Scalar>(1.0, 1.0)());
00175 
00176 }
00177 
00178 
00179 } // namespace Thyra
00180 
00181 
00182 //
00183 // Explicit instantiation macro
00184 //
00185 // Must be expanded from within the global namespace!
00186 //
00187 
00188 #define SIMPLE_2D_MODEL_EVALUATOR_INSTANT(SCALAR) \
00189   \
00190   template class Simple2DModelEvaluator<SCALAR >; \
00191   \
00192   template Teuchos::RCP<Simple2DModelEvaluator<SCALAR > > \
00193   simple2DModelEvaluator(); \
00194 
00195 
00196 #endif // THYRA_SIMPLE_2D_MODEL_EVALUATOR_DEF_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:00:23 2011 for Thyra by  doxygen 1.6.3