DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_L2ProjectionOperator.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_L2PROJECTIONOPERATOR_HPP
42 #define DTK_L2PROJECTIONOPERATOR_HPP
43 
44 #include "DTK_EntityIterator.hpp"
45 #include "DTK_IntegrationPointSet.hpp"
46 #include "DTK_MapOperator.hpp"
47 #include "DTK_Types.hpp"
48 
49 #include <Teuchos_Array.hpp>
50 #include <Teuchos_ParameterList.hpp>
51 #include <Teuchos_RCP.hpp>
52 
53 #include <Tpetra_CrsMatrix.hpp>
54 
55 #include <Thyra_LinearOpBase.hpp>
56 
57 namespace DataTransferKit
58 {
59 //---------------------------------------------------------------------------//
67 //---------------------------------------------------------------------------//
68 class L2ProjectionOperator : virtual public MapOperator
69 {
70  public:
72  typedef MapOperator Base;
73  typedef typename Base::Root Root;
74  typedef typename Root::scalar_type Scalar;
75  typedef typename Root::local_ordinal_type LO;
76  typedef typename Root::global_ordinal_type GO;
77  typedef typename Base::TpetraMultiVector TpetraMultiVector;
78  typedef typename Base::TpetraMap TpetraMap;
79 
83  L2ProjectionOperator( const Teuchos::RCP<const TpetraMap> &domain_map,
84  const Teuchos::RCP<const TpetraMap> &range_map,
85  const Teuchos::ParameterList &parameters );
86 
87  protected:
88  /*
89  * \brief Setup the map operator from a domain entity set and a range
90  * entity set.
91  *
92  * \param domain_map Parallel map for domain vectors this map should be
93  * compatible with.
94  *
95  * \param domain_function The function that contains the data that will be
96  * sent to the range. Must always be nonnull but the pointers it contains
97  * may be null of no entities are on-process.
98  *
99  * \param range_map Parallel map for range vectors this map should be
100  * compatible with.
101  *
102  * \param range_space The function that will receive the data from the
103  * domain. Must always be nonnull but the pointers it contains to entity
104  * data may be null of no entities are on-process.
105  *
106  * \param parameters Parameters for the setup.
107  */
108  void setupImpl( const Teuchos::RCP<FunctionSpace> &domain_space,
109  const Teuchos::RCP<FunctionSpace> &range_space ) override;
110 
114  void applyImpl(
115  const TpetraMultiVector &X, TpetraMultiVector &Y,
116  Teuchos::ETransp mode = Teuchos::NO_TRANS,
117  double alpha = Teuchos::ScalarTraits<double>::one(),
118  double beta = Teuchos::ScalarTraits<double>::zero() ) const override;
119 
120  /*
121  * \brief Transpose apply option.
122  */
123  bool hasTransposeApplyImpl() const override;
124 
125  private:
126  // Assemble the mass matrix and range integration point set.
127  void assembleMassMatrix(
128  const Teuchos::RCP<FunctionSpace> &range_space,
129  EntityIterator range_iterator,
130  Teuchos::RCP<Tpetra::CrsMatrix<double, LO, GO>> &mass_matrix,
131  Teuchos::RCP<IntegrationPointSet> &range_ip_set );
132 
133  // Assemble the coupling matrix.
134  void assembleCouplingMatrix(
135  const Teuchos::RCP<FunctionSpace> &domain_space,
136  EntityIterator domain_iterator,
137  const Teuchos::RCP<IntegrationPointSet> &range_ip_set,
138  Teuchos::RCP<Tpetra::CrsMatrix<double, LO, GO>> &coupling_matrix );
139 
140  private:
141  // Order of numerical integration for assembly of the Galerkin problem.
142  int d_int_order;
143 
144  // Search sublist.
145  Teuchos::ParameterList d_search_list;
146 
147  // Coupling matrix.
148  Teuchos::RCP<const Thyra::LinearOpBase<double>> d_l2_operator;
149 };
150 
151 //---------------------------------------------------------------------------//
152 
153 } // end namespace DataTransferKit
154 
155 //---------------------------------------------------------------------------//
156 
157 #endif // end DTK_L2PROJECTIONOPERATOR_HPP
158 
159 //---------------------------------------------------------------------------//
160 // end DTK_L2ProjectionOperator.hpp
161 //---------------------------------------------------------------------------//
Entity iterator interface.
L2ProjectionOperator(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.