atlas
Partitioner.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 <string>
14 
15 
16 #include "atlas/library/config.h"
17 #include "atlas/util/ObjectHandle.h"
18 
19 namespace eckit {
20 class Parametrisation;
21 }
22 
23 namespace atlas {
24 class Grid;
25 class Mesh;
26 class FunctionSpace;
27 namespace grid {
28 class Distribution;
29 class DistributionImpl;
30 
31 namespace detail {
32 namespace partitioner {
33 class Partitioner;
34 } // namespace partitioner
35 } // namespace detail
36 } // namespace grid
37 } // namespace atlas
38 
39 namespace atlas {
40 namespace mesh {
41 namespace detail {
42 class MeshImpl;
43 }
44 } // namespace mesh
45 } // namespace atlas
46 
47 namespace atlas {
48 namespace functionspace {
49 class FunctionSpaceImpl;
50 } // namespace functionspace
51 } // namespace atlas
52 
53 namespace atlas {
54 namespace grid {
55 namespace detail {
56 namespace grid {
57 class Grid;
58 } // namespace grid
59 } // namespace detail
60 } // namespace grid
61 } // namespace atlas
62 
63 namespace atlas {
64 namespace grid {
65 
66 // ------------------------------------------------------------------
67 
68 class Partitioner : DOXYGEN_HIDE( public util::ObjectHandle<detail::partitioner::Partitioner> ) {
69 public:
70  using Config = eckit::Parametrisation;
72 
73 public:
74  static bool exists( const std::string& type );
75 
76 public:
77  using Handle::Handle;
78  Partitioner() = default;
79  Partitioner( const std::string& type );
80  Partitioner( const std::string& type, const idx_t nb_partitions );
81  Partitioner( const Config& );
82  Partitioner( const std::string& type, const Config& );
83 
84  void partition( const Grid& grid, int part[] ) const;
85 
86  Distribution partition( const Grid& grid ) const;
87 
88  idx_t nb_partitions() const;
89 
90  std::string type() const;
91 };
92 
93 // ------------------------------------------------------------------
94 
96 public:
97  using Config = eckit::Parametrisation;
98 
99 public:
100  static bool exists( const std::string& type );
101 
102 public:
104  MatchingPartitioner( const Mesh& );
105  MatchingPartitioner( const Mesh&, const Config& );
107  MatchingPartitioner( const FunctionSpace&, const Config& );
108 };
109 
110 // ------------------------------------------------------------------
111 
113 public:
114  using MatchingPartitioner::MatchingPartitioner;
115 };
116 
117 // ------------------------------------------------------------------
118 
119 #ifndef DOXYGEN_SHOULD_SKIP_THIS
121 
122 extern "C" {
123 Partitioner::Implementation* atlas__grid__Partitioner__new( const Partitioner::Config* config );
124 
125 Partitioner::Implementation* atlas__grid__Partitioner__new_type( const char* type );
126 
127 Partitioner::Implementation* atlas__grid__MatchingMeshPartitioner__new( const mesh::detail::MeshImpl* mesh,
128  const Partitioner::Config* config );
129 Partitioner::Implementation* atlas__grid__MatchingFunctionSpacePartitioner__new(
130  const functionspace::FunctionSpaceImpl* functionspace, const Partitioner::Config* config );
131 void atlas__grid__Partitioner__delete( Partitioner::Implementation* This );
132 DistributionImpl* atlas__grid__Partitioner__partition( const Partitioner::Implementation* This, const GridImpl* grid );
133 }
134 #endif
135 
136 } // namespace grid
137 } // namespace atlas
Definition: Distribution.h:31
Definition: Mesh.h:55
Definition: Domain.h:19
Most general grid container.
Definition: Grid.h:64
Definition: Grid.h:42
Definition: DistributionImpl.h:44
Definition: Partitioner.h:95
Definition: Partitioner.h:112
Definition: MeshImpl.h:54
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
FunctionSpace class helps to interprete Fields.
Definition: FunctionSpaceImpl.h:44
Definition: Partitioner.h:68
Definition: FunctionSpace.h:39