Fundamental Vector Reduction/Transformation Operator (RTOp) Interfaces Version of the Day
Loading...
Searching...
No Matches
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
52namespace RTOpPack {
53
54
55// Protected functions to be overridden by subclasses
56
57
58template<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
71template<class Scalar>
72Teuchos::RCP<ReductTarget>
74{
75 return Teuchos::null;
76}
77
78
79template<class Scalar>
81 const ReductTarget& /* in_reduct_obj */, const Ptr<ReductTarget>& /* inout_reduct_obj */
82 ) const
83{
84 throwNoReductError();
85}
86
87
88template<class Scalar>
90 const Ptr<ReductTarget> &/* reduct_obj */ ) const
91{
92 throwNoReductError();
93}
94
95
96template<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
108template<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
120template<class Scalar>
122{
123 return op_name_;
124}
125
126
127template<class Scalar>
129{
130 return true;
131}
132
133
134template<class Scalar>
136{
137 return Range1D();
138}
139
140
141// Nonvirtual protected functions
142
143
144template<class Scalar>
145RTOpT<Scalar>::RTOpT( const std::string &op_name_base )
146{
147 setOpNameBase(op_name_base);
148}
149
150
151template<class Scalar>
152void 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
161template<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
Templated interface to vector reduction/transformation operators {abstract}.
virtual std::string op_name_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 reduce_reduct_objs_impl(const ReductTarget &in_reduct_obj, const Ptr< ReductTarget > &inout_reduct_obj) const
virtual Teuchos::RCP< ReductTarget > reduct_obj_create_impl() const
virtual void reduct_obj_reinit_impl(const Ptr< ReductTarget > &reduct_obj) const
virtual Range1D range_impl() const
virtual void get_reduct_type_num_entries_impl(const Ptr< int > &num_values, const Ptr< int > &num_indexes, const Ptr< int > &num_chars) 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
void setOpNameBase(const std::string &op_name_base)
Just set the operator name.
virtual bool coord_invariant_impl() const
RTOpT(const std::string &op_name_base="")
Constructor that creates an operator name appended with the type.
Abstract base class for all reduction objects.