00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef THYRA_APPLY_OP_HELPER_HPP
00030 #define THYRA_APPLY_OP_HELPER_HPP
00031
00032 #include "Thyra_apply_op_helper_decl.hpp"
00033 #include "Thyra_VectorBase.hpp"
00034 #include "Thyra_VectorSpaceBase.hpp"
00035 #include "Thyra_AssertOp.hpp"
00036 #include "Teuchos_TestForException.hpp"
00037 #include "Teuchos_as.hpp"
00038
00039
00040 template<class Scalar>
00041 void Thyra::apply_op_validate_input(
00042 const std::string &func_name,
00043 const VectorSpaceBase<Scalar> &space,
00044 const RTOpPack::RTOpT<Scalar> &op,
00045 const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
00046 const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
00047 const Ptr<RTOpPack::ReductTarget> &reduct_obj,
00048 const Index first_ele_offset_in,
00049 const Index sub_dim_in,
00050 const Index global_offset_in
00051 )
00052 {
00053 const int num_vecs = vecs.size();
00054 const int num_targ_vecs = targ_vecs.size();
00055 const Index
00056 dim = space.dim();
00057 TEST_FOR_EXCEPTION(
00058 global_offset_in < 0, std::logic_error
00059 ,func_name << " : Error! global_offset_in = "
00060 <<global_offset_in<<" is not valid" );
00061 TEST_FOR_EXCEPTION(
00062 first_ele_offset_in+1 > dim, std::logic_error
00063 ,func_name << " : Error! first_ele_offset_in = "
00064 <<first_ele_offset_in<<" is not compatible with space.dim() = " << dim );
00065 TEST_FOR_EXCEPTION(
00066 (sub_dim_in > 0 && sub_dim_in > dim-first_ele_offset_in), std::logic_error
00067 ,func_name << " : Error! first_ele_offset_in = "
00068 <<first_ele_offset_in<<" and sub_dim_in = "<<sub_dim_in
00069 <<" is not compatible with space.dim() = " << dim );
00070 for (int k = 0; k < num_vecs; ++k)
00071 THYRA_ASSERT_VEC_SPACES(func_name,space,*vecs[k]->space());
00072 for (int k = 0; k < num_targ_vecs; ++k)
00073 THYRA_ASSERT_VEC_SPACES(func_name,space,*targ_vecs[k]->space());
00074 }
00075
00076
00077 template<class Scalar>
00078 void Thyra::apply_op_validate_input(
00079 const std::string &func_name,
00080 const VectorSpaceBase<Scalar> &domain,
00081 const VectorSpaceBase<Scalar> &range,
00082 const RTOpPack::RTOpT<Scalar> &primary_op,
00083 const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
00084 const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
00085 const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
00086 const Index primary_first_ele_offset_in,
00087 const Index primary_sub_dim_in,
00088 const Index primary_global_offset_in,
00089 const Index secondary_first_ele_offset_in,
00090 const Index secondary_sub_dim_in
00091 )
00092 {
00093 using Teuchos::as;
00094
00095 const Index
00096 range_dim = range.dim();
00097 TEST_FOR_EXCEPTION(
00098 primary_global_offset_in < 0, std::logic_error
00099 ,func_name << " : Error! primary_global_offset_in = "
00100 <<primary_global_offset_in<<" is not valid" );
00101 TEST_FOR_EXCEPTION(
00102 primary_first_ele_offset_in < 0 || range_dim < primary_first_ele_offset_in+1, std::logic_error
00103 ,func_name << " : Error! primary_first_ele_offset_in = "
00104 <<primary_first_ele_offset_in<<" is not compatible with range.dim() = " << range_dim );
00105 TEST_FOR_EXCEPTION(
00106 (primary_sub_dim_in > 0 && primary_sub_dim_in > range_dim-primary_first_ele_offset_in)
00107 , std::logic_error
00108 ,func_name << " : Error! primary_first_ele_offset_in = "
00109 <<primary_first_ele_offset_in<<" and primary_sub_dim_in = "<<primary_sub_dim_in
00110 <<" are not compatible with range.dim() = " << range_dim );
00111
00112 const Index
00113 domain_dim = domain.dim();
00114 TEST_FOR_EXCEPTION(
00115 secondary_first_ele_offset_in < 0 || domain_dim < secondary_first_ele_offset_in+1, std::logic_error
00116 ,func_name << " : Error! secondary_first_ele_offset_in = "
00117 <<secondary_first_ele_offset_in<<" is not compatible with domain.dim() = " << domain_dim );
00118 TEST_FOR_EXCEPTION(
00119 (secondary_sub_dim_in > 0 && secondary_sub_dim_in > domain_dim-secondary_first_ele_offset_in)
00120 , std::logic_error
00121 ,func_name << " : Error! secondary_first_ele_offset_in = "
00122 <<secondary_first_ele_offset_in<<" and secondary_sub_dim_in = "<<secondary_sub_dim_in
00123 <<" are not compatible with domain.dim() = " << domain_dim );
00124
00125 for (int k = 0; k < multi_vecs.size(); ++k) {
00126 THYRA_ASSERT_VEC_SPACES(func_name,domain,*multi_vecs[k]->domain());
00127 THYRA_ASSERT_VEC_SPACES(func_name,range,*multi_vecs[k]->range());
00128 }
00129 for (int k = 0; k < targ_multi_vecs.size(); ++k) {
00130 THYRA_ASSERT_VEC_SPACES(func_name,domain,*targ_multi_vecs[k]->domain());
00131 THYRA_ASSERT_VEC_SPACES(func_name,range,*targ_multi_vecs[k]->range());
00132 }
00133 }
00134
00135
00136 #endif // THYRA_APPLY_OP_HELPER_HPP