Skip to content

Improvements for hermitespline interpolation#3298

Open
dschwoerer wants to merge 36 commits intonextfrom
hermitespline
Open

Improvements for hermitespline interpolation#3298
dschwoerer wants to merge 36 commits intonextfrom
hermitespline

Conversation

@dschwoerer
Copy link
Contributor

Includes X-splitting also for monotonichermitespline and more.

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.
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 25 out of 77. Check the log or trigger a new build to see more.

/// Perhaps should only impose near boundaries, since that is where
/// problems most obviously occur.
template <bool monotonic>
class XZHermiteSplineBase : public XZInterpolation {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: member 'npe' of type 'const int' is const qualified [cppcoreguidelines-avoid-const-or-ref-data-members]

  const int npe;
            ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants