DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_NodeToNodeOperator.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 /*
3  Copyright (c) 2012, Stuart R. Slattery
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are
8  met:
9 
10  *: Redistributions of source code must retain the above copyright
11  notice, this list of conditions and the following disclaimer.
12 
13  *: Redistributions in binary form must reproduce the above copyright
14  notice, this list of conditions and the following disclaimer in the
15  documentation and/or other materials provided with the distribution.
16 
17  *: Neither the name of the University of Wisconsin - Madison nor the
18  names of its contributors may be used to endorse or promote products
19  derived from this software without specific prior written permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 //---------------------------------------------------------------------------//
39 //---------------------------------------------------------------------------//
40 
41 #ifndef DTK_NODETONODE_HPP
42 #define DTK_NODETONODE_HPP
43 
44 #include "DTK_MapOperator.hpp"
45 
46 #include <Teuchos_Array.hpp>
47 #include <Teuchos_ArrayView.hpp>
48 #include <Teuchos_Comm.hpp>
49 #include <Teuchos_RCP.hpp>
50 
51 #include <Tpetra_CrsMatrix.hpp>
52 
53 namespace DataTransferKit
54 {
55 //---------------------------------------------------------------------------//
63 //---------------------------------------------------------------------------//
64 template <int DIM>
65 class NodeToNodeOperator : virtual public MapOperator
66 {
67  public:
69  typedef MapOperator Base;
71  typedef typename Base::Root Root;
72  typedef typename Root::scalar_type Scalar;
73  typedef typename Root::local_ordinal_type LO;
74  typedef typename Root::global_ordinal_type GO;
75  typedef typename Base::TpetraMultiVector TpetraMultiVector;
76  typedef typename Base::TpetraMap TpetraMap;
78 
88  NodeToNodeOperator( const Teuchos::RCP<const TpetraMap> &domain_map,
89  const Teuchos::RCP<const TpetraMap> &range_map,
90  const Teuchos::ParameterList &parameters );
91 
92  protected:
93  /*
94  * \brief Setup the map operator from a domain entity set and a range
95  * entity set.
96  *
97  * \param domain_function The function that contains the data that will be
98  * sent to the range. Must always be nonnull but the pointers it contains
99  * may be null of no entities are on-process.
100  *
101  * \param range_space The function that will receive the data from the
102  * domain. Must always be nonnull but the pointers it contains to entity
103  * data may be null of no entities are on-process.
104  *
105  * \param parameters Parameters for the setup.
106  */
107  void setupImpl( const Teuchos::RCP<FunctionSpace> &domain_space,
108  const Teuchos::RCP<FunctionSpace> &range_space ) override;
109 
113  void applyImpl(
114  const TpetraMultiVector &X, TpetraMultiVector &Y,
115  Teuchos::ETransp mode = Teuchos::NO_TRANS,
116  double alpha = Teuchos::ScalarTraits<double>::one(),
117  double beta = Teuchos::ScalarTraits<double>::zero() ) const override;
118 
119  /*
120  * \brief Transpose apply option.
121  */
122  bool hasTransposeApplyImpl() const override;
123 
124  private:
125  // Extract node coordinates and ids from an iterator.
126  void getNodeCoordsAndIds( const Teuchos::RCP<FunctionSpace> &space,
127  Teuchos::ArrayRCP<double> &centers,
128  Teuchos::ArrayRCP<GO> &support_ids ) const;
129 
130  private:
131  // Exporter
132  Teuchos::RCP<Tpetra::CrsMatrix<Scalar, LO, GO>> d_coupling_matrix;
133 };
134 
135 //---------------------------------------------------------------------------//
136 
137 } // end namespace DataTransferKit
138 
139 //---------------------------------------------------------------------------//
140 
141 #endif // end DTK_NODETONODE_HPP
142 
143 //---------------------------------------------------------------------------//
144 // end DTK_NodeToNodeOperator.hpp
145 //---------------------------------------------------------------------------//
NodeToNodeOperator(const Teuchos::RCP< const TpetraMap > &domain_map, const Teuchos::RCP< const TpetraMap > &range_map, const Teuchos::ParameterList &parameters)
Constructor.
void applyImpl(const TpetraMultiVector &X, TpetraMultiVector &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, double alpha=Teuchos::ScalarTraits< double >::one(), double beta=Teuchos::ScalarTraits< double >::zero()) const override
Apply the operator.
DTK_BasicEntitySet.cpp.
Parallel moving least square interpolator MapOperator implementation.