atlas
Distribution.h
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 #pragma once
12 
13 #include <vector>
14 
15 #include "atlas/grid/detail/distribution/DistributionImpl.h"
16 #include "atlas/library/config.h"
17 #include "atlas/util/Config.h"
18 #include "atlas/util/ObjectHandle.h"
19 #include "atlas/util/vector.h"
20 
21 namespace atlas {
22 class Grid;
23 namespace grid {
24 class Partitioner;
25 } // namespace grid
26 } // namespace atlas
27 
28 namespace atlas {
29 namespace grid {
30 
31 class Distribution : DOXYGEN_HIDE( public util::ObjectHandle<DistributionImpl> ) {
32  friend class Partitioner;
33 
34 public:
37 
38  using Handle::Handle;
39  Distribution() = default;
40 
42  Distribution( const Grid& );
43 
45  Distribution( const Grid&, const Config& );
46 
48  Distribution( const Grid&, const Partitioner& );
49 
51  Distribution( int nb_partitions, idx_t npts, int partition[], int part0 = 0 );
52 
54  Distribution( int nb_partitions, partition_t&& partition );
55 
56  ~Distribution();
57 
58  ATLAS_ALWAYS_INLINE int partition( gidx_t index ) const { return get()->partition( index ); }
59 
60  template <typename PartitionContainer>
61  void partition( gidx_t begin, gidx_t end, PartitionContainer& partitions ) const {
62  ATLAS_ASSERT( end - begin <= partitions.size() );
63  return get()->partition( begin, end, partitions.data() );
64  }
65 
66  size_t footprint() const { return get()->footprint(); }
67 
68  ATLAS_ALWAYS_INLINE idx_t nb_partitions() const { return get()->nb_partitions(); }
69 
70  ATLAS_ALWAYS_INLINE gidx_t size() const { return get()->size(); }
71 
72  const std::vector<idx_t>& nb_pts() const;
73 
74  idx_t max_pts() const;
75 
76  idx_t min_pts() const;
77 
78  const std::string& type() const;
79 
80  friend std::ostream& operator<<( std::ostream& os, const Distribution& distribution );
81 
82  std::string hash() const;
83 
84  void hash( eckit::Hash& ) const;
85 };
86 
87 } // namespace grid
88 } // namespace atlas
Definition: Distribution.h:31
Most general grid container.
Definition: Grid.h:64
long gidx_t
Integer type for global indices.
Definition: config.h:34
Contains all atlas classes and methods.
Definition: atlas-grids.cc:33
long idx_t
Integer type for indices in connectivity tables.
Definition: config.h:42
Definition: Partitioner.h:68
Configuration class used to construct various atlas components.
Definition: Config.h:27