RTOp Package Browser (Single Doxygen Collection) Version of the Day
RTOpPack_RTOpT_decl.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 // RTOp: Interfaces and Support Software for Vector Reduction Transformation
00005 //       Operations
00006 //                Copyright (2006) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00039 // 
00040 // ***********************************************************************
00041 // @HEADER
00042 
00043 
00044 #ifndef RTOPPACK_RTOP_NEW_T_DECL_HPP
00045 #define RTOPPACK_RTOP_NEW_T_DECL_HPP
00046 
00047 
00048 #include "RTOpPack_Types.hpp"
00049 #include "Teuchos_Describable.hpp"
00050 
00051 
00052 namespace RTOpPack {
00053 
00054 
00057 class ReductTarget : public Teuchos::Describable
00058 {};
00059 
00060 
00168 template<class Scalar>
00169 class RTOpT : public Teuchos::Describable {
00170 public:
00171 
00174 
00176   typedef typename PrimitiveTypeTraits<Scalar,Scalar>::primitiveType
00177   primitive_value_type;
00178 
00180 
00183 
00199   void get_reduct_type_num_entries(
00200     const Ptr<int> &num_values,
00201     const Ptr<int> &num_indexes,
00202     const Ptr<int> &num_chars
00203     ) const
00204     {
00205       get_reduct_type_num_entries_impl(num_values, num_indexes, num_chars);
00206     }
00207 
00214   Teuchos::RCP<ReductTarget> reduct_obj_create() const
00215     {
00216       return reduct_obj_create_impl();
00217     }
00218 
00224   void reduce_reduct_objs(
00225     const ReductTarget& in_reduct_obj, const Ptr<ReductTarget>& inout_reduct_obj
00226     ) const
00227     {
00228       reduce_reduct_objs_impl( in_reduct_obj, inout_reduct_obj );
00229     }
00230 
00238   void reduct_obj_reinit( const Ptr<ReductTarget> &reduct_obj ) const
00239     {
00240       reduct_obj_reinit_impl(reduct_obj);
00241     }
00242 
00252   void extract_reduct_obj_state(
00253     const ReductTarget &reduct_obj,
00254     const ArrayView<primitive_value_type> &value_data,
00255     const ArrayView<index_type> &index_data,
00256     const ArrayView<char_type> &char_data
00257     ) const
00258     {
00259       extract_reduct_obj_state_impl( reduct_obj,
00260         value_data, index_data, char_data );
00261     }
00262 
00268   void load_reduct_obj_state(
00269     const ArrayView<const primitive_value_type> &value_data,
00270     const ArrayView<const index_type> &index_data,
00271     const ArrayView<const char_type> &char_data,
00272     const Ptr<ReductTarget> &reduct_obj
00273     ) const
00274     {
00275       load_reduct_obj_state_impl( value_data, index_data, char_data, reduct_obj );
00276     }
00277 
00279 
00282 
00292   std::string op_name() const
00293     {
00294       return op_name_impl();
00295     }
00296 
00297   // 2007/11/14: rabartl: ToDo: Above: change to return std::string.  Don't
00298   // bother deprecating the old function since you can't really do it very
00299   // well.
00300 
00306   bool coord_invariant() const
00307     {
00308       return coord_invariant_impl();
00309     }
00310 
00321   Range1D range() const
00322     {
00323       return range_impl();
00324     }
00325 
00394   void apply_op(
00395     const ArrayView<const ConstSubVectorView<Scalar> > &sub_vecs,
00396     const ArrayView<const SubVectorView<Scalar> > &targ_sub_vecs,
00397     const Ptr<ReductTarget> &reduct_obj
00398     ) const
00399     {
00400       apply_op_impl(sub_vecs, targ_sub_vecs, reduct_obj);
00401     }
00402 
00404 
00405 protected:
00406 
00409 
00411   virtual void get_reduct_type_num_entries_impl(
00412     const Ptr<int> &num_values,
00413     const Ptr<int> &num_indexes,
00414     const Ptr<int> &num_chars
00415     ) const;
00416 
00418   virtual Teuchos::RCP<ReductTarget> reduct_obj_create_impl() const;
00419 
00421   virtual void reduce_reduct_objs_impl(
00422     const ReductTarget& in_reduct_obj, const Ptr<ReductTarget>& inout_reduct_obj
00423     ) const;
00424 
00426   virtual void reduct_obj_reinit_impl( const Ptr<ReductTarget> &reduct_obj ) const;
00427 
00429   virtual void extract_reduct_obj_state_impl(
00430     const ReductTarget &reduct_obj,
00431     const ArrayView<primitive_value_type> &value_data,
00432     const ArrayView<index_type> &index_data,
00433     const ArrayView<char_type> &char_data
00434     ) const;
00435 
00437   virtual void load_reduct_obj_state_impl(
00438     const ArrayView<const primitive_value_type> &value_data,
00439     const ArrayView<const index_type> &index_data,
00440     const ArrayView<const char_type> &char_data,
00441     const Ptr<ReductTarget> &reduct_obj
00442     ) const;
00443 
00445   virtual std::string op_name_impl() const;
00446 
00448   virtual bool coord_invariant_impl() const;
00449 
00451   virtual Range1D range_impl() const;
00452 
00454   virtual void apply_op_impl(
00455     const ArrayView<const ConstSubVectorView<Scalar> > &sub_vecs,
00456     const ArrayView<const SubVectorView<Scalar> > &targ_sub_vecs,
00457     const Ptr<ReductTarget> &reduct_obj
00458     ) const = 0;
00459 
00461 
00464 
00467   RTOpT( const std::string &op_name_base = "" );
00468 
00470   void setOpNameBase( const std::string &op_name_base );
00471 
00473 
00474 public:
00475 
00478 
00480   RTOP_DEPRECATED void get_reduct_type_num_entries(
00481     int* num_values, int* num_indexes, int* num_chars
00482     ) const
00483     {
00484       using Teuchos::ptr;
00485       get_reduct_type_num_entries_impl(ptr(num_values),
00486         ptr(num_indexes), ptr(num_chars) );
00487     }
00488 
00490   RTOP_DEPRECATED void reduce_reduct_objs(
00491     const ReductTarget& in_reduct_obj, ReductTarget* inout_reduct_obj
00492     ) const
00493     {
00494       reduce_reduct_objs_impl( in_reduct_obj, Teuchos::ptr(inout_reduct_obj) );
00495     }
00496 
00498   RTOP_DEPRECATED void reduct_obj_reinit( ReductTarget* reduct_obj ) const
00499     {
00500       reduct_obj_reinit_impl(Teuchos::ptr(reduct_obj));
00501     }
00502 
00504   RTOP_DEPRECATED void extract_reduct_obj_state(
00505     const ReductTarget &reduct_obj,
00506     int num_values, primitive_value_type value_data[],
00507     int num_indexes, index_type index_data[],
00508     int num_chars, char_type char_data[]
00509     ) const
00510     {
00511       using Teuchos::arrayView;
00512       extract_reduct_obj_state_impl( reduct_obj,
00513         arrayView(value_data, num_values), arrayView(index_data, num_indexes),
00514         arrayView(char_data, num_chars) );
00515     }
00516 
00518   RTOP_DEPRECATED void load_reduct_obj_state(
00519     int num_values, const primitive_value_type value_data[],
00520     int num_indexes, const index_type index_data[],
00521     int num_chars, const char_type char_data[],
00522     ReductTarget *reduct_obj
00523     ) const
00524     {
00525       using Teuchos::arrayView;
00526       load_reduct_obj_state_impl( arrayView(value_data, num_values),
00527         arrayView(index_data, num_indexes), arrayView(char_data, num_chars),
00528         Teuchos::ptr(reduct_obj) );
00529     }
00530 
00532   RTOP_DEPRECATED void apply_op(
00533     const int num_vecs, const ConstSubVectorView<Scalar> sub_vecs[],
00534     const int num_targ_vecs, const SubVectorView<Scalar> targ_sub_vecs[],
00535     ReductTarget *reduct_obj
00536     ) const
00537     {
00538       apply_op_impl(
00539         Teuchos::arrayView(sub_vecs, num_vecs),
00540         Teuchos::arrayView(targ_sub_vecs, num_targ_vecs),
00541         Teuchos::ptr(reduct_obj)
00542         );
00543     }
00544 
00546 
00547 private:
00548 
00549   std::string op_name_;
00550 
00551   void throwNoReductError() const;
00552 
00553 }; // end class RTOpT
00554 
00555 
00556 // 2007/11/14: rabartl: ToDo: Break off an RTOpDefaultBase interface and put
00557 // all default implementation functions in there.
00558 
00559 
00560 } // end namespace RTOpPack
00561 
00562 
00563 #endif // RTOPPACK_RTOP_NEW_T_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines