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_decl.hpp
1 // @HEADER
2 // *****************************************************************************
3 // RTOp: Interfaces and Support Software for Vector Reduction Transformation
4 // Operations
5 //
6 // Copyright 2006 NTESS and the RTOp contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 
12 #ifndef RTOPPACK_RTOP_NEW_T_DECL_HPP
13 #define RTOPPACK_RTOP_NEW_T_DECL_HPP
14 
15 
16 #include "RTOpPack_Types.hpp"
17 #include "Teuchos_Describable.hpp"
18 
19 
20 namespace RTOpPack {
21 
22 
26 {};
27 
28 
136 template<class Scalar>
137 class RTOpT : public Teuchos::Describable {
138 public:
139 
142 
146 
148 
151 
168  const Ptr<int> &num_values,
169  const Ptr<int> &num_indexes,
170  const Ptr<int> &num_chars
171  ) const
172  {
173  get_reduct_type_num_entries_impl(num_values, num_indexes, num_chars);
174  }
175 
183  {
184  return reduct_obj_create_impl();
185  }
186 
193  const ReductTarget& in_reduct_obj, const Ptr<ReductTarget>& inout_reduct_obj
194  ) const
195  {
196  reduce_reduct_objs_impl( in_reduct_obj, inout_reduct_obj );
197  }
198 
206  void reduct_obj_reinit( const Ptr<ReductTarget> &reduct_obj ) const
207  {
208  reduct_obj_reinit_impl(reduct_obj);
209  }
210 
221  const ReductTarget &reduct_obj,
222  const ArrayView<primitive_value_type> &value_data,
223  const ArrayView<index_type> &index_data,
224  const ArrayView<char_type> &char_data
225  ) const
226  {
227  extract_reduct_obj_state_impl( reduct_obj,
228  value_data, index_data, char_data );
229  }
230 
237  const ArrayView<const primitive_value_type> &value_data,
238  const ArrayView<const index_type> &index_data,
239  const ArrayView<const char_type> &char_data,
240  const Ptr<ReductTarget> &reduct_obj
241  ) const
242  {
243  load_reduct_obj_state_impl( value_data, index_data, char_data, reduct_obj );
244  }
245 
247 
250 
260  std::string op_name() const
261  {
262  return op_name_impl();
263  }
264 
265  // 2007/11/14: rabartl: ToDo: Above: change to return std::string. Don't
266  // bother deprecating the old function since you can't really do it very
267  // well.
268 
274  bool coord_invariant() const
275  {
276  return coord_invariant_impl();
277  }
278 
289  Range1D range() const
290  {
291  return range_impl();
292  }
293 
362  void apply_op(
363  const ArrayView<const ConstSubVectorView<Scalar> > &sub_vecs,
364  const ArrayView<const SubVectorView<Scalar> > &targ_sub_vecs,
365  const Ptr<ReductTarget> &reduct_obj
366  ) const
367  {
368  apply_op_impl(sub_vecs, targ_sub_vecs, reduct_obj);
369  }
370 
372 
373 protected:
374 
377 
380  const Ptr<int> &num_values,
381  const Ptr<int> &num_indexes,
382  const Ptr<int> &num_chars
383  ) const;
384 
387 
389  virtual void reduce_reduct_objs_impl(
390  const ReductTarget& in_reduct_obj, const Ptr<ReductTarget>& inout_reduct_obj
391  ) const;
392 
394  virtual void reduct_obj_reinit_impl( const Ptr<ReductTarget> &reduct_obj ) const;
395 
397  virtual void extract_reduct_obj_state_impl(
398  const ReductTarget &reduct_obj,
399  const ArrayView<primitive_value_type> &value_data,
400  const ArrayView<index_type> &index_data,
401  const ArrayView<char_type> &char_data
402  ) const;
403 
405  virtual void load_reduct_obj_state_impl(
406  const ArrayView<const primitive_value_type> &value_data,
407  const ArrayView<const index_type> &index_data,
408  const ArrayView<const char_type> &char_data,
409  const Ptr<ReductTarget> &reduct_obj
410  ) const;
411 
413  virtual std::string op_name_impl() const;
414 
416  virtual bool coord_invariant_impl() const;
417 
419  virtual Range1D range_impl() const;
420 
422  virtual void apply_op_impl(
423  const ArrayView<const ConstSubVectorView<Scalar> > &sub_vecs,
424  const ArrayView<const SubVectorView<Scalar> > &targ_sub_vecs,
425  const Ptr<ReductTarget> &reduct_obj
426  ) const = 0;
427 
429 
432 
435  RTOpT( const std::string &op_name_base = "" );
436 
438  void setOpNameBase( const std::string &op_name_base );
439 
441 
442 public:
443 
444 
445 private:
446 
447  std::string op_name_;
448 
449  void throwNoReductError() const;
450 
451 }; // end class RTOpT
452 
453 
454 // 2007/11/14: rabartl: ToDo: Break off an RTOpDefaultBase interface and put
455 // all default implementation functions in there.
456 
457 
458 } // end namespace RTOpPack
459 
460 
461 #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...
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.