Port some Hermes-3 finite volume operators (rebased)#3335
Port some Hermes-3 finite volume operators (rebased)#3335dschwoerer wants to merge 107 commits intonextfrom
Conversation
Includes bug fix: ```diff - BoutReal gL = n.c - n.L; - BoutReal gR = n.R - n.c; + BoutReal gL = n.c - n.m; + BoutReal gR = n.p - n.c; ```
Co-authored-by: Peter Hill <peter.hill@york.ac.uk>
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.
This reverts commit bd7dd2d.
|
|
||
| template <typename T> | ||
| auto& getStore() { | ||
| if constexpr (std::is_same<T, Field3DParallel>::value) { |
There was a problem hiding this comment.
warning: no header providing "Field3DParallel" is directly included [misc-include-cleaner]
include/bout/deriv_store.hxx:37:
- #include <bout/scorepwrapper.hxx>
+ #include "bout/field3d.hxx"
+ #include <bout/scorepwrapper.hxx>|
|
||
| template <typename T> | ||
| auto& getStore() { | ||
| if constexpr (std::is_same<T, Field3DParallel>::value) { |
There was a problem hiding this comment.
warning: no header providing "std::is_same" is directly included [misc-include-cleaner]
include/bout/deriv_store.hxx:35:
- #include <unordered_map>
+ #include <type_traits>
+ #include <unordered_map>| template <typename T> | ||
| auto& getStore() { | ||
| if constexpr (std::is_same<T, Field3DParallel>::value) { | ||
| return DerivativeStore<Field3D>::getInstance(); |
There was a problem hiding this comment.
warning: no header providing "Field3D" is directly included [misc-include-cleaner]
return DerivativeStore<Field3D>::getInstance();
^| } | ||
| 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:544:
- inline const Field3DParallel asField3DParallel() const;
+ inline Field3DParallel asField3DParallel() const;| const Field3DParallel Field3D::asField3DParallel() const { | |
| Field3DParallel Field3D::asField3DParallel() const { |
| for (size_t i = 0; i < result.numberParallelSlices(); ++i) { | ||
| result.yup(i).allocate(); | ||
| BOUT_FOR(d, result.yup(i).getValidRegionWithDefault("RGN_INVALID")) { | ||
| result.yup(i)[d] = func(i + 1, d); |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]
result.yup(i)[d] = func(i + 1, d);
^| #include "bout/unused.hxx" | ||
| #include "bout/utils.hxx" | ||
| #include "bout/vecops.hxx" | ||
|
|
There was a problem hiding this comment.
warning: included header vecops.hxx is not used directly [misc-include-cleaner]
|
|
||
| namespace { | ||
| // Get a unique name for a field based on the sign/magnitude of the offset | ||
| std::string parallel_slice_field_name(std::string field, int offset) { |
There was a problem hiding this comment.
warning: the parameter 'field' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
| std::string parallel_slice_field_name(std::string field, int offset) { | |
| std::string parallel_slice_field_name(const std::string& field, int offset) { |
| 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:43:
- #include "bout/field2d.hxx"
+ #include "bout/build_defines.hxx"
+ #include "bout/field2d.hxx"| output_options["Z"].force(Z, "FCI"); | ||
| } | ||
|
|
||
| void FCITransform::loadParallelMetrics(Coordinates* coords) { |
There was a problem hiding this comment.
warning: unused parameter 'coords' [clang-diagnostic-unused-parameter]
void FCITransform::loadParallelMetrics(Coordinates* coords) {
^| ////////////// Y DERIVATIVE ///////////////// | ||
|
|
||
| Field3D DDY(const Field3D& f, CELL_LOC outloc, const std::string& method, | ||
| Field3D DDY(const Field3DParallel& f, CELL_LOC outloc, const std::string& method, |
There was a problem hiding this comment.
warning: no header providing "Field3DParallel" is directly included [misc-include-cleaner]
Field3D DDY(const Field3DParallel& f, CELL_LOC outloc, const std::string& method,
^
Rebase of #3200 on top of #3320 and #3334