RTOpPack_RTOpT.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 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00026 // 
00027 // ***********************************************************************
00028 // @HEADER
00029 
00030 #ifndef RTOPPACK_RTOP_NEW_T_HPP
00031 #define RTOPPACK_RTOP_NEW_T_HPP
00032 
00033 #include "RTOpPack_RTOpTDecl.hpp"
00034 #include "Teuchos_Workspace.hpp"
00035 #include "Teuchos_TestForException.hpp"
00036 #include "Teuchos_ScalarTraits.hpp"
00037 
00038 namespace RTOpPack {
00039 
00040 template<class Scalar>
00041 RTOpT<Scalar>::RTOpT( const std::string &op_name_base )
00042   :op_name_(op_name_base + std::string(Teuchos::ScalarTraits<Scalar>::name()))
00043 {}
00044 
00045 // Reduction object functions
00046 
00047 template<class Scalar>
00048 void RTOpT<Scalar>::get_reduct_type_num_entries(
00049   int*   num_values
00050   ,int*  num_indexes
00051   ,int*  num_chars
00052   ) const
00053 {
00054 #ifdef RTOp_DEBUG
00055   TEST_FOR_EXCEPTION( !num_values, std::logic_error, "Error!" );
00056   TEST_FOR_EXCEPTION( !num_indexes, std::logic_error, "Error!"  );
00057   TEST_FOR_EXCEPTION( !num_chars, std::logic_error, "Error!"  );
00058 #endif
00059   *num_values  = 0;
00060   *num_indexes = 0;
00061   *num_chars   = 0;
00062 }
00063 
00064 template<class Scalar>
00065 Teuchos::RefCountPtr<ReductTarget>
00066 RTOpT<Scalar>::reduct_obj_create() const
00067 {
00068   return Teuchos::null;
00069 }
00070 
00071 template<class Scalar>
00072 void RTOpT<Scalar>::reduce_reduct_objs(
00073   const ReductTarget& in_reduct_obj, ReductTarget* inout_reduct_obj
00074   ) const
00075 {
00076   TEST_FOR_EXCEPTION(true,std::logic_error,"Error, should not call!");
00077 }
00078 
00079 template<class Scalar>
00080 void RTOpT<Scalar>::reduct_obj_reinit( ReductTarget* reduct_obj ) const
00081 {
00082   TEST_FOR_EXCEPTION(true,std::logic_error,"Error, should not call!");
00083 }
00084 
00085 template<class Scalar>
00086 void RTOpT<Scalar>::extract_reduct_obj_state(
00087   const ReductTarget     &reduct_obj
00088   ,int                      num_values
00089   ,primitive_value_type     value_data[]
00090   ,int                      num_indexes
00091   ,index_type               index_data[]
00092   ,int                      num_chars
00093   ,char_type                char_data[]
00094   ) const
00095 {
00096   TEST_FOR_EXCEPTION(true,std::logic_error,"Error, should not call!");
00097 }
00098 
00099 template<class Scalar>
00100 void RTOpT<Scalar>::load_reduct_obj_state(
00101   int                            num_values
00102   ,const primitive_value_type    value_data[]
00103   ,int                           num_indexes
00104   ,const index_type              index_data[]
00105   ,int                           num_chars
00106   ,const char_type               char_data[]
00107   ,ReductTarget               *reduct_obj
00108   ) const
00109 {
00110   TEST_FOR_EXCEPTION(true,std::logic_error,"Error, should not call!");
00111 }
00112 
00113 // Operator functions
00114 
00115 template<class Scalar>
00116 const char* RTOpT<Scalar>::op_name() const
00117 {
00118   return op_name_.c_str();
00119 }
00120 
00121 template<class Scalar>
00122 RTOpT<Scalar>& RTOpT<Scalar>::operator=(const RTOpT<Scalar>& op)
00123 {
00124   using Teuchos::Workspace;
00125   Teuchos::WorkspaceStore* wss = Teuchos::get_default_workspace_store().get();
00126   int num_values = 0, num_indexes = 0, num_chars = 0;
00127   op.get_op_type_num_entries( &num_values, &num_indexes, &num_chars );
00128   Workspace<primitive_value_type> value_data(wss,num_values,false);
00129   Workspace<index_type>           index_data(wss,num_indexes,false);
00130   Workspace<char_type>            char_data(wss,num_chars,false);
00131   op.extract_op_state(
00132     num_values,   num_values  ? &value_data[0] : NULL
00133     ,num_indexes, num_indexes ? &index_data[0] : NULL
00134     ,num_chars,   num_chars   ? &char_data[0]  : NULL
00135     );
00136   this->load_op_state(
00137     num_values,   num_values  ? &value_data[0] : NULL
00138     ,num_indexes, num_indexes ? &index_data[0] : NULL
00139     ,num_chars,   num_chars   ? &char_data[0]  : NULL
00140     );
00141   return *this;
00142 }
00143 
00144 template<class Scalar>
00145 void RTOpT<Scalar>::get_op_type_num_entries(
00146   int*  num_values
00147   ,int* num_indexes
00148   ,int* num_chars
00149   ) const
00150 {
00151 #ifdef RTOp_DEBUG
00152   TEST_FOR_EXCEPTION( !num_values, std::logic_error, "Error!" );
00153   TEST_FOR_EXCEPTION( !num_indexes, std::logic_error, "Error!"  );
00154   TEST_FOR_EXCEPTION( !num_chars, std::logic_error, "Error!"  );
00155 #endif
00156   *num_values  = 0;
00157   *num_indexes = 0;
00158   *num_chars   = 0;
00159 }
00160 
00161 template<class Scalar>
00162 void RTOpT<Scalar>::extract_op_state(
00163   int                             num_values
00164   ,primitive_value_type           value_data[]
00165   ,int                            num_indexes
00166   ,index_type                     index_data[]
00167   ,int                            num_chars
00168   ,char_type                      char_data[]
00169   ) const
00170 {
00171   TEST_FOR_EXCEPTION(true,std::logic_error,"Error, should not call!");
00172 }
00173 
00174 template<class Scalar>
00175 void RTOpT<Scalar>::load_op_state(
00176   int                           num_values
00177   ,const primitive_value_type   value_data[]
00178   ,int                          num_indexes
00179   ,const index_type             index_data[]
00180   ,int                          num_chars
00181   ,const char_type              char_data[]
00182   )
00183 {
00184   TEST_FOR_EXCEPTION(true,std::logic_error,"Error, should not call!");
00185 }
00186 
00187 template<class Scalar>
00188 bool RTOpT<Scalar>::coord_invariant() const
00189 {
00190   return true;
00191 }
00192 
00193 } // end namespace RTOpPack
00194 
00195 #endif // RTOPPACK_RTOP_NEW_T_HPP

Generated on Thu Sep 18 12:30:42 2008 for RTOp Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1