-
Notifications
You must be signed in to change notification settings - Fork 105
Make Field2D more like Field3D #3296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ab783f0
fc2dece
4d6873d
3156681
160adb4
b043da3
d37661b
48e78ec
b6b39d9
ea2ea21
8a3f82d
1f7623c
88abeb5
ec69e88
013a847
6385330
640d27d
9bb5bca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,8 @@ | |
| * | ||
| **************************************************************************/ | ||
|
|
||
| #include "bout/utils.hxx" | ||
| #include <cstddef> | ||
| class Field3D; | ||
|
|
||
| #pragma once | ||
|
|
@@ -238,15 +240,15 @@ public: | |
| * Ensure that this field has separate fields | ||
| * for yup and ydown. | ||
| */ | ||
| void splitParallelSlices(); | ||
| void splitParallelSlices() override; | ||
dschwoerer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /*! | ||
| * Clear the parallel slices, yup and ydown | ||
| */ | ||
| void clearParallelSlices(); | ||
| void clearParallelSlices() override; | ||
dschwoerer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// Check if this field has yup and ydown fields | ||
| bool hasParallelSlices() const { | ||
| bool hasParallelSlices() const override { | ||
| #if CHECK > 2 | ||
| if (yup_fields.size() != ydown_fields.size()) { | ||
| throw BoutException( | ||
|
|
@@ -263,24 +265,24 @@ public: | |
|
|
||
| /// Check if this field has yup and ydown fields | ||
| /// Return reference to yup field | ||
| Field3D& yup(std::vector<Field3D>::size_type index = 0) { | ||
| Field3D& yup(size_t index = 0) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would've thought we would also need these to be virtual to make things properly generic? Although I guess you're mostly interested in We could make these virtual by returning
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is the reason. We do not want to return Field, so there is no way to make this virtual. |
||
| ASSERT2(index < yup_fields.size()); | ||
| return yup_fields[index]; | ||
| } | ||
| /// Return const reference to yup field | ||
| const Field3D& yup(std::vector<Field3D>::size_type index = 0) const { | ||
| const Field3D& yup(size_t index = 0) const { | ||
| ASSERT2(index < yup_fields.size()); | ||
| return yup_fields[index]; | ||
| } | ||
|
|
||
| /// Return reference to ydown field | ||
| Field3D& ydown(std::vector<Field3D>::size_type index = 0) { | ||
| Field3D& ydown(size_t index = 0) { | ||
| ASSERT2(index < ydown_fields.size()); | ||
| return ydown_fields[index]; | ||
| } | ||
|
|
||
| /// Return const reference to ydown field | ||
| const Field3D& ydown(std::vector<Field3D>::size_type index = 0) const { | ||
| const Field3D& ydown(size_t index = 0) const { | ||
| ASSERT2(index < ydown_fields.size()); | ||
| return ydown_fields[index]; | ||
| } | ||
|
|
@@ -327,11 +329,11 @@ public: | |
| const Region<Ind3D>& getRegion(const std::string& region_name) const; | ||
| /// Use region provided by the default, and if none is set, use the provided one | ||
| const Region<Ind3D>& getValidRegionWithDefault(const std::string& region_name) const; | ||
| void setRegion(const std::string& region_name); | ||
| void resetRegion() { regionID.reset(); }; | ||
| void setRegion(size_t id) { regionID = id; }; | ||
| void setRegion(std::optional<size_t> id) { regionID = id; }; | ||
| std::optional<size_t> getRegionID() const { return regionID; }; | ||
| void setRegion(const std::string& region_name) override; | ||
| void resetRegion() override { regionID.reset(); }; | ||
| void setRegion(size_t id) override { regionID = id; }; | ||
dschwoerer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| void setRegion(std::optional<size_t> id) override { regionID = id; }; | ||
| std::optional<size_t> getRegionID() const override { return regionID; }; | ||
|
|
||
| /// Return a Region<Ind2D> reference to use to iterate over the x- and | ||
| /// y-indices of this field | ||
|
|
@@ -481,7 +483,7 @@ public: | |
| friend class Vector3D; | ||
| friend class Vector2D; | ||
|
|
||
| Field3D& calcParallelSlices(); | ||
| void calcParallelSlices() override; | ||
dschwoerer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| void applyBoundary(bool init = false) override; | ||
| void applyBoundary(BoutReal t); | ||
|
|
@@ -511,6 +513,9 @@ public: | |
|
|
||
| std::weak_ptr<Options> getTracking() { return tracking; }; | ||
|
|
||
| bool areCalcParallelSlicesAllowed() const { return _allowCalcParallelSlices; }; | ||
| void disallowCalcParallelSlices() { _allowCalcParallelSlices = false; }; | ||
ZedThree marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private: | ||
| /// Array sizes (from fieldmesh). These are valid only if fieldmesh is not null | ||
| int nx{-1}, ny{-1}, nz{-1}; | ||
|
|
@@ -530,6 +535,8 @@ private: | |
| /// counter for tracking, to assign unique names to the variable names | ||
| int tracking_state{0}; | ||
| std::weak_ptr<Options> tracking; | ||
|
|
||
| bool _allowCalcParallelSlices{true}; | ||
| // name is changed if we assign to the variable, while selfname is a | ||
| // non-changing copy that is used for the variable names in the dump files | ||
| std::string selfname; | ||
|
|
@@ -600,8 +607,8 @@ void checkData(const Field3D& f, const std::string& region = "RGN_NOBNDRY"); | |
| #else | ||
| /// Ignored with disabled CHECK; Throw an exception if \p f is not | ||
| /// allocated or if any elements are non-finite (for CHECK > 2) | ||
| inline void checkData(const Field3D& UNUSED(f), | ||
| const std::string& UNUSED(region) = "RGN_NOBNDRY"){}; | ||
| inline void checkData([[maybe_unused]] const Field3D& f, | ||
| [[maybe_unused]] const std::string& region = "RGN_NOBNDRY") {}; | ||
| #endif | ||
|
|
||
| /// Fourier filtering, removes all except one mode | ||
|
|
@@ -662,7 +669,7 @@ Field2D DC(const Field3D& f, const std::string& rgn = "RGN_ALL"); | |
| #if CHECK > 2 | ||
| void invalidateGuards(Field3D& var); | ||
| #else | ||
| inline void invalidateGuards(Field3D& UNUSED(var)) {} | ||
| inline void invalidateGuards([[maybe_unused]] Field3D& var) {} | ||
| #endif | ||
|
|
||
| /// Returns a reference to the time-derivative of a field \p f | ||
|
|
@@ -673,7 +680,7 @@ inline Field3D& ddt(Field3D& f) { return *(f.timeDeriv()); } | |
| /// toString template specialisation | ||
| /// Defined in utils.hxx | ||
| template <> | ||
| inline std::string toString<>(const Field3D& UNUSED(val)) { | ||
| inline std::string toString<>([[maybe_unused]] const Field3D& val) { | ||
dschwoerer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return "<Field3D>"; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.