Thyra Version of the Day
Thyra_apply_op_helper_def.hpp
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //    Thyra: Interfaces and Support for Abstract Numerical Algorithms
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #ifndef THYRA_APPLY_OP_HELPER_HPP
00043 #define THYRA_APPLY_OP_HELPER_HPP
00044 
00045 #include "Thyra_apply_op_helper_decl.hpp"
00046 #include "Thyra_VectorBase.hpp"
00047 #include "Thyra_VectorSpaceBase.hpp"
00048 #include "Thyra_AssertOp.hpp"
00049 #include "Teuchos_Assert.hpp"
00050 #include "Teuchos_as.hpp"
00051 
00052 
00053 template<class Scalar>
00054 void Thyra::apply_op_validate_input(
00055   const std::string &func_name,
00056   const VectorSpaceBase<Scalar> &space,
00057   const RTOpPack::RTOpT<Scalar> &op,
00058   const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
00059   const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
00060   const Ptr<RTOpPack::ReductTarget> &reduct_obj,
00061   const Ordinal global_offset_in
00062   )
00063 {
00064   const int num_vecs = vecs.size();
00065   const int num_targ_vecs = targ_vecs.size();
00066   TEUCHOS_TEST_FOR_EXCEPTION(
00067     global_offset_in < 0, std::logic_error
00068     ,func_name << " : Error! global_offset_in = "
00069     <<global_offset_in<<" is not valid" );
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 Ordinal primary_global_offset_in
00087   )
00088 {
00089   using Teuchos::as;
00090   // Validate primary range arguments
00091   TEUCHOS_TEST_FOR_EXCEPTION(
00092     primary_global_offset_in < 0, std::logic_error
00093     ,func_name << " : Error! primary_global_offset_in = "
00094     <<primary_global_offset_in<<" is not valid" );
00095   // Validate secondary domain arguments
00096   // Validate spaces
00097   for (int k = 0; k < multi_vecs.size(); ++k) {
00098     THYRA_ASSERT_VEC_SPACES(func_name,domain,*multi_vecs[k]->domain());
00099     THYRA_ASSERT_VEC_SPACES(func_name,range,*multi_vecs[k]->range());
00100   }
00101   for (int k = 0; k < targ_multi_vecs.size(); ++k) {
00102     THYRA_ASSERT_VEC_SPACES(func_name,domain,*targ_multi_vecs[k]->domain());
00103     THYRA_ASSERT_VEC_SPACES(func_name,range,*targ_multi_vecs[k]->range());
00104   }
00105 }
00106 
00107 
00108 //
00109 // Explicit instant macro
00110 //
00111 
00112 #define THYRA_APPLY_OP_HELPER_INSTANT(SCALAR) \
00113    \
00114   template void apply_op_validate_input( \
00115     const std::string &func_name, \
00116     const VectorSpaceBase<SCALAR > &space, \
00117     const RTOpPack::RTOpT<SCALAR > &op, \
00118     const ArrayView<const Ptr<const VectorBase<SCALAR > > > &vecs, \
00119     const ArrayView<const Ptr<VectorBase<SCALAR > > > &targ_vecs, \
00120     const Ptr<RTOpPack::ReductTarget> &reduct_obj, \
00121     const Ordinal global_offset_in \
00122     ); \
00123    \
00124   template void apply_op_validate_input( \
00125     const std::string &func_name, \
00126     const VectorSpaceBase<SCALAR > &domain, \
00127     const VectorSpaceBase<SCALAR > &range, \
00128     const RTOpPack::RTOpT<SCALAR > &primary_op, \
00129     const ArrayView<const Ptr<const MultiVectorBase<SCALAR > > > &multi_vecs, \
00130     const ArrayView<const Ptr<MultiVectorBase<SCALAR > > > &targ_multi_vecs, \
00131     const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs, \
00132     const Ordinal primary_global_offset_in \
00133     ); \
00134 
00135 
00136 
00137 #endif // THYRA_APPLY_OP_HELPER_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines