Skip to content

Commit 4b8dd03

Browse files
authored
Comments on FAB-related classes and methods (#3636)
New or updated comments for various FAB-related classes and methods. Descriptions are tweaked to match standard comment conventions and make IntelliSense happy. For example, some descriptions get moved to be just before their respective class declarations.
1 parent 4b64003 commit 4b8dd03

File tree

9 files changed

+243
-222
lines changed

9 files changed

+243
-222
lines changed

Src/Base/AMReX_BaseFab.H

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -90,54 +90,6 @@ makeArray4 (T* p, Box const& bx, int ncomp) noexcept
9090
return Array4<T>{p, amrex::begin(bx), amrex::end(bx), ncomp};
9191
}
9292

93-
/**
94-
* \brief A Fortran Array-like Object
95-
* BaseFab emulates the Fortran array concept.
96-
* Useful operations can be performed upon
97-
* BaseFabs in C++, and they provide a convenient interface to
98-
* Fortran when it is necessary to retreat into that language.
99-
100-
* BaseFab is a template class. Through use of the
101-
* template, a BaseFab may be based upon any class. So far at least,
102-
* most applications have been based upon simple types like integers,
103-
* real*4s, or real*8s. Most applications do not use BaseFabs
104-
* directly, but utilize specialized classes derived from BaseFab.
105-
106-
* Classes derived from BaseFab include FArrayBox, IArrayBox, TagBox,
107-
* Mask, EBFArrayBox, EBCellFlag and CutFab.
108-
109-
* BaseFab objects depend on the dimensionality of space
110-
* (indirectly through the DOMAIN Box member). It is
111-
* typical to define the macro SPACEDIM to be 1, 2, or 3 to indicate
112-
* the dimension of space. See the discussion of class Box for more
113-
* information. A BaseFab contains a Box DOMAIN, which indicates the
114-
* integer indexing space over which the array is defined. A BaseFab
115-
* also has NVAR components. By components, we mean that for each
116-
* point in the rectangular indexing space, there are NVAR values
117-
* associated with that point. A Fortran array corresponding to a
118-
* BaseFab would have (SPACEDIM+1) dimensions.
119-
120-
* By design, the array layout in a BaseFab mirrors that of a
121-
* Fortran array. The first index (x direction for example) varies
122-
* most rapidly, the next index (y direction), if any, varies next
123-
* fastest. The component index varies last, after all the spatial
124-
* indices.
125-
126-
* It is sometimes convenient to be able to treat a sub-array within an
127-
* existing BaseFab as a BaseFab in its own right. This is often
128-
* referred to as aliasing the BaseFab. Note that when aliasing is
129-
* used, the BaseFabs domain will not, in general, be the same as the
130-
* parent BaseFabs domain, nor will the number of components.
131-
* BaseFab is a dimension dependent class, so SPACEDIM must be
132-
* defined as either 1, 2, or 3 when compiling.
133-
134-
* This is NOT a polymorphic class.
135-
136-
* It does NOT provide a copy constructor or assignment operator.
137-
138-
* T MUST have a default constructor and an assignment operator.
139-
*/
140-
14193
template <typename T>
14294
typename std::enable_if<std::is_arithmetic<T>::value>::type
14395
placementNew (T* const /*ptr*/, Long /*n*/)
@@ -178,6 +130,54 @@ placementDelete (T* const ptr, Long n)
178130
});
179131
}
180132

133+
/**
134+
* \brief A FortranArrayBox(FAB)-like object
135+
*
136+
* BaseFab emulates the Fortran array concept.
137+
* Useful operations can be performed upon
138+
* BaseFabs in C++, and they provide a convenient interface to
139+
* Fortran when it is necessary to retreat into that language.
140+
*
141+
* BaseFab is a template class. Through use of the
142+
* template, a BaseFab may be based upon any class. So far at least,
143+
* most applications have been based upon simple types like integers,
144+
* real*4s, or real*8s. Most applications do not use BaseFabs
145+
* directly, but utilize specialized classes derived from BaseFab.
146+
*
147+
* Classes derived from BaseFab include FArrayBox, IArrayBox, TagBox,
148+
* Mask, EBFArrayBox, EBCellFlag and CutFab.
149+
*
150+
* BaseFab objects depend on the dimensionality of space
151+
* (indirectly through the DOMAIN Box member). It is
152+
* typical to define the macro SPACEDIM to be 1, 2, or 3 to indicate
153+
* the dimension of space. See the discussion of class Box for more
154+
* information. A BaseFab contains a Box DOMAIN, which indicates the
155+
* integer indexing space over which the array is defined. A BaseFab
156+
* also has NVAR components. By components, we mean that for each
157+
* point in the rectangular indexing space, there are NVAR values
158+
* associated with that point. A Fortran array corresponding to a
159+
* BaseFab would have (SPACEDIM+1) dimensions.
160+
*
161+
* By design, the array layout in a BaseFab mirrors that of a
162+
* Fortran array. The first index (x direction for example) varies
163+
* most rapidly, the next index (y direction), if any, varies next
164+
* fastest. The component index varies last, after all the spatial
165+
* indices.
166+
*
167+
* It is sometimes convenient to be able to treat a sub-array within an
168+
* existing BaseFab as a BaseFab in its own right. This is often
169+
* referred to as aliasing the BaseFab. Note that when aliasing is
170+
* used, the BaseFabs domain will not, in general, be the same as the
171+
* parent BaseFabs domain, nor will the number of components.
172+
* BaseFab is a dimension dependent class, so SPACEDIM must be
173+
* defined as either 1, 2, or 3 when compiling.
174+
*
175+
* This is NOT a polymorphic class.
176+
*
177+
* It does NOT provide a copy constructor or assignment operator.
178+
*
179+
* \tparam T MUST have a default constructor and an assignment operator.
180+
*/
181181
template <class T>
182182
class BaseFab
183183
: public DataAllocator

Src/Base/AMReX_BoxArray.H

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -515,16 +515,16 @@ struct BATransformer
515515
// for backward compatibility
516516
using BndryBATransformer = BATransformer;
517517

518-
/**
519-
* \brief A collection of Boxes stored in an Array. It is a
520-
* reference-counted concrete class, not a polymorphic one; i.e. you
521-
* cannot use any of the List member functions with a BoxList.
522-
*/
523-
524518
class MFIter;
525519
class AmrMesh;
526520
class FabArrayBase;
527521

522+
/**
523+
* \brief A collection of Boxes stored in an Array.
524+
*
525+
* It is a reference-counted concrete class, not a polymorphic one; i.e. you
526+
* cannot use any of the List member functions with a BoxList.
527+
*/
528528
class BoxArray
529529
{
530530
public:

Src/Base/AMReX_FArrayBox.H

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class FArrayBox;
2626
* primarily for FArrayBox implementers; i.e. user's shouldn't
2727
* call any of the member functions in this class directly.
2828
*/
29-
3029
class FABio // NOLINT(cppcoreguidelines-special-member-functions)
3130
{
3231
public:
@@ -224,7 +223,6 @@ private:
224223
* This class does NOT provide a copy constructor or assignment operator,
225224
* but it has a move constructor.
226225
*/
227-
228226
class FArrayBox
229227
:
230228
public BaseFab<Real>

Src/Base/AMReX_FabArray.H

Lines changed: 61 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -56,64 +56,11 @@ Long nBytesOwned (T const&) noexcept { return 0; }
5656
template <typename T>
5757
Long nBytesOwned (BaseFab<T> const& fab) noexcept { return fab.nBytesOwned(); }
5858

59-
/*
60-
A Collection of Fortran Array-like Objects
61-
62-
63-
The FabArray<FAB> class implements a collection (stored as an array) of
64-
Fortran array-like objects. The parameterized type FAB is intended to be
65-
any class derived from BaseFab<T>. For example, FAB may be a BaseFab of
66-
integers, so we could write:
67-
68-
FabArray<BaseFab<int> > int_fabs;
69-
70-
Then int_fabs is a FabArray that can hold a collection of BaseFab<int>
71-
objects.
72-
73-
FabArray is not just a general container class for Fortran arrays. It is
74-
intended to hold "grid" data for use in finite difference calculations in
75-
which the data is defined on a union of (usually disjoint) rectangular
76-
regions embedded in a uniform index space. This region, called the valid
77-
region, is represented by a BoxArray. For the purposes of this discussion,
78-
the Kth Box in the BoxArray represents the interior region of the Kth grid.
79-
80-
Since the intent is to be used with finite difference calculations a
81-
FabArray also includes the notion of a boundary region for each grid. The
82-
boundary region is specified by the ngrow parameter which tells the FabArray
83-
to allocate each FAB to be ngrow cells larger in all directions than the
84-
underlying Box. The larger region covered by the union of all the FABs is
85-
called the region of definition. The underlying notion is that the valid
86-
region contains the grid interior data and the region of definition includes
87-
the interior region plus the boundary areas.
88-
89-
Operations are available to copy data from the valid regions into these
90-
boundary areas where the two overlap. The number of components, that is,
91-
the number of values that can be stored in each cell of a FAB, is either
92-
given as an argument to the constructor or is inherent in the definition of
93-
the underlying FAB. Each FAB in the FabArray will have the same number of
94-
components.
95-
96-
In summary, a FabArray is an array of FABs. The Kth element contains a FAB
97-
that holds the data for the Kth grid, a Box that defines the valid region
98-
of the Kth grid.
99-
100-
A typical use for a FabArray would be to hold the solution vector or
101-
right-hand-side when solving a linear system of equations on a union of
102-
rectangular grids. The copy operations would be used to copy data from the
103-
valid regions of neighboring grids into the boundary regions after each
104-
relaxation step of the iterative method. If a multigrid method is used, a
105-
FabArray could be used to hold the data at each level in the multigrid
106-
hierarchy.
107-
108-
This class is a concrete class not a polymorphic one.
109-
110-
This class does NOT provide a copy constructor or assignment operator.
111-
*/
112-
113-
//
114-
// alloc: allocate memory or not
115-
//
59+
/**
60+
* \brief FabArray memory allocation information
61+
*/
11662
struct MFInfo {
63+
// alloc: allocate memory or not
11764
bool alloc = true;
11865
Arena* arena = nullptr;
11966
Vector<std::string> tags;
@@ -314,6 +261,60 @@ Add (FabArray<FAB>& dst, FabArray<FAB> const& src, int srccomp, int dstcomp, int
314261
}
315262
}
316263

264+
/**
265+
* \brief An Array of FortranArrayBox(FAB)-like Objects
266+
*
267+
* The FabArray<FAB> class implements a collection (stored as an array) of
268+
* Fortran array box-like ( \p FAB ) objects. The parameterized type \p FAB is intended to be
269+
* any class derived from BaseFab<T>. For example, \p FAB may be a BaseFab of
270+
* integers, so we could write:
271+
*
272+
* FabArray<BaseFab<int> > int_fabs;
273+
*
274+
* Then int_fabs is a FabArray that can hold a collection of BaseFab<int>
275+
* objects.
276+
*
277+
* FabArray is not just a general container class for Fortran arrays. It is
278+
* intended to hold "grid" data for use in finite difference calculations in
279+
* which the data is defined on a union of (usually disjoint) rectangular
280+
* regions embedded in a uniform index space. This region, called the valid
281+
* region, is represented by a BoxArray. For the purposes of this discussion,
282+
* the Kth Box in the BoxArray represents the interior region of the Kth grid.
283+
*
284+
* Since the intent is to be used with finite difference calculations a
285+
* FabArray also includes the notion of a boundary region for each grid. The
286+
* boundary region is specified by the ngrow parameter which tells the FabArray
287+
* to allocate each \p FAB to be ngrow cells larger in all directions than the
288+
* underlying Box. The larger region covered by the union of all the \p FABs is
289+
* called the region of definition. The underlying notion is that the valid
290+
* region contains the grid interior data and the region of definition includes
291+
* the interior region plus the boundary areas.
292+
*
293+
* Operations are available to copy data from the valid regions into these
294+
* boundary areas where the two overlap. The number of components, that is,
295+
* the number of values that can be stored in each cell of a \p FAB, is either
296+
* given as an argument to the constructor or is inherent in the definition of
297+
* the underlying \p FAB. Each \p FAB in the FabArray will have the same number of
298+
* components.
299+
*
300+
* In summary, a FabArray is an array of \p FABs. The Kth element contains a \p FAB
301+
* that holds the data for the Kth grid, a Box that defines the valid region
302+
* of the Kth grid.
303+
*
304+
* A typical use for a FabArray would be to hold the solution vector or
305+
* right-hand-side when solving a linear system of equations on a union of
306+
* rectangular grids. The copy operations would be used to copy data from the
307+
* valid regions of neighboring grids into the boundary regions after each
308+
* relaxation step of the iterative method. If a multigrid method is used, a
309+
* FabArray could be used to hold the data at each level in the multigrid
310+
* hierarchy.
311+
*
312+
* This class is a concrete class not a polymorphic one.
313+
*
314+
* This class does NOT provide a copy constructor or assignment operator.
315+
*
316+
* \tparam FAB FortranArrayBox-like object. Typically a derived class of BaseFab. Not to be confused with FabArrayBase.
317+
*/
317318
template <class FAB>
318319
class FabArray
319320
:
@@ -338,8 +339,9 @@ public:
338339
FabArray () noexcept;
339340

340341
/**
341-
* \brief Construct an empty FabArray<FAB> that has a default Arena. If
342-
* `define` is called later with a nullptr as MFInfo's arena, the
342+
* \brief Construct an empty FabArray<FAB> that has a default Arena.
343+
*
344+
* If `define` is called later with a nullptr as MFInfo's arena, the
343345
* default Arena `a` will be used. If the arena in MFInfo is not a
344346
* nullptr, the MFInfo's arena will be used.
345347
*/

Src/Base/AMReX_FabArrayBase.H

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ template <typename FAB> class FabArray;
2828

2929
namespace EB2 { class IndexSpace; }
3030

31+
/**
32+
* \brief Base class for FabArray.
33+
*
34+
* Not to be confused with FArrayBox or `FAB` shorthands.
35+
* Can be read as FArrayBox-like Array Base.
36+
*/
3137
class FabArrayBase
3238
{
3339
friend class MFIter;

0 commit comments

Comments
 (0)