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

Generated on Tue Jul 13 09:26:20 2010 for Thyra by  doxygen 1.4.7