Field3DParallel#3320
Conversation
Field3DParallel enforces that parallel derivatives can be taken. This means for FCI, parallel fields are present. It also ensures that if an operation is taken on such a field, the parallel fields are retained. This replaces part of fci-automagic, that always retained parallel fields on operations.
dicts have been preserving order for several releases now.
Otherwise, the Field3DParallel is casted to Field3D and the wrong overloads are used
The communication was a no-op, as that did never calculate the parallel fields.
They should return Field3D, not Field3DParallel
This is needed for 2D metrics, and in this case we probably want to clear the parallel fields.
the functions where implemented, but not defined in the header
Otherwise `Field3DParallel(0.0)` fails, as it constructs a `Field3D` without parallel slices, and then fails as that cannot be converted to a `Field3DParallel`
This reverts commit bd7dd2d.
| } | ||
| return Field3DParallel(*this, true); | ||
| } | ||
| const Field3DParallel Field3D::asField3DParallel() const { |
There was a problem hiding this comment.
warning: return type 'const Field3DParallel' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness [readability-const-return-type]
include/bout/field3d.hxx:546:
- inline const Field3DParallel asField3DParallel() const;
+ inline Field3DParallel asField3DParallel() const;| const Field3DParallel Field3D::asField3DParallel() const { | |
| Field3DParallel Field3D::asField3DParallel() const { |
| return bout::derivatives::index::DDY(f_parallel, outloc, method, region); | ||
| } | ||
| #endif | ||
| Field3D Coordinates::DDY(const Field3DParallel& f, CELL_LOC outloc, |
There was a problem hiding this comment.
warning: no header providing "Field3DParallel" is directly included [misc-include-cleaner]
src/mesh/coordinates.cxx:6:
- #include "bout/field_data.hxx"
+ #include "bout/field3d.hxx"
+ #include "bout/field_data.hxx"| return direction + "_" + field + slice_suffix; | ||
| }; | ||
|
|
||
| #if BOUT_USE_METRIC_3D |
There was a problem hiding this comment.
warning: no header providing "BOUT_USE_METRIC_3D" is directly included [misc-include-cleaner]
src/mesh/parallel/fci.cxx:44:
- #include "bout/field2d.hxx"
+ #include "bout/build_defines.hxx"
+ #include "bout/field2d.hxx"|
|
||
| int size() const override { return nx * ny; } | ||
|
|
||
| Field2D& asField3DParallel() { return *this; } |
There was a problem hiding this comment.
This looks potentially very confusing: surely asField3DParallel should return Field3DParallel, not Field2D?
There was a problem hiding this comment.
Indeed, it looks confusing. However, this is needed to write FA / FCI independent code.
Maybe we should rename asField3DParallel() to something along the lines of .allowYDerivatives()?
There was a problem hiding this comment.
Ah I see. Perhaps just a comment might be sufficient.
Add missing includes, add comment to potentially confusing `asField3DParallel` method that returns `Field2D`.
A field that can be used to compute parallel derivatives. For FCI that means, it has parallel slices, and will preserve them.
Any Field3D can be turned into a Field3DParallel, if it has parallel slices. If not, it will raise a runtime error, as that is not known at compile time.
This can be used to preserve parallel slices, by turning a Field3D into a Field3DParallel:
fwill have parallel slices. If f2 or f3 do not have parallel slices, this will throw an error.Includes #3334