Improvements for hermitespline interpolation#3298
Conversation
For FCI we need to be able to access "random" data from the adjacent slices. If they are split in x-direction, this requires some tricky communication pattern. It can be used like this: ``` // Create object GlobalField3DAccess fci_comm(thismesh); // let it know what data points will be required: // where IndG3D is an index in the global field, which would be the // normal Ind3D if there would be only one proc. fci_comm.get(IndG3D(i, ny, nz)); // If all index have been added, the communication pattern will be // established. This has to be called by all processors in parallel fci_comm.setup() // Once the data for a given field is needed, it needs to be // communicated: GlobalField3DAccessInstance global_data = fci_comm.communicate(f3d); // and can be accessed like this BoutReal data = global_data[IndG3D(i, ny, nz)]; // ny and nz in the IndG3D are always optional. ```
If they are two instances of the same template, this allows to have an if in the inner loop that can be optimised out.
lower_bound takes into account the data is sorted
Ensures we all ways check for monotonicity
Tags were different for sender and receiver
Otherwise mpi might wait for the wrong request.
to avoid confusion whether the offsets are for sending or receiving
Using a local set for each thread ensures we do not need a mutex for adding data, at the cost of having to merge the different sets later.
We want to skip sending if there is no data for this process ...
The result needs to be well understood, as the indices are a mix of local and global indices, as we need to access non-local data.
| /// Perhaps should only impose near boundaries, since that is where | ||
| /// problems most obviously occur. | ||
| template <bool monotonic> | ||
| class XZHermiteSplineBase : public XZInterpolation { |
There was a problem hiding this comment.
warning: class 'XZHermiteSplineBase' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
class XZHermiteSplineBase : public XZInterpolation {
^| Tensor<SpecificInd<IND_TYPE::IND_3D>> i_corner; // index of bottom-left grid point | ||
| Tensor<int> k_corner; // z-index of bottom-left grid point | ||
|
|
||
| std::unique_ptr<GlobalField3DAccess> gf3daccess; |
There was a problem hiding this comment.
warning: member variable 'gf3daccess' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]
std::unique_ptr<GlobalField3DAccess> gf3daccess;
^| Tensor<int> k_corner; // z-index of bottom-left grid point | ||
|
|
||
| std::unique_ptr<GlobalField3DAccess> gf3daccess; | ||
| Tensor<std::array<int, 4>> g3dinds; |
There was a problem hiding this comment.
warning: member variable 'g3dinds' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]
Tensor<std::array<int, 4>> g3dinds;
^| Tensor<int> k_corner; // z-index of bottom-left grid point | ||
|
|
||
| std::unique_ptr<GlobalField3DAccess> gf3daccess; | ||
| Tensor<std::array<int, 4>> g3dinds; |
There was a problem hiding this comment.
warning: no header providing "std::array" is directly included [misc-include-cleaner]
include/bout/interpolation_xz.hxx:29:
+ #include <array>| #endif | ||
|
|
||
| /// Factors to allow for some wiggleroom | ||
| BoutReal abs_fac_monotonic{1e-2}; |
There was a problem hiding this comment.
warning: member variable 'abs_fac_monotonic' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]
BoutReal abs_fac_monotonic{1e-2};
^|
|
||
| #include <vector> | ||
|
|
||
| const BoutReal& GlobalField3DAccessInstance::operator[](IndG3D ind) const { |
There was a problem hiding this comment.
warning: no header providing "BoutReal" is directly included [misc-include-cleaner]
src/mesh/parallel/fci_comm.cxx:26:
+ #include "bout/bout_types.hxx"|
|
||
| #include <vector> | ||
|
|
||
| const BoutReal& GlobalField3DAccessInstance::operator[](IndG3D ind) const { |
There was a problem hiding this comment.
warning: no header providing "IndG3D" is directly included [misc-include-cleaner]
src/mesh/parallel/fci_comm.cxx:26:
+ #include "bout/region.hxx"|
|
||
| const BoutReal& GlobalField3DAccessInstance::operator[](IndG3D ind) const { | ||
| auto it = gfa.mapping.find(ind.ind); | ||
| ASSERT2(it != gfa.mapping.end()); |
There was a problem hiding this comment.
warning: no header providing "ASSERT2" is directly included [misc-include-cleaner]
src/mesh/parallel/fci_comm.cxx:26:
+ #include "bout/assert.hxx"| int ind; | ||
| }; | ||
| struct globalToLocal1D { | ||
| const int mg; |
There was a problem hiding this comment.
warning: member 'mg' of type 'const int' is const qualified [cppcoreguidelines-avoid-const-or-ref-data-members]
const int mg;
^| }; | ||
| struct globalToLocal1D { | ||
| const int mg; | ||
| const int npe; |
There was a problem hiding this comment.
warning: member 'npe' of type 'const int' is const qualified [cppcoreguidelines-avoid-const-or-ref-data-members]
const int npe;
^
Includes X-splitting also for monotonichermitespline and more.