DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_CenterDistributor.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_CENTERDISTRIBUTOR_HPP
42 #define DTK_CENTERDISTRIBUTOR_HPP
43 
44 #include "DTK_CloudDomain.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_Distributor.hpp>
52 
53 namespace DataTransferKit
54 {
55 //---------------------------------------------------------------------------//
64 //---------------------------------------------------------------------------//
65 template <int DIM>
67 {
68  public:
69  // Constructor.
70  CenterDistributor( const Teuchos::RCP<const Teuchos::Comm<int>> &comm,
71  const Teuchos::ArrayView<const double> &source_centers,
72  const Teuchos::ArrayView<const double> &target_centers,
73  const double radius,
74  Teuchos::Array<double> &target_decomp_source_centers );
75 
76  // Get the number of source centers that will be distributed from this
77  // process.
78  int getNumExports() const { return d_num_exports; }
79 
80  // Get the number of source centers that will be distributed to this
81  // process.
82  int getNumImports() const { return d_num_imports; }
83 
84  // Given a set of scalar values at the given source centers in the source
85  // decomposition, distribute them to the target decomposition.
86  template <class T>
87  void distribute( const Teuchos::ArrayView<const T> &source_decomp_data,
88  const Teuchos::ArrayView<T> &target_decomp_data ) const;
89 
90  private:
91  // Compute the domain of the local set of centers.
92  CloudDomain<DIM> localCloudDomain(
93  const Teuchos::ArrayView<const double> &target_centers ) const;
94 
95  private:
96  // Distributor.
97  Teuchos::RCP<Tpetra::Distributor> d_distributor;
98 
99  // Number of source packets that will be imported to this process.
100  int d_num_imports;
101 
102  // Number of source packets that will be exported from this process.
103  int d_num_exports;
104 
105  // Expanded array of local source ids to export.
106  Teuchos::Array<unsigned> d_export_ids;
107 };
108 
109 //---------------------------------------------------------------------------//
110 
111 } // end namespace DataTransferKit
112 
113 //---------------------------------------------------------------------------//
114 // Template includes.
115 //---------------------------------------------------------------------------//
116 
118 
119 //---------------------------------------------------------------------------//
120 
121 #endif // end DTK_CENTERDISTRIBUTOR_HPP
122 
123 //---------------------------------------------------------------------------//
124 // end DTK_CenterDistributor.hpp
125 //---------------------------------------------------------------------------//
CenterDistributor(const Teuchos::RCP< const Teuchos::Comm< int >> &comm, const Teuchos::ArrayView< const double > &source_centers, const Teuchos::ArrayView< const double > &target_centers, const double radius, Teuchos::Array< double > &target_decomp_source_centers)
Constructor.
Global acenter distributor.
Axis-aligned Cartesian cloud domain container.
void distribute(const Teuchos::ArrayView< const T > &source_decomp_data, const Teuchos::ArrayView< T > &target_decomp_data) const
Given a set of scalar values at the given source centers in the source decomposition, distribute them to the target decomposition.
DTK_BasicEntitySet.cpp.
Cloud domain declaration.