Block-Structured AMR Software Framework
AMReX_Cluster.H
Go to the documentation of this file.
1 
2 #ifndef AMREX_Cluster_H_
3 #define AMREX_Cluster_H_
4 #include <AMReX_Config.H>
5 
6 #include <AMReX_BoxList.H>
7 #include <AMReX_REAL.H>
8 
9 #include <list>
10 
11 namespace amrex {
12 
13 class BoxDomain;
14 class BoxArray;
15 class ClusterList;
16 
17 
23 class Cluster
24 {
25 public:
26 
30  Cluster () noexcept = default;
31 
40  Cluster (IntVect* a, Long len) noexcept;
41 
49  Cluster (Cluster& c, const Box& b);
50 
51  ~Cluster () = default;
52  Cluster (const Cluster&) = delete;
53  Cluster (Cluster&&) = delete;
54  Cluster& operator= (const Cluster&) = delete;
55  Cluster& operator= (Cluster&&) = delete;
56 
60  [[nodiscard]] const Box& box () const noexcept { return m_bx; }
61 
65  [[nodiscard]] bool ok () const noexcept { return m_ar != nullptr && m_len > 0; }
66 
70  [[nodiscard]] Long numTag () const noexcept { return m_len; }
71 
77  [[nodiscard]] Long numTag (const Box& b) const noexcept;
78 
86  Cluster* chop ();
87 
88 
95  Cluster* new_chop ();
96 
110  void distribute (ClusterList& clst,
111  const BoxDomain& bd);
112 
116  [[nodiscard]] Real eff () const noexcept {
117  BL_ASSERT(ok());
118  return static_cast<Real>(double(numTag()) / m_bx.d_numPts());
119  }
120 
121 private:
122 
126  void minBox () noexcept;
127 
130  IntVect* m_ar = nullptr;
131  Long m_len = 0;
132 };
133 
134 
141 {
142 public:
143 
147  ClusterList () = default;
148 
155  ClusterList (IntVect* pts, Long len);
156 
160  ~ClusterList ();
161 
162  ClusterList (const ClusterList&) = delete;
163  ClusterList (ClusterList&&) = delete;
164  ClusterList& operator= (const ClusterList&) = delete;
166 
170  [[nodiscard]] int length () const { return static_cast<int>(lst.size()); }
171 
177  void append (Cluster* c) { lst.push_back(c); }
178 
182  [[nodiscard]] BoxArray boxArray () const;
183 
189  void boxArray (BoxArray& ba) const;
190 
194  [[nodiscard]] BoxList boxList() const;
195 
201  void boxList (BoxList& blst) const;
202 
208  void chop (Real eff);
209 
216  void new_chop (Real eff);
217 
225  void intersect (BoxArray& ba);
226 
227 private:
228 
230  std::list<Cluster*> lst;
231 };
232 
233 }
234 
235 #endif /*_Cluster_H_*/
#define BL_ASSERT(EX)
Definition: AMReX_BLassert.H:39
A collection of Boxes stored in an Array.
Definition: AMReX_BoxArray.H:550
A List of Disjoint Boxes.
Definition: AMReX_BoxDomain.H:67
A class for managing a List of Boxes that share a common IndexType. This class implements operations ...
Definition: AMReX_BoxList.H:52
AMREX_GPU_HOST_DEVICE double d_numPts() const noexcept
Returns the number of points contained in the BoxND. This is intended for use only in diagnostic mess...
Definition: AMReX_Box.H:366
A list of Cluster objects.
Definition: AMReX_Cluster.H:141
std::list< Cluster * > lst
The data.
Definition: AMReX_Cluster.H:230
ClusterList(ClusterList &&)=delete
ClusterList(const ClusterList &)=delete
void append(Cluster *c)
Add cluster to end of list.
Definition: AMReX_Cluster.H:177
ClusterList()=default
The default constructor.
int length() const
Return number of clusters in list.
Definition: AMReX_Cluster.H:170
A cluster of tagged cells.
Definition: AMReX_Cluster.H:24
Cluster & operator=(const Cluster &)=delete
Cluster * new_chop()
This version of chop has slightly different logic - in this case if a cut results in two boxes with t...
Definition: AMReX_Cluster.cpp:337
IntVect * m_ar
Definition: AMReX_Cluster.H:130
Long m_len
Definition: AMReX_Cluster.H:131
Long numTag() const noexcept
Returns number of tagged points in cluster.
Definition: AMReX_Cluster.H:70
Real eff() const noexcept
Compute ratio of tagged to total number of points in cluster.
Definition: AMReX_Cluster.H:116
Cluster() noexcept=default
The default constructor – builds invalid Cluster.
Box m_bx
The data.
Definition: AMReX_Cluster.H:129
void distribute(ClusterList &clst, const BoxDomain &bd)
Constructs a list of cluster objects obtained by intersecting this cluster with each box in bl....
Definition: AMReX_Cluster.cpp:98
bool ok() const noexcept
Does cluster contain any points?
Definition: AMReX_Cluster.H:65
Cluster * chop()
This operation splits a cluster into two pieces by selecting a cutting plane with certain optimal cha...
Definition: AMReX_Cluster.cpp:261
void minBox() noexcept
Compute and store minimal box containing tagged points.
Definition: AMReX_Cluster.cpp:129
const Box & box() const noexcept
Return minimal box containing all tagged points.
Definition: AMReX_Cluster.H:60
Definition: AMReX_Amr.cpp:49
BoxArray intersect(const BoxArray &ba, const Box &b, int ng=0)
Make a BoxArray from the intersection of Box b and BoxArray(+ghostcells).
BoxArray const & boxArray(FabArrayBase const &fa)