Debian Codegraph @

src/atlas/grid/Distribution.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 "Distribution.h"
12
13 #include "eckit/utils/MD5.h"
14
15 #include "atlas/grid/Grid.h"
16 #include "atlas/grid/Partitioner.h"
17 #include "atlas/grid/detail/distribution/DistributionArray.h"
18 #include "atlas/grid/detail/distribution/SerialDistribution.h"
19
20 namespace atlas {
21 namespace grid {
22
23 using namespace detail::distribution;
24
25 Distribution::Distribution(const Grid& grid): Handle(new SerialDistribution{grid}) {}
26
27 Distribution::Distribution(const Grid& grid, const Config& config): Handle(Partitioner(config).partition(grid).get()) {}
28
29 Distribution::Distribution(const Grid& grid, const Partitioner& partitioner): Handle(partitioner.partition(grid)) {}
30
31 Distribution::Distribution(int nb_partitions, idx_t npts, int part[], int part0):
32 Handle(new DistributionArray(nb_partitions, npts, part, part0)) {}
33
34 Distribution::Distribution(int nb_partitions, partition_t&& part):
35 Handle(new DistributionArray(nb_partitions, std::move(part))) {}
36
37 Distribution::~Distribution() = default;
38
39 const std::vector<idx_t>& Distribution::nb_pts() const {
40 return get()->nb_pts();
41 }
42
43 idx_t Distribution::max_pts() const {
44 return get()->max_pts();
45 }
46
47 idx_t Distribution::min_pts() const {
48 return get()->min_pts();
49 }
50
51 const std::string& Distribution::type() const {
52 return get()->type();
53 }
54
55 std::ostream& operator<<(std::ostream& os, const Distribution& distribution) {
56 distribution.get()->print(os);
57 return os;
58 }
59
60 void Distribution::hash(eckit::Hash& hash) const {
61 get()->hash(hash);
62 }
63
64 std::string Distribution::hash() const {
65 eckit::MD5 h;
66 hash(h);
67 return h.digest();
68 }
69
70 } // namespace grid
71 } // namespace atlas