Reference documentation for deal.II version 9.3.3
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
vector_data_exchange.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2020 - 2021 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16
17#ifndef dealii_matrix_free_vector_data_exchange_h
18#define dealii_matrix_free_vector_data_exchange_h
19
20
21#include <deal.II/base/config.h>
22
24
25
27
28namespace internal
29{
30 namespace MatrixFreeFunctions
31 {
36 namespace VectorDataExchange
37 {
41 class Base
42 {
43 public:
44 virtual ~Base() = default;
45
46 virtual unsigned int
47 locally_owned_size() const = 0;
48
49 virtual unsigned int
50 n_ghost_indices() const = 0;
51
52 virtual unsigned int
53 n_import_indices() const = 0;
54
55 virtual unsigned int
56 n_import_sm_procs() const = 0;
57
59 size() const = 0;
60
61 virtual void
63 const unsigned int communication_channel,
64 const ArrayView<const double> & locally_owned_array,
65 const std::vector<ArrayView<const double>> &shared_arrays,
66 const ArrayView<double> & ghost_array,
67 const ArrayView<double> & temporary_storage,
68 std::vector<MPI_Request> & requests) const = 0;
69
70 virtual void
72 const ArrayView<const double> & locally_owned_array,
73 const std::vector<ArrayView<const double>> &shared_arrays,
74 const ArrayView<double> & ghost_array,
75 std::vector<MPI_Request> & requests) const = 0;
76
77 virtual void
79 const VectorOperation::values vector_operation,
80 const unsigned int communication_channel,
81 const ArrayView<const double> & locally_owned_array,
82 const std::vector<ArrayView<const double>> &shared_arrays,
83 const ArrayView<double> & ghost_array,
84 const ArrayView<double> & temporary_storage,
85 std::vector<MPI_Request> & requests) const = 0;
86
87 virtual void
89 const VectorOperation::values vector_operation,
90 const ArrayView<double> & locally_owned_storage,
91 const std::vector<ArrayView<const double>> &shared_arrays,
92 const ArrayView<double> & ghost_array,
93 const ArrayView<const double> & temporary_storage,
94 std::vector<MPI_Request> & requests) const = 0;
95
96 virtual void
97 reset_ghost_values(const ArrayView<double> &ghost_array) const = 0;
98
99 virtual void
101 const unsigned int communication_channel,
102 const ArrayView<const float> & locally_owned_array,
103 const std::vector<ArrayView<const float>> &shared_arrays,
104 const ArrayView<float> & ghost_array,
105 const ArrayView<float> & temporary_storage,
106 std::vector<MPI_Request> & requests) const = 0;
107
108 virtual void
110 const ArrayView<const float> & locally_owned_array,
111 const std::vector<ArrayView<const float>> &shared_arrays,
112 const ArrayView<float> & ghost_array,
113 std::vector<MPI_Request> & requests) const = 0;
114
115 virtual void
117 const VectorOperation::values vector_operation,
118 const unsigned int communication_channel,
119 const ArrayView<const float> & locally_owned_array,
120 const std::vector<ArrayView<const float>> &shared_arrays,
121 const ArrayView<float> & ghost_array,
122 const ArrayView<float> & temporary_storage,
123 std::vector<MPI_Request> & requests) const = 0;
124
125 virtual void
127 const VectorOperation::values vector_operation,
128 const ArrayView<float> & locally_owned_storage,
129 const std::vector<ArrayView<const float>> &shared_arrays,
130 const ArrayView<float> & ghost_array,
131 const ArrayView<const float> & temporary_storage,
132 std::vector<MPI_Request> & requests) const = 0;
133
134 virtual void
135 reset_ghost_values(const ArrayView<float> &ghost_array) const = 0;
136 };
137
138
143 {
144 public:
146 const std::shared_ptr<const Utilities::MPI::Partitioner>
147 &partitioner);
148
149 virtual ~PartitionerWrapper() = default;
150
151 unsigned int
152 locally_owned_size() const override;
153
154 unsigned int
155 n_ghost_indices() const override;
156
157 unsigned int
158 n_import_indices() const override;
159
160 unsigned int
161 n_import_sm_procs() const override;
162
164 size() const override;
165
166 void
168 const unsigned int communication_channel,
169 const ArrayView<const double> & locally_owned_array,
170 const std::vector<ArrayView<const double>> &shared_arrays,
171 const ArrayView<double> & ghost_array,
172 const ArrayView<double> & temporary_storage,
173 std::vector<MPI_Request> & requests) const override;
174
175 void
177 const ArrayView<const double> & locally_owned_array,
178 const std::vector<ArrayView<const double>> &shared_arrays,
179 const ArrayView<double> & ghost_array,
180 std::vector<MPI_Request> & requests) const override;
181
182 void
184 const VectorOperation::values vector_operation,
185 const unsigned int communication_channel,
186 const ArrayView<const double> & locally_owned_array,
187 const std::vector<ArrayView<const double>> &shared_arrays,
188 const ArrayView<double> & ghost_array,
189 const ArrayView<double> & temporary_storage,
190 std::vector<MPI_Request> & requests) const override;
191
192 void
194 const VectorOperation::values vector_operation,
195 const ArrayView<double> & locally_owned_storage,
196 const std::vector<ArrayView<const double>> &shared_arrays,
197 const ArrayView<double> & ghost_array,
198 const ArrayView<const double> & temporary_storage,
199 std::vector<MPI_Request> & requests) const override;
200
201 void
202 reset_ghost_values(const ArrayView<double> &ghost_array) const override;
203
204 void
206 const unsigned int communication_channel,
207 const ArrayView<const float> & locally_owned_array,
208 const std::vector<ArrayView<const float>> &shared_arrays,
209 const ArrayView<float> & ghost_array,
210 const ArrayView<float> & temporary_storage,
211 std::vector<MPI_Request> & requests) const override;
212
213 void
215 const ArrayView<const float> & locally_owned_array,
216 const std::vector<ArrayView<const float>> &shared_arrays,
217 const ArrayView<float> & ghost_array,
218 std::vector<MPI_Request> & requests) const override;
219
220 void
222 const VectorOperation::values vector_operation,
223 const unsigned int communication_channel,
224 const ArrayView<const float> & locally_owned_array,
225 const std::vector<ArrayView<const float>> &shared_arrays,
226 const ArrayView<float> & ghost_array,
227 const ArrayView<float> & temporary_storage,
228 std::vector<MPI_Request> & requests) const override;
229
230 void
232 const VectorOperation::values vector_operation,
233 const ArrayView<float> & locally_owned_storage,
234 const std::vector<ArrayView<const float>> &shared_arrays,
235 const ArrayView<float> & ghost_array,
236 const ArrayView<const float> & temporary_storage,
237 std::vector<MPI_Request> & requests) const override;
238
239 void
240 reset_ghost_values(const ArrayView<float> &ghost_array) const override;
241
242 private:
243 template <typename Number>
244 void
245 reset_ghost_values_impl(const ArrayView<Number> &ghost_array) const;
246
247 const std::shared_ptr<const Utilities::MPI::Partitioner> partitioner;
248 };
249
250
251
257 class Full : public Base
258 {
259 public:
260 Full(
261 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
262 const MPI_Comm &communicator_sm);
263
264 unsigned int
265 locally_owned_size() const override;
266
267 unsigned int
268 n_ghost_indices() const override;
269
270 unsigned int
271 n_import_indices() const override;
272
273 virtual unsigned int
274 n_import_sm_procs() const override;
275
277 size() const override;
278
279 const MPI_Comm &
281
282 void
284 const unsigned int communication_channel,
285 const ArrayView<const double> & locally_owned_array,
286 const std::vector<ArrayView<const double>> &shared_arrays,
287 const ArrayView<double> & ghost_array,
288 const ArrayView<double> & temporary_storage,
289 std::vector<MPI_Request> & requests) const override;
290
291 void
293 const ArrayView<const double> & locally_owned_array,
294 const std::vector<ArrayView<const double>> &shared_arrays,
295 const ArrayView<double> & ghost_array,
296 std::vector<MPI_Request> & requests) const override;
297
298 void
300 const VectorOperation::values vector_operation,
301 const unsigned int communication_channel,
302 const ArrayView<const double> & locally_owned_array,
303 const std::vector<ArrayView<const double>> &shared_arrays,
304 const ArrayView<double> & ghost_array,
305 const ArrayView<double> & temporary_storage,
306 std::vector<MPI_Request> & requests) const override;
307
308 void
310 const VectorOperation::values vector_operation,
311 const ArrayView<double> & locally_owned_storage,
312 const std::vector<ArrayView<const double>> &shared_arrays,
313 const ArrayView<double> & ghost_array,
314 const ArrayView<const double> & temporary_storage,
315 std::vector<MPI_Request> & requests) const override;
316
317 void
318 reset_ghost_values(const ArrayView<double> &ghost_array) const override;
319
320 void
322 const unsigned int communication_channel,
323 const ArrayView<const float> & locally_owned_array,
324 const std::vector<ArrayView<const float>> &shared_arrays,
325 const ArrayView<float> & ghost_array,
326 const ArrayView<float> & temporary_storage,
327 std::vector<MPI_Request> & requests) const override;
328
329 void
331 const ArrayView<const float> & locally_owned_array,
332 const std::vector<ArrayView<const float>> &shared_arrays,
333 const ArrayView<float> & ghost_array,
334 std::vector<MPI_Request> & requests) const override;
335
336 void
338 const VectorOperation::values vector_operation,
339 const unsigned int communication_channel,
340 const ArrayView<const float> & locally_owned_array,
341 const std::vector<ArrayView<const float>> &shared_arrays,
342 const ArrayView<float> & ghost_array,
343 const ArrayView<float> & temporary_storage,
344 std::vector<MPI_Request> & requests) const override;
345
346 void
348 const VectorOperation::values vector_operation,
349 const ArrayView<float> & locally_owned_storage,
350 const std::vector<ArrayView<const float>> &shared_arrays,
351 const ArrayView<float> & ghost_array,
352 const ArrayView<const float> & temporary_storage,
353 std::vector<MPI_Request> & requests) const override;
354
355 void
356 reset_ghost_values(const ArrayView<float> &ghost_array) const override;
357
358 private:
359 template <typename Number>
360 void
362 const unsigned int communication_channel,
363 const ArrayView<const Number> & locally_owned_array,
364 const std::vector<ArrayView<const Number>> &shared_arrays,
365 const ArrayView<Number> & ghost_array,
366 const ArrayView<Number> & temporary_storage,
367 std::vector<MPI_Request> & requests) const;
368
369 template <typename Number>
370 void
372 const ArrayView<const Number> & locally_owned_array,
373 const std::vector<ArrayView<const Number>> &shared_arrays,
374 const ArrayView<Number> & ghost_array,
375 std::vector<MPI_Request> & requests) const;
376
377 template <typename Number>
378 void
380 const VectorOperation::values vector_operation,
381 const unsigned int communication_channel,
382 const ArrayView<const Number> & locally_owned_array,
383 const std::vector<ArrayView<const Number>> &shared_arrays,
384 const ArrayView<Number> & ghost_array,
385 const ArrayView<Number> & temporary_storage,
386 std::vector<MPI_Request> & requests) const;
387
388 template <typename Number>
389 void
391 const VectorOperation::values vector_operation,
392 const ArrayView<Number> & locally_owned_storage,
393 const std::vector<ArrayView<const Number>> &shared_arrays,
394 const ArrayView<Number> & ghost_array,
395 const ArrayView<const Number> & temporary_storage,
396 std::vector<MPI_Request> & requests) const;
397
398 template <typename Number>
399 void
400 reset_ghost_values_impl(const ArrayView<Number> &ghost_array) const;
401
402 private:
407
412
416 const unsigned int n_local_elements;
417
421 const unsigned int n_ghost_elements;
422
427
433
438 std::pair<std::vector<unsigned int>,
439 std::vector<std::pair<unsigned int, unsigned int>>>
441
446 std::vector<std::array<unsigned int, 3>> ghost_targets_data;
447
454 std::vector<std::array<unsigned int, 3>> import_targets_data;
455
464 std::pair<std::vector<unsigned int>,
465 std::vector<std::pair<unsigned int, unsigned int>>>
467
472 std::vector<unsigned int> sm_ghost_ranks;
473
478 std::pair<std::vector<unsigned int>,
479 std::vector<std::pair<unsigned int, unsigned int>>>
481
486 std::pair<std::vector<unsigned int>,
487 std::vector<std::pair<unsigned int, unsigned int>>>
489
494 std::vector<unsigned int> sm_import_ranks;
495
500 std::pair<std::vector<unsigned int>,
501 std::vector<std::pair<unsigned int, unsigned int>>>
503
508 std::pair<std::vector<unsigned int>,
509 std::vector<std::pair<unsigned int, unsigned int>>>
511 };
512
513 } // namespace VectorDataExchange
514 } // end of namespace MatrixFreeFunctions
515} // end of namespace internal
516
518
519#endif
virtual void import_from_ghosted_array_start(const VectorOperation::values vector_operation, const unsigned int communication_channel, const ArrayView< const float > &locally_owned_array, const std::vector< ArrayView< const float > > &shared_arrays, const ArrayView< float > &ghost_array, const ArrayView< float > &temporary_storage, std::vector< MPI_Request > &requests) const =0
virtual void export_to_ghosted_array_finish(const ArrayView< const float > &locally_owned_array, const std::vector< ArrayView< const float > > &shared_arrays, const ArrayView< float > &ghost_array, std::vector< MPI_Request > &requests) const =0
virtual void reset_ghost_values(const ArrayView< float > &ghost_array) const =0
virtual types::global_dof_index size() const =0
virtual unsigned int locally_owned_size() const =0
virtual void import_from_ghosted_array_finish(const VectorOperation::values vector_operation, const ArrayView< float > &locally_owned_storage, const std::vector< ArrayView< const float > > &shared_arrays, const ArrayView< float > &ghost_array, const ArrayView< const float > &temporary_storage, std::vector< MPI_Request > &requests) const =0
virtual void reset_ghost_values(const ArrayView< double > &ghost_array) const =0
virtual void export_to_ghosted_array_start(const unsigned int communication_channel, const ArrayView< const float > &locally_owned_array, const std::vector< ArrayView< const float > > &shared_arrays, const ArrayView< float > &ghost_array, const ArrayView< float > &temporary_storage, std::vector< MPI_Request > &requests) const =0
virtual void import_from_ghosted_array_start(const VectorOperation::values vector_operation, const unsigned int communication_channel, const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< double > &temporary_storage, std::vector< MPI_Request > &requests) const =0
virtual void import_from_ghosted_array_finish(const VectorOperation::values vector_operation, const ArrayView< double > &locally_owned_storage, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< const double > &temporary_storage, std::vector< MPI_Request > &requests) const =0
virtual void export_to_ghosted_array_start(const unsigned int communication_channel, const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< double > &temporary_storage, std::vector< MPI_Request > &requests) const =0
virtual void export_to_ghosted_array_finish(const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, std::vector< MPI_Request > &requests) const =0
void export_to_ghosted_array_start(const unsigned int communication_channel, const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< double > &temporary_storage, std::vector< MPI_Request > &requests) const override
void reset_ghost_values(const ArrayView< double > &ghost_array) const override
std::vector< std::array< unsigned int, 3 > > ghost_targets_data
std::pair< std::vector< unsigned int >, std::vector< std::pair< unsigned int, unsigned int > > > sm_export_data_this
void export_to_ghosted_array_finish(const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, std::vector< MPI_Request > &requests) const override
void import_from_ghosted_array_start(const VectorOperation::values vector_operation, const unsigned int communication_channel, const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< double > &temporary_storage, std::vector< MPI_Request > &requests) const override
void export_to_ghosted_array_start_impl(const unsigned int communication_channel, const ArrayView< const Number > &locally_owned_array, const std::vector< ArrayView< const Number > > &shared_arrays, const ArrayView< Number > &ghost_array, const ArrayView< Number > &temporary_storage, std::vector< MPI_Request > &requests) const
void import_from_ghosted_array_finish_impl(const VectorOperation::values vector_operation, const ArrayView< Number > &locally_owned_storage, const std::vector< ArrayView< const Number > > &shared_arrays, const ArrayView< Number > &ghost_array, const ArrayView< const Number > &temporary_storage, std::vector< MPI_Request > &requests) const
std::pair< std::vector< unsigned int >, std::vector< std::pair< unsigned int, unsigned int > > > sm_export_data
std::vector< std::array< unsigned int, 3 > > import_targets_data
std::pair< std::vector< unsigned int >, std::vector< std::pair< unsigned int, unsigned int > > > ghost_indices_subset_data
void import_from_ghosted_array_finish(const VectorOperation::values vector_operation, const ArrayView< double > &locally_owned_storage, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< const double > &temporary_storage, std::vector< MPI_Request > &requests) const override
Full(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner, const MPI_Comm &communicator_sm)
void export_to_ghosted_array_finish_impl(const ArrayView< const Number > &locally_owned_array, const std::vector< ArrayView< const Number > > &shared_arrays, const ArrayView< Number > &ghost_array, std::vector< MPI_Request > &requests) const
std::pair< std::vector< unsigned int >, std::vector< std::pair< unsigned int, unsigned int > > > sm_import_data
void import_from_ghosted_array_start_impl(const VectorOperation::values vector_operation, const unsigned int communication_channel, const ArrayView< const Number > &locally_owned_array, const std::vector< ArrayView< const Number > > &shared_arrays, const ArrayView< Number > &ghost_array, const ArrayView< Number > &temporary_storage, std::vector< MPI_Request > &requests) const
void reset_ghost_values_impl(const ArrayView< Number > &ghost_array) const
std::pair< std::vector< unsigned int >, std::vector< std::pair< unsigned int, unsigned int > > > sm_import_data_this
virtual types::global_dof_index size() const override
std::pair< std::vector< unsigned int >, std::vector< std::pair< unsigned int, unsigned int > > > import_indices_data
const std::shared_ptr< const Utilities::MPI::Partitioner > partitioner
void export_to_ghosted_array_finish(const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, std::vector< MPI_Request > &requests) const override
PartitionerWrapper(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner)
void export_to_ghosted_array_start(const unsigned int communication_channel, const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< double > &temporary_storage, std::vector< MPI_Request > &requests) const override
void reset_ghost_values_impl(const ArrayView< Number > &ghost_array) const
void import_from_ghosted_array_finish(const VectorOperation::values vector_operation, const ArrayView< double > &locally_owned_storage, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< const double > &temporary_storage, std::vector< MPI_Request > &requests) const override
void reset_ghost_values(const ArrayView< double > &ghost_array) const override
void import_from_ghosted_array_start(const VectorOperation::values vector_operation, const unsigned int communication_channel, const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< double > &temporary_storage, std::vector< MPI_Request > &requests) const override
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403