Block-Structured AMR Software Framework
AMReX_TagBox.H
Go to the documentation of this file.
1 
2 #ifndef AMREX_TagBox_H_
3 #define AMREX_TagBox_H_
4 #include <AMReX_Config.H>
5 
6 #include <AMReX_IntVect.H>
7 #include <AMReX_Box.H>
8 #include <AMReX_Array.H>
9 #include <AMReX_Vector.H>
10 #include <AMReX_BaseFab.H>
11 #include <AMReX_FabArray.H>
12 #include <AMReX_BoxArray.H>
13 #include <AMReX_Geometry.H>
14 
15 namespace amrex {
16 
17 
23 class TagBox final
24  :
25  public BaseFab<char>
26 {
27 public:
28 
30  using TagType = char;
31 
33  enum TagVal { CLEAR=0, BUF, SET };
34 
35  TagBox () noexcept = default;
36 
37  explicit TagBox (Arena* ar) noexcept;
38 
39  TagBox (const Box& bx, int n, Arena* ar);
40 
41  explicit TagBox (const Box& bx, int n = 1, bool alloc = true,
42  bool shared = false, Arena* ar = nullptr);
43 
44  TagBox (const TagBox& rhs, MakeType make_type, int scomp, int ncomp);
45 
46  ~TagBox () noexcept override = default;
47 
48  TagBox (TagBox&& rhs) noexcept = default;
49 
50  TagBox (const TagBox& rhs) = delete;
51  TagBox& operator= (const TagBox& rhs) = delete;
52  TagBox& operator= (TagBox&& rhs) = delete;
53 
54 
59  void coarsen (const IntVect& ratio, const Box& cbox) noexcept;
60 
69  void buffer (const IntVect& a_nbuff, const IntVect& nwid) noexcept;
70 
76 //#if (__cplusplus >= 201402L)
77 // [[deprecated("No need to use this unless calling Fortran < 2003")]]
78 //#endif
79  [[nodiscard]] Vector<int> tags () const noexcept;
80 
89 //#if (__cplusplus >= 201402L)
90 // [[deprecated("No need to use this unless calling Fortran < 2003")]]
91 //#endif
92  void get_itags(Vector<int>& ar, const Box& tilebx) const noexcept;
93 
100 //#if (__cplusplus >= 201402L)
101 // [[deprecated("No need to use this unless calling Fortran < 2003")]]
102 //#endif
103  void tags (const Vector<int>& ar) noexcept;
104 
111 //#if (__cplusplus >= 201402L)
112 // [[deprecated("No need to use this unless calling Fortran < 2003")]]
113 //#endif
114  void tags_and_untags (const Vector<int>& ar) noexcept;
115 
123 //#if (__cplusplus >= 201402L)
124 // [[deprecated("No need to use this unless calling Fortran < 2003")]]
125 //#endif
126  void tags (const Vector<int>& ar, const Box& tilebx) noexcept;
127 
135 //#if (__cplusplus >= 201402L)
136 // [[deprecated("No need to use this unless calling Fortran < 2003")]]
137 //#endif
138  void tags_and_untags (const Vector<int>& ar, const Box& tilebx) noexcept;
139 };
140 
141 
148  :
149  public FabArray<TagBox>
150 {
151 public:
152 
155 
163  TagBoxArray (const BoxArray& ba, const DistributionMapping& dm, int _ngrow=0);
164  TagBoxArray (const BoxArray& ba, const DistributionMapping& dm, const IntVect& _ngrow);
165 
166  ~TagBoxArray () = default;
167 
168  TagBoxArray (TagBoxArray&& rhs) noexcept = default;
169  TagBoxArray& operator= (TagBoxArray&& rhs) noexcept = default;
170 
171  TagBoxArray (const TagBoxArray& rhs) = delete;
172  TagBoxArray& operator= (const TagBoxArray& rhs) = delete;
173 
179  void buffer (const IntVect& nbuf);
180 
187  void mapPeriodicRemoveDuplicates (const Geometry& geom);
188 
195  void setVal (const BoxArray& ba, TagBox::TagVal val);
197 
203  void coarsen (const IntVect& ratio);
204 
210  void collate (Gpu::PinnedVector<IntVect>& TheGlobalCollateSpace) const;
211 
212  // \brief Are there tags in the region defined by bx?
213  bool hasTags (Box const& bx) const;
214 
215  void local_collate_cpu (Gpu::PinnedVector<IntVect>& v) const;
216 #ifdef AMREX_USE_GPU
217  void local_collate_gpu (Gpu::PinnedVector<IntVect>& v) const;
218 #endif
219 };
220 
221 }
222 
223 #endif /*_TagBox_H_*/
A virtual base class for objects that manage their own dynamic memory allocation.
Definition: AMReX_Arena.H:100
A FortranArrayBox(FAB)-like object.
Definition: AMReX_BaseFab.H:183
void setVal(char const &x, const Box &bx, int dcomp, int ncomp) noexcept
The setVal functions set sub-regions in the BaseFab to a constant value. This most general form speci...
Definition: AMReX_BaseFab.H:1869
A collection of Boxes stored in an Array.
Definition: AMReX_BoxArray.H:550
Calculates the distribution of FABs to MPI processes.
Definition: AMReX_DistributionMapping.H:41
An Array of FortranArrayBox(FAB)-like Objects.
Definition: AMReX_FabArray.H:344
Rectangular problem domain geometry.
Definition: AMReX_Geometry.H:73
Definition: AMReX_PODVector.H:246
An array of TagBoxes.
Definition: AMReX_TagBox.H:150
TagBoxArray(const TagBoxArray &rhs)=delete
~TagBoxArray()=default
TagBoxArray(TagBoxArray &&rhs) noexcept=default
TagBox::TagType TagType
The type of each tag.
Definition: AMReX_TagBox.H:154
Tagged cells in a Box.
Definition: AMReX_TagBox.H:26
void get_itags(Vector< int > &ar, const Box &tilebx) const noexcept
Since a TagBox is a BaseFab<char>, we can use this utility function to allocate an integer array to h...
Definition: AMReX_TagBox.cpp:180
void coarsen(const IntVect &ratio, const Box &cbox) noexcept
Construct and return a new tagbox in which the coarsened cell is tagged of any of the corresponding f...
Definition: AMReX_TagBox.cpp:33
TagBox() noexcept=default
TagBox & operator=(const TagBox &rhs)=delete
char TagType
The type of each tag.
Definition: AMReX_TagBox.H:30
Vector< int > tags() const noexcept
Returns Vector<int> of size domain.numPts() suitable for calling Fortran, with positions set to same ...
Definition: AMReX_TagBox.cpp:124
TagVal
Possible values for each cell.
Definition: AMReX_TagBox.H:33
@ SET
Definition: AMReX_TagBox.H:33
@ CLEAR
Definition: AMReX_TagBox.H:33
@ BUF
Definition: AMReX_TagBox.H:33
void tags_and_untags(const Vector< int > &ar) noexcept
Set values as specified by the array – this tags and untags. It's an error if ar.length() !...
Definition: AMReX_TagBox.cpp:161
void buffer(const IntVect &a_nbuff, const IntVect &nwid) noexcept
Mark neighbors of every tagged cell a distance nbuff away only search interior for initial tagged poi...
Definition: AMReX_TagBox.cpp:76
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition: AMReX_Vector.H:27
Definition: AMReX_Amr.cpp:49
MakeType
Definition: AMReX_MakeType.H:7
void * alloc(std::size_t sz) const noexcept
Definition: AMReX_DataAllocator.H:16