Debian Codegraph @

src/atlas/grid/detail/distribution/DistributionFunction.cc

raw
1 /*
2 * (C) Copyright 2013 ECMWF.
3 *
4 * This software is licensed under the terms of the Apache Licence Version 2.0
5 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 * In applying this licence, ECMWF does not waive the privileges and immunities
7 * granted to it by virtue of its status as an intergovernmental organisation
8 * nor does it submit to any jurisdiction.
9 */
10
11 #include "DistributionFunction.h"
12
13 #include <algorithm>
14 #include <ostream>
15
16 #include "eckit/types/Types.h"
17 #include "eckit/utils/Hash.h"
18
19 #include "atlas/grid/Grid.h"
20
21 namespace atlas {
22 namespace grid {
23 namespace detail {
24 namespace distribution {
25
26 void DistributionFunction::print(std::ostream& s) const {
27 auto print_partition = [&](std::ostream& s) {
28 eckit::output_list<int> list_printer(s);
29 for (gidx_t i = 0; i < size_; i++) {
30 list_printer.push_back(partition(i));
31 }
32 };
33 s << "Distribution( "
34 << "type: " << type_ << ", nb_points: " << size_ << ", nb_partitions: " << nb_pts_.size() << ", parts : ";
35 print_partition(s);
36 }
37
38 void DistributionFunction::hash(eckit::Hash& hash) const {
39 for (gidx_t i = 0; i < size_; i++) {
40 hash.add(partition(i));
41 }
42 }
43
44 } // namespace distribution
45 } // namespace detail
46 } // namespace grid
47 } // namespace atlas