Thyra Version of the Day
Loading...
Searching...
No Matches
Thyra_apply_op_helper_def.hpp
1// @HEADER
2// *****************************************************************************
3// Thyra: Interfaces and Support for Abstract Numerical Algorithms
4//
5// Copyright 2004 NTESS and the Thyra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef THYRA_APPLY_OP_HELPER_HPP
11#define THYRA_APPLY_OP_HELPER_HPP
12
13#include "Thyra_apply_op_helper_decl.hpp"
14#include "Thyra_VectorBase.hpp"
15#include "Thyra_VectorSpaceBase.hpp"
16#include "Thyra_AssertOp.hpp"
17#include "Teuchos_Assert.hpp"
18#include "Teuchos_as.hpp"
19
20
21template<class Scalar>
23 const std::string &func_name,
24 const VectorSpaceBase<Scalar> &space,
25 const RTOpPack::RTOpT<Scalar> &/* op */,
26 const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
27 const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
28 const Ptr<RTOpPack::ReductTarget> &/* reduct_obj */,
29 const Ordinal global_offset_in
30 )
31{
32 const int num_vecs = vecs.size();
33 const int num_targ_vecs = targ_vecs.size();
35 global_offset_in < 0, std::logic_error
36 ,func_name << " : Error! global_offset_in = "
37 <<global_offset_in<<" is not valid" );
38 for (int k = 0; k < num_vecs; ++k)
39 THYRA_ASSERT_VEC_SPACES(func_name,space,*vecs[k]->space());
40 for (int k = 0; k < num_targ_vecs; ++k)
41 THYRA_ASSERT_VEC_SPACES(func_name,space,*targ_vecs[k]->space());
42}
43
44
45template<class Scalar>
47 const std::string &func_name,
48 const VectorSpaceBase<Scalar> &domain,
49 const VectorSpaceBase<Scalar> &range,
50 const RTOpPack::RTOpT<Scalar> &/* primary_op */,
51 const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
52 const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
53 const ArrayView<const Ptr<RTOpPack::ReductTarget> > &/* reduct_objs */,
54 const Ordinal primary_global_offset_in
55 )
56{
57 using Teuchos::as;
58 // Validate primary range arguments
60 primary_global_offset_in < 0, std::logic_error
61 ,func_name << " : Error! primary_global_offset_in = "
62 <<primary_global_offset_in<<" is not valid" );
63 // Validate secondary domain arguments
64 // Validate spaces
65 for (int k = 0; k < multi_vecs.size(); ++k) {
66 THYRA_ASSERT_VEC_SPACES(func_name,domain,*multi_vecs[k]->domain());
67 THYRA_ASSERT_VEC_SPACES(func_name,range,*multi_vecs[k]->range());
68 }
69 for (int k = 0; k < targ_multi_vecs.size(); ++k) {
70 THYRA_ASSERT_VEC_SPACES(func_name,domain,*targ_multi_vecs[k]->domain());
71 THYRA_ASSERT_VEC_SPACES(func_name,range,*targ_multi_vecs[k]->range());
72 }
73}
74
75
76//
77// Explicit instant macro
78//
79
80#define THYRA_APPLY_OP_HELPER_INSTANT(SCALAR) \
81 \
82 template void apply_op_validate_input( \
83 const std::string &func_name, \
84 const VectorSpaceBase<SCALAR > &space, \
85 const RTOpPack::RTOpT<SCALAR > &op, \
86 const ArrayView<const Ptr<const VectorBase<SCALAR > > > &vecs, \
87 const ArrayView<const Ptr<VectorBase<SCALAR > > > &targ_vecs, \
88 const Ptr<RTOpPack::ReductTarget> &reduct_obj, \
89 const Ordinal global_offset_in \
90 ); \
91 \
92 template void apply_op_validate_input( \
93 const std::string &func_name, \
94 const VectorSpaceBase<SCALAR > &domain, \
95 const VectorSpaceBase<SCALAR > &range, \
96 const RTOpPack::RTOpT<SCALAR > &primary_op, \
97 const ArrayView<const Ptr<const MultiVectorBase<SCALAR > > > &multi_vecs, \
98 const ArrayView<const Ptr<MultiVectorBase<SCALAR > > > &targ_multi_vecs, \
99 const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs, \
100 const Ordinal primary_global_offset_in \
101 ); \
102
103
104
105#endif // THYRA_APPLY_OP_HELPER_HPP
Interface for a collection of column vectors called a multi-vector.
Abstract interface for finite-dimensional dense vectors.
Abstract interface for objects that represent a space for vectors.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
#define THYRA_ASSERT_VEC_SPACES(FUNC_NAME, VS1, VS2)
This is a very useful macro that should be used to validate that two vector spaces are compatible.
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
void apply_op_validate_input(const std::string &func_name, const VectorSpaceBase< Scalar > &space, const RTOpPack::RTOpT< Scalar > &op, const ArrayView< const Ptr< const VectorBase< Scalar > > > &vecs, const ArrayView< const Ptr< VectorBase< Scalar > > > &targ_vecs, const Ptr< RTOpPack::ReductTarget > &reduct_obj, const Ordinal global_offset)
Validate the inputs to VectorBase::applyOp().
TypeTo as(const TypeFrom &t)