Block-Structured AMR Software Framework
AMReX_AlgPartition.H
Go to the documentation of this file.
1 #ifndef AMREX_ALG_PARTITION_H_
2 #define AMREX_ALG_PARTITION_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_INT.H>
7 #include <AMReX_Vector.H>
8 
9 #include <memory>
10 
11 namespace amrex {
12 
14 {
15 public:
16  AlgPartition ();
17  explicit AlgPartition (Long global_size);
18  explicit AlgPartition (Vector<Long> const& rows);
19  explicit AlgPartition (Vector<Long>&& rows) noexcept;
20 
21  void define (Long global_size);
22  void define (Vector<Long> const& rows);
23  void define (Vector<Long>&& rows);
24 
25  [[nodiscard]] bool empty () const { return m_ref->m_row.empty(); }
26 
27  [[nodiscard]] Long operator[] (int i) const { return m_ref->m_row[i]; }
28  [[nodiscard]] Long numGlobalRows () const { return m_ref->m_row.back(); }
29  [[nodiscard]] int numActiveProcs () const { return m_ref->m_n_active_procs; }
30 
31  [[nodiscard]] Vector<Long> const& dataVector () const { return m_ref->m_row; }
32 
33  [[nodiscard]] bool operator== (AlgPartition const& rhs) const noexcept;
34  [[nodiscard]] bool operator!= (AlgPartition const& rhs) const noexcept;
35 
36 private:
37  struct Ref
38  {
39  friend class AlgPartition;
40  Ref () = default;
41  explicit Ref (Long global_size);
42  explicit Ref (Vector<Long> const& rows);
43  explicit Ref (Vector<Long>&& rows);
44  void define (Long global_size);
45  void define (Vector<Long> const& rows);
46  void define (Vector<Long>&& rows);
47  void update_n_active_procs ();
48 
49  Vector<Long> m_row; // size: nprocs + 1
51  };
52 
53  std::shared_ptr<Ref> m_ref;
54 };
55 
56 }
57 
58 #endif
Definition: AMReX_AlgPartition.H:14
std::shared_ptr< Ref > m_ref
Definition: AMReX_AlgPartition.H:53
Long numGlobalRows() const
Definition: AMReX_AlgPartition.H:28
AlgPartition()
Definition: AMReX_AlgPartition.cpp:5
int numActiveProcs() const
Definition: AMReX_AlgPartition.H:29
bool operator==(AlgPartition const &rhs) const noexcept
Definition: AMReX_AlgPartition.cpp:36
bool empty() const
Definition: AMReX_AlgPartition.H:25
Vector< Long > const & dataVector() const
Definition: AMReX_AlgPartition.H:31
void define(Long global_size)
Definition: AMReX_AlgPartition.cpp:21
bool operator!=(AlgPartition const &rhs) const noexcept
Definition: AMReX_AlgPartition.cpp:41
Long operator[](int i) const
Definition: AMReX_AlgPartition.H:27
Definition: AMReX_Amr.cpp:49
Definition: AMReX_AlgPartition.H:38
Vector< Long > m_row
Definition: AMReX_AlgPartition.H:49
int m_n_active_procs
Definition: AMReX_AlgPartition.H:50
void define(Long global_size)
Definition: AMReX_AlgPartition.cpp:63
void update_n_active_procs()
Definition: AMReX_AlgPartition.cpp:93