DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_ConsistentInterpolationOperator.hpp
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_CONSISTENTINTERPOLATIONOPERATOR_HPP
42 #define DTK_CONSISTENTINTERPOLATIONOPERATOR_HPP
43 
44 #include "DTK_MapOperator.hpp"
45 #include "DTK_Types.hpp"
46 
47 #include <Teuchos_Array.hpp>
48 #include <Teuchos_ParameterList.hpp>
49 #include <Teuchos_RCP.hpp>
50 
51 #include <Tpetra_CrsMatrix.hpp>
52 #include <Tpetra_Map.hpp>
53 #include <Tpetra_Vector.hpp>
54 
55 namespace DataTransferKit
56 {
57 //---------------------------------------------------------------------------//
64 //---------------------------------------------------------------------------//
65 class ConsistentInterpolationOperator : virtual public MapOperator
66 {
67  public:
69  typedef MapOperator Base;
70  typedef typename Base::Root Root;
71  typedef typename Root::scalar_type Scalar;
72  typedef typename Root::local_ordinal_type LO;
73  typedef typename Root::global_ordinal_type GO;
74  typedef typename Base::TpetraMultiVector TpetraMultiVector;
75  typedef typename Base::TpetraMap TpetraMap;
76 
81  const Teuchos::RCP<const TpetraMap> &domain_map,
82  const Teuchos::RCP<const TpetraMap> &range_map,
83  const Teuchos::ParameterList &parameters );
84 
92  Teuchos::ArrayView<const EntityId> getMissedRangeEntityIds() const;
93 
94  protected:
95  /*
96  * \brief Setup the map operator from a domain entity set and a range
97  * entity set.
98  *
99  * \param domain_map Parallel map for domain vectors this map should be
100  * compatible with.
101  *
102  * \param domain_function The function that contains the data that will be
103  * sent to the range. Must always be nonnull but the pointers it contains
104  * may be null of no entities are on-process.
105  *
106  * \param range_map Parallel map for range vectors this map should be
107  * compatible with.
108  *
109  * \param range_space The function that will receive the data from the
110  * domain. Must always be nonnull but the pointers it contains to entity
111  * data may be null of no entities are on-process.
112  *
113  * \param parameters Parameters for the setup.
114  */
115  void setupImpl( const Teuchos::RCP<FunctionSpace> &domain_space,
116  const Teuchos::RCP<FunctionSpace> &range_space ) override;
117 
121  void applyImpl(
122  const TpetraMultiVector &X, TpetraMultiVector &Y,
123  Teuchos::ETransp mode = Teuchos::NO_TRANS,
124  double alpha = Teuchos::ScalarTraits<double>::one(),
125  double beta = Teuchos::ScalarTraits<double>::zero() ) const override;
126 
127  /*
128  * \brief Transpose apply option.
129  */
130  bool hasTransposeApplyImpl() const override;
131 
132  private:
133  // Range entity topological dimension. Default is 0 (vertex).
134  int d_range_entity_dim;
135 
136  // Boolean for keeping the original range data when range entities are not
137  // mapped.
138  bool d_keep_missed_sol;
139 
140  // Search sublist.
141  Teuchos::ParameterList d_search_list;
142 
143  // The coupling matrix.
144  Teuchos::RCP<Tpetra::CrsMatrix<Scalar, LO, GO>> d_coupling_matrix;
145 
146  // An array of range entity ids that were not mapped during the last call
147  // to setup.
148  Teuchos::Array<EntityId> d_missed_range_entity_ids;
149 
150  // The missed range entity update vector.
151  Teuchos::RCP<Tpetra::Vector<Scalar, LO, GO>> d_keep_range_vec;
152 };
153 
154 //---------------------------------------------------------------------------//
155 
156 } // end namespace DataTransferKit
157 
158 //---------------------------------------------------------------------------//
159 
160 #endif // end DTK_CONSISTENTINTERPOLATIONOPERATOR_HPP
161 
162 //---------------------------------------------------------------------------//
163 // end DTK_ConsistentInterpolationOperator.hpp
164 //---------------------------------------------------------------------------//
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.
ConsistentInterpolationOperator(const Teuchos::RCP< const TpetraMap > &domain_map, const Teuchos::RCP< const TpetraMap > &range_map, const Teuchos::ParameterList &parameters)
Constructor.
Teuchos::ArrayView< const EntityId > getMissedRangeEntityIds() const
Return the ids of the range entities that were not mapped during the last setup phase (i...
DTK_BasicEntitySet.cpp.