Fundamental Vector Reduction/Transformation Operator (RTOp) Interfaces  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RTOpPack_RTOpT_def.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // RTOp: Interfaces and Support Software for Vector Reduction Transformation
5 // Operations
6 // Copyright (2006) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
39 //
40 // ***********************************************************************
41 // @HEADER
42 
43 #ifndef RTOPPACK_RTOP_NEW_T_HPP
44 #define RTOPPACK_RTOP_NEW_T_HPP
45 
46 #include "RTOpPack_RTOpT_decl.hpp"
47 #include "Teuchos_Workspace.hpp"
48 #include "Teuchos_Assert.hpp"
49 #include "Teuchos_ScalarTraits.hpp"
50 
51 
52 namespace RTOpPack {
53 
54 
55 // Protected functions to be overridden by subclasses
56 
57 
58 template<class Scalar>
60  const Ptr<int> &num_values,
61  const Ptr<int> &num_indexes,
62  const Ptr<int> &num_chars
63  ) const
64 {
65  *num_values = 0;
66  *num_indexes = 0;
67  *num_chars = 0;
68 }
69 
70 
71 template<class Scalar>
74 {
75  return Teuchos::null;
76 }
77 
78 
79 template<class Scalar>
81  const ReductTarget& /* in_reduct_obj */, const Ptr<ReductTarget>& /* inout_reduct_obj */
82  ) const
83 {
84  throwNoReductError();
85 }
86 
87 
88 template<class Scalar>
90  const Ptr<ReductTarget> &/* reduct_obj */ ) const
91 {
92  throwNoReductError();
93 }
94 
95 
96 template<class Scalar>
98  const ReductTarget &/* reduct_obj */,
99  const ArrayView<primitive_value_type> &/* value_data */,
100  const ArrayView<index_type> &/* index_data */,
101  const ArrayView<char_type> &/* char_data */
102  ) const
103 {
104  throwNoReductError();
105 }
106 
107 
108 template<class Scalar>
110  const ArrayView<const primitive_value_type> &/* value_data */,
111  const ArrayView<const index_type> &/* index_data */,
112  const ArrayView<const char_type> &/* char_data */,
113  const Ptr<ReductTarget> &/* reduct_obj */
114  ) const
115 {
116  throwNoReductError();
117 }
118 
119 
120 template<class Scalar>
121 std::string RTOpT<Scalar>::op_name_impl() const
122 {
123  return op_name_;
124 }
125 
126 
127 template<class Scalar>
129 {
130  return true;
131 }
132 
133 
134 template<class Scalar>
136 {
137  return Range1D();
138 }
139 
140 
141 // Nonvirtual protected functions
142 
143 
144 template<class Scalar>
145 RTOpT<Scalar>::RTOpT( const std::string &op_name_base )
146 {
147  setOpNameBase(op_name_base);
148 }
149 
150 
151 template<class Scalar>
152 void RTOpT<Scalar>::setOpNameBase( const std::string &op_name_base )
153 {
154  op_name_ = op_name_base+"<"+ScalarTraits<Scalar>::name()+">";
155 }
156 
157 
158 // private
159 
160 
161 template<class Scalar>
163 {
164  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
165  "Error, no reduction is defined for concrete reduction op \'"
166  << this->description() << "\'!" );
167 }
168 
169 
170 
171 } // end namespace RTOpPack
172 
173 
174 #endif // RTOPPACK_RTOP_NEW_T_HPP
virtual Teuchos::RCP< ReductTarget > reduct_obj_create_impl() const
virtual void reduct_obj_reinit_impl(const Ptr< ReductTarget > &reduct_obj) const
virtual void reduce_reduct_objs_impl(const ReductTarget &in_reduct_obj, const Ptr< ReductTarget > &inout_reduct_obj) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static std::string name()
virtual Range1D range_impl() const
Templated interface to vector reduction/transformation operators {abstract}.
virtual bool coord_invariant_impl() const
virtual void extract_reduct_obj_state_impl(const ReductTarget &reduct_obj, const ArrayView< primitive_value_type > &value_data, const ArrayView< index_type > &index_data, const ArrayView< char_type > &char_data) const
virtual void load_reduct_obj_state_impl(const ArrayView< const primitive_value_type > &value_data, const ArrayView< const index_type > &index_data, const ArrayView< const char_type > &char_data, const Ptr< ReductTarget > &reduct_obj) const
virtual std::string op_name_impl() const
Abstract base class for all reduction objects.
void setOpNameBase(const std::string &op_name_base)
Just set the operator name.
virtual void get_reduct_type_num_entries_impl(const Ptr< int > &num_values, const Ptr< int > &num_indexes, const Ptr< int > &num_chars) const
RTOpT(const std::string &op_name_base="")
Constructor that creates an operator name appended with the type.