11#ifndef BOUT_FIELDGROUP_H
22#define BOUT_FIELDGROUP_H
33
4- #include " bout/field_data.hxx"
5- #include < bout/field3d.hxx>
6-
4+ #include < bout/traits.hxx>
75#include < bout/vector2d.hxx>
86#include < bout/vector3d.hxx>
97
108#include < vector>
119
12- #include < algorithm>
10+ class Field2D ;
11+ class Field3D ;
12+ class FieldPerp ;
13+ class Field ;
1314
1415// / Group together fields for easier communication
1516// /
16- // / Note: The FieldData class is used as a base class,
17- // / which is inherited by Field2D, Field3D, Vector2D and Vector3D
18- // / however Vector2D and Vector3D are stored by reference to their
19- // / components (x,y,z) as Field2D or Field3D objects.
17+ // / Note: The `Field` class is used as a base class,
18+ // / which is inherited by ` Field2D`, ` Field3D`, `FieldPerp`;
19+ // / however ` Vector2D` and ` Vector3D` are stored by reference to their
20+ // / components `` (x, y, z)`` as ` Field2D` or ` Field3D` objects.
2021class FieldGroup {
2122public:
2223 FieldGroup () = default ;
2324 FieldGroup (const FieldGroup& other) = default ;
2425 FieldGroup (FieldGroup&& other) = default ;
2526 FieldGroup& operator =(const FieldGroup& other) = default ;
2627 FieldGroup& operator =(FieldGroup&& other) = default ;
28+ ~FieldGroup () = default ;
2729
28- // / Constructor with a single FieldData \p f
29- FieldGroup (FieldData& f) { fvec.push_back (&f); }
30-
31- // / Constructor with a single Field3D \p f
30+ FieldGroup (Field& f) { fvec.push_back (&f); }
3231 FieldGroup (Field3D& f) {
3332 fvec.push_back (&f);
3433 f3vec.push_back (&f);
@@ -56,7 +55,7 @@ public:
5655 }
5756
5857 // / Variadic constructor. Allows an arbitrary number of
59- // / FieldData arguments
58+ // / Field arguments
6059 // /
6160 // / The explicit keyword prevents FieldGroup being constructed with arbitrary
6261 // / types. In particular arguments to add() cannot be implicitly converted
@@ -78,12 +77,12 @@ public:
7877 return *this ;
7978 }
8079
81- // / Add a FieldData \p f to the group.
80+ // / Add a Field \p f to the group.
8281 // /
8382 // / A pointer to this field will be stored internally,
8483 // / so the lifetime of this variable should be longer
8584 // / than the lifetime of this group.
86- void add (FieldData & f) { fvec.push_back (&f); }
85+ void add (Field & f) { fvec.push_back (&f); }
8786
8887 // Add a 3D field \p f, which goes into both vectors.
8988 //
@@ -121,18 +120,8 @@ public:
121120 }
122121
123122 // / Add multiple fields to this group
124- // /
125- // / This is a variadic template which allows Field3D objects to be
126- // / treated as a special case. An arbitrary number of fields can be
127- // / added.
128- template <typename ... Ts>
129- void add (FieldData& t, Ts&... ts) {
130- add (t); // Add the first using functions above
131- add (ts...); // Add the rest
132- }
133-
134123 template <typename ... Ts>
135- void add (Field3D & t, Ts&... ts) {
124+ void add (Field & t, Ts&... ts) {
136125 add (t); // Add the first using functions above
137126 add (ts...); // Add the rest
138127 }
@@ -165,16 +154,14 @@ public:
165154 }
166155
167156 // / Iteration over all fields
168- using iterator = std::vector<FieldData*>::iterator;
169- iterator begin () { return fvec.begin (); }
170- iterator end () { return fvec.end (); }
157+ auto begin () { return fvec.begin (); }
158+ auto end () { return fvec.end (); }
171159
172160 // / Const iteration over all fields
173- using const_iterator = std::vector<FieldData*>::const_iterator;
174- const_iterator begin () const { return fvec.begin (); }
175- const_iterator end () const { return fvec.end (); }
161+ auto begin () const { return fvec.cbegin (); }
162+ auto end () const { return fvec.cend (); }
176163
177- const std::vector<FieldData *>& get () const { return fvec; }
164+ const std::vector<Field *>& get () const { return fvec; }
178165
179166 // / Iteration over 3D fields
180167 const std::vector<Field3D*>& field3d () const { return f3vec; }
@@ -183,8 +170,8 @@ public:
183170 void makeUnique ();
184171
185172private:
186- std::vector<FieldData *> fvec; // Vector of fields
187- std::vector<Field3D*> f3vec; // Vector of 3D fields
173+ std::vector<Field *> fvec; // Vector of fields
174+ std::vector<Field3D*> f3vec; // Vector of 3D fields
188175};
189176
190177// / Combine two FieldGroups
0 commit comments