RTOp Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RTOpPack_RTOpT_decl.hpp
Go to the documentation of this file.
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 
44 #ifndef RTOPPACK_RTOP_NEW_T_DECL_HPP
45 #define RTOPPACK_RTOP_NEW_T_DECL_HPP
46 
47 
48 #include "RTOpPack_Types.hpp"
49 #include "Teuchos_Describable.hpp"
50 
51 
52 namespace RTOpPack {
53 
54 
58 {};
59 
60 
168 template<class Scalar>
169 class RTOpT : public Teuchos::Describable {
170 public:
171 
174 
178 
180 
183 
200  const Ptr<int> &num_values,
201  const Ptr<int> &num_indexes,
202  const Ptr<int> &num_chars
203  ) const
204  {
205  get_reduct_type_num_entries_impl(num_values, num_indexes, num_chars);
206  }
207 
215  {
216  return reduct_obj_create_impl();
217  }
218 
225  const ReductTarget& in_reduct_obj, const Ptr<ReductTarget>& inout_reduct_obj
226  ) const
227  {
228  reduce_reduct_objs_impl( in_reduct_obj, inout_reduct_obj );
229  }
230 
238  void reduct_obj_reinit( const Ptr<ReductTarget> &reduct_obj ) const
239  {
240  reduct_obj_reinit_impl(reduct_obj);
241  }
242 
253  const ReductTarget &reduct_obj,
254  const ArrayView<primitive_value_type> &value_data,
255  const ArrayView<index_type> &index_data,
256  const ArrayView<char_type> &char_data
257  ) const
258  {
259  extract_reduct_obj_state_impl( reduct_obj,
260  value_data, index_data, char_data );
261  }
262 
269  const ArrayView<const primitive_value_type> &value_data,
270  const ArrayView<const index_type> &index_data,
271  const ArrayView<const char_type> &char_data,
272  const Ptr<ReductTarget> &reduct_obj
273  ) const
274  {
275  load_reduct_obj_state_impl( value_data, index_data, char_data, reduct_obj );
276  }
277 
279 
282 
292  std::string op_name() const
293  {
294  return op_name_impl();
295  }
296 
297  // 2007/11/14: rabartl: ToDo: Above: change to return std::string. Don't
298  // bother deprecating the old function since you can't really do it very
299  // well.
300 
306  bool coord_invariant() const
307  {
308  return coord_invariant_impl();
309  }
310 
321  Range1D range() const
322  {
323  return range_impl();
324  }
325 
394  void apply_op(
395  const ArrayView<const ConstSubVectorView<Scalar> > &sub_vecs,
396  const ArrayView<const SubVectorView<Scalar> > &targ_sub_vecs,
397  const Ptr<ReductTarget> &reduct_obj
398  ) const
399  {
400  apply_op_impl(sub_vecs, targ_sub_vecs, reduct_obj);
401  }
402 
404 
405 protected:
406 
409 
412  const Ptr<int> &num_values,
413  const Ptr<int> &num_indexes,
414  const Ptr<int> &num_chars
415  ) const;
416 
419 
421  virtual void reduce_reduct_objs_impl(
422  const ReductTarget& in_reduct_obj, const Ptr<ReductTarget>& inout_reduct_obj
423  ) const;
424 
426  virtual void reduct_obj_reinit_impl( const Ptr<ReductTarget> &reduct_obj ) const;
427 
429  virtual void extract_reduct_obj_state_impl(
430  const ReductTarget &reduct_obj,
431  const ArrayView<primitive_value_type> &value_data,
432  const ArrayView<index_type> &index_data,
433  const ArrayView<char_type> &char_data
434  ) const;
435 
437  virtual void load_reduct_obj_state_impl(
438  const ArrayView<const primitive_value_type> &value_data,
439  const ArrayView<const index_type> &index_data,
440  const ArrayView<const char_type> &char_data,
441  const Ptr<ReductTarget> &reduct_obj
442  ) const;
443 
445  virtual std::string op_name_impl() const;
446 
448  virtual bool coord_invariant_impl() const;
449 
451  virtual Range1D range_impl() const;
452 
454  virtual void apply_op_impl(
455  const ArrayView<const ConstSubVectorView<Scalar> > &sub_vecs,
456  const ArrayView<const SubVectorView<Scalar> > &targ_sub_vecs,
457  const Ptr<ReductTarget> &reduct_obj
458  ) const = 0;
459 
461 
464 
467  RTOpT( const std::string &op_name_base = "" );
468 
470  void setOpNameBase( const std::string &op_name_base );
471 
473 
474 public:
475 
476 
477 private:
478 
479  std::string op_name_;
480 
481  void throwNoReductError() const;
482 
483 }; // end class RTOpT
484 
485 
486 // 2007/11/14: rabartl: ToDo: Break off an RTOpDefaultBase interface and put
487 // all default implementation functions in there.
488 
489 
490 } // end namespace RTOpPack
491 
492 
493 #endif // RTOPPACK_RTOP_NEW_T_DECL_HPP
std::string op_name() const
Return the name (as a null-terminated C-style string) of the operator.
virtual Teuchos::RCP< ReductTarget > reduct_obj_create_impl() const
Range1D range() const
Returns the continuous range of elements that this operator is defined over.
virtual void reduct_obj_reinit_impl(const Ptr< ReductTarget > &reduct_obj) const
Class for a changeable sub-vector.
virtual void reduce_reduct_objs_impl(const ReductTarget &in_reduct_obj, const Ptr< ReductTarget > &inout_reduct_obj) const
void get_reduct_type_num_entries(const Ptr< int > &num_values, const Ptr< int > &num_indexes, const Ptr< int > &num_chars) const
Get the number of entries of each basic data type in the externalized state for a reduction object fo...
void throwNoReductError() const
bool coord_invariant() const
Returns true if this operator is coordinate invariant.
Class for a non-changeable sub-vector.
virtual Range1D range_impl() const
Templated interface to vector reduction/transformation operators {abstract}.
virtual void apply_op_impl(const ArrayView< const ConstSubVectorView< Scalar > > &sub_vecs, const ArrayView< const SubVectorView< Scalar > > &targ_sub_vecs, const Ptr< ReductTarget > &reduct_obj) const =0
virtual bool coord_invariant_impl() const
void extract_reduct_obj_state(const ReductTarget &reduct_obj, const ArrayView< primitive_value_type > &value_data, const ArrayView< index_type > &index_data, const ArrayView< char_type > &char_data) const
Extract the state of an already created reduction object.
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
void load_reduct_obj_state(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
Load the state of an already created reduction object given arrays of primitive objects.
void reduct_obj_reinit(const Ptr< ReductTarget > &reduct_obj) const
Reinitialize an already created reduction object.
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
PrimitiveTypeTraits< Scalar, Scalar >::primitiveType primitive_value_type
virtual std::string op_name_impl() const
Abstract base class for all reduction objects.
void reduce_reduct_objs(const ReductTarget &in_reduct_obj, const Ptr< ReductTarget > &inout_reduct_obj) const
Reduce intermediate reduction target objects.
void setOpNameBase(const std::string &op_name_base)
Just set the operator name.
Teuchos::RCP< ReductTarget > reduct_obj_create() const
Creates a new reduction target object initialized and ready to be used in a reduction.
void apply_op(const ArrayView< const ConstSubVectorView< Scalar > > &sub_vecs, const ArrayView< const SubVectorView< Scalar > > &targ_sub_vecs, const Ptr< ReductTarget > &reduct_obj) const
Apply the reduction/transformation operator to a set of sub-vectors.
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.