| 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; |
| 71 |
using Implementation = detail::partitioner::Partitioner; |
| 72 |
|
| 73 |
public: |
| 74 |
static bool exists(const std::string& type); |
| 75 |
|
| 76 |
public: |
| 77 |
using Handle::Handle; |
| 78 |
Partitioner() = default; |
| 79 |
explicit 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 |
std::string mpi_comm() const; |
| 93 |
}; |
| 94 |
|
| 95 |
// ------------------------------------------------------------------ |
| 96 |
|
| 97 |
class MatchingPartitioner : public Partitioner { |
| 98 |
public: |
| 99 |
using Config = eckit::Parametrisation; |
| 100 |
|
| 101 |
public: |
| 102 |
static bool exists(const std::string& type); |
| 103 |
|
| 104 |
public: |
| 105 |
MatchingPartitioner(); |
| 106 |
MatchingPartitioner(const Mesh&); |
| 107 |
MatchingPartitioner(const Mesh&, const Config&); |
| 108 |
MatchingPartitioner(const FunctionSpace&); |
| 109 |
MatchingPartitioner(const FunctionSpace&, const Config&); |
| 110 |
}; |
| 111 |
|
| 112 |
// ------------------------------------------------------------------ |
| 113 |
|
| 114 |
class MatchingMeshPartitioner : public MatchingPartitioner { |
| 115 |
public: |
| 116 |
using MatchingPartitioner::MatchingPartitioner; |
| 117 |
}; |
| 118 |
|
| 119 |
// ------------------------------------------------------------------ |
| 120 |
|
| 121 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 122 |
using GridImpl = detail::grid::Grid; |
| 123 |
|
| 124 |
extern "C" { |
| 125 |
Partitioner::Implementation* atlas__grid__Partitioner__new(const Partitioner::Config* config); |
| 126 |
|
| 127 |
Partitioner::Implementation* atlas__grid__Partitioner__new_type(const char* type); |
| 128 |
|
| 129 |
Partitioner::Implementation* atlas__grid__MatchingMeshPartitioner__new(const mesh::detail::MeshImpl* mesh, |
| 130 |
const Partitioner::Config* config); |
| 131 |
Partitioner::Implementation* atlas__grid__MatchingFunctionSpacePartitioner__new( |
| 132 |
const functionspace::FunctionSpaceImpl* functionspace, const Partitioner::Config* config); |
| 133 |
void atlas__grid__Partitioner__delete(Partitioner::Implementation* This); |
| 134 |
DistributionImpl* atlas__grid__Partitioner__partition(const Partitioner::Implementation* This, const GridImpl* grid); |
| 135 |
} |
| 136 |
#endif |
| 137 |
|
| 138 |
} // namespace grid |
| 139 |
} // namespace atlas |