-
Notifications
You must be signed in to change notification settings - Fork 95
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
Allow X splitting with FCI #2651
base: next
Are you sure you want to change the base?
Changes from 46 commits
3583476
4ec74ef
d096020
d2a81bf
ea5640f
089ddfa
de7d1de
8a1c230
8234ccf
9525e2c
b62082c
e147bc5
62d5bbe
5c32415
a4a28c6
0e28dc1
66bde04
adba877
cbaf894
5673f0c
9149bf4
a088700
32ea2fd
faac69c
0ee0d07
49cd985
4566405
4935742
01a436c
147a872
cee68f2
15aaa05
eba722b
30ea7e3
66ff716
10d320f
4b05708
60224e4
608bb5d
88741c5
09f609b
d46efba
b7786ff
e5157ad
2a9172e
25667e4
1c31c29
2e872b4
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 | ||||
---|---|---|---|---|---|---|
|
@@ -26,6 +26,15 @@ | |||||
|
||||||
#include "bout/mask.hxx" | ||||||
|
||||||
#define USE_NEW_WEIGHTS 1 | ||||||
#if BOUT_HAS_PETSC | ||||||
#define HS_USE_PETSC 1 | ||||||
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. warning: macro 'HS_USE_PETSC' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage] #define HS_USE_PETSC 1
^ |
||||||
#endif | ||||||
|
||||||
#ifdef HS_USE_PETSC | ||||||
#include "bout/petsclib.hxx" | ||||||
#endif | ||||||
|
||||||
class Options; | ||||||
|
||||||
/// Interpolate a field onto a perturbed set of points | ||||||
|
@@ -43,57 +52,52 @@ public: | |||||
protected: | ||||||
Mesh* localmesh{nullptr}; | ||||||
|
||||||
std::string region_name; | ||||||
std::shared_ptr<Region<Ind3D>> region{nullptr}; | ||||||
int region_id{-1}; | ||||||
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. warning: member variable 'region_id' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] int region_id{-1};
^ |
||||||
|
||||||
public: | ||||||
XZInterpolation(int y_offset = 0, Mesh* localmeshIn = nullptr) | ||||||
: y_offset(y_offset), | ||||||
localmesh(localmeshIn == nullptr ? bout::globals::mesh : localmeshIn) {} | ||||||
XZInterpolation(const BoutMask& mask, int y_offset = 0, Mesh* mesh = nullptr) | ||||||
: XZInterpolation(y_offset, mesh) { | ||||||
region = regionFromMask(mask, localmesh); | ||||||
setMask(mask); | ||||||
} | ||||||
XZInterpolation(const std::string& region_name, int y_offset = 0, Mesh* mesh = nullptr) | ||||||
: y_offset(y_offset), localmesh(mesh), region_name(region_name) {} | ||||||
XZInterpolation(std::shared_ptr<Region<Ind3D>> region, int y_offset = 0, | ||||||
Mesh* mesh = nullptr) | ||||||
: y_offset(y_offset), localmesh(mesh), region(std::move(region)) {} | ||||||
: y_offset(y_offset), localmesh(mesh), | ||||||
region_id(localmesh->getRegionID(region_name)) {} | ||||||
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. warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions] region_id(localmesh->getRegionID(region_name)) {}
^ |
||||||
XZInterpolation(const Region<Ind3D>& region, int y_offset = 0, Mesh* mesh = nullptr) | ||||||
: y_offset(y_offset), localmesh(mesh) { | ||||||
setRegion(region); | ||||||
} | ||||||
virtual ~XZInterpolation() = default; | ||||||
|
||||||
void setMask(const BoutMask& mask) { | ||||||
region = regionFromMask(mask, localmesh); | ||||||
region_name = ""; | ||||||
} | ||||||
void setMask(const BoutMask& mask) { setRegion(regionFromMask(mask, localmesh)); } | ||||||
void setRegion(const std::string& region_name) { | ||||||
this->region_name = region_name; | ||||||
this->region = nullptr; | ||||||
} | ||||||
void setRegion(const std::shared_ptr<Region<Ind3D>>& region) { | ||||||
this->region_name = ""; | ||||||
this->region = region; | ||||||
this->region_id = localmesh->getRegionID(region_name); | ||||||
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. warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions] this->region_id = localmesh->getRegionID(region_name);
^ |
||||||
} | ||||||
void setRegion(const std::unique_ptr<Region<Ind3D>> region) { setRegion(*region); } | ||||||
void setRegion(const Region<Ind3D>& region) { | ||||||
this->region_name = ""; | ||||||
this->region = std::make_shared<Region<Ind3D>>(region); | ||||||
std::string name; | ||||||
int i = 0; | ||||||
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. warning: variable name 'i' is too short, expected at least 3 characters [readability-identifier-length] int i = 0;
^ |
||||||
do { | ||||||
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. warning: avoid do-while loops [cppcoreguidelines-avoid-do-while] do {
^ |
||||||
name = fmt::format("unsec_reg_xz_interp_{:d}", i++); | ||||||
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. warning: variable name 'i' is too short, expected at least 3 characters [readability-identifier-length] int i = 0;
^ |
||||||
} while (localmesh->hasRegion3D(name)); | ||||||
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. warning: avoid do-while loops [cppcoreguidelines-avoid-do-while] do {
^ |
||||||
localmesh->addRegion(name, region); | ||||||
this->region_id = localmesh->getRegionID(name); | ||||||
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. warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions] this->region_id = localmesh->getRegionID(name);
^ |
||||||
} | ||||||
Region<Ind3D> getRegion() const { | ||||||
if (!region_name.empty()) { | ||||||
return localmesh->getRegion(region_name); | ||||||
} | ||||||
ASSERT1(region != nullptr); | ||||||
return *region; | ||||||
const Region<Ind3D>& getRegion() const { | ||||||
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. warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions] this->region_id = localmesh->getRegionID(name);
^ |
||||||
ASSERT2(region_id != -1); | ||||||
return localmesh->getRegion(region_id); | ||||||
} | ||||||
Region<Ind3D> getRegion(const std::string& region) const { | ||||||
const bool has_region = !region_name.empty() or this->region != nullptr; | ||||||
if (!region.empty() and region != "RGN_ALL") { | ||||||
if (has_region) { | ||||||
return intersection(localmesh->getRegion(region), getRegion()); | ||||||
} | ||||||
const Region<Ind3D>& getRegion(const std::string& region) const { | ||||||
if (region_id == -1) { | ||||||
return localmesh->getRegion(region); | ||||||
} | ||||||
ASSERT1(has_region); | ||||||
return getRegion(); | ||||||
if (region == "" or region == "RGN_ALL") { | ||||||
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. warning: the 'empty' method should be used to check for emptiness instead of comparing to an empty object [readability-container-size-empty]
Suggested change
Additional context/usr/include/c++/12/bits/basic_string.h:1190: method 'basic_string'::empty() defined here empty() const _GLIBCXX_NOEXCEPT
^ |
||||||
return getRegion(); | ||||||
} | ||||||
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. warning: the 'empty' method should be used to check for emptiness instead of comparing to an empty object [readability-container-size-empty]
Suggested change
Additional context/usr/include/c++/12/bits/basic_string.h:1190: method 'basic_string'::empty() defined here empty() const _GLIBCXX_NOEXCEPT
^ |
||||||
return localmesh->getRegion( | ||||||
localmesh->getCommonRegion(localmesh->getRegionID(region), region_id)); | ||||||
} | ||||||
virtual void calcWeights(const Field3D& delta_x, const Field3D& delta_z, | ||||||
const std::string& region = "RGN_NOBNDRY") = 0; | ||||||
|
@@ -134,8 +138,8 @@ protected: | |||||
/// This is protected rather than private so that it can be | ||||||
/// extended and used by HermiteSplineMonotonic | ||||||
|
||||||
Tensor<int> i_corner; // x-index of bottom-left grid point | ||||||
Tensor<int> k_corner; // z-index of bottom-left grid point | ||||||
Tensor<SpecificInd<IND_TYPE::IND_3D>> i_corner; // index of bottom-left grid point | ||||||
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. warning: member variable 'i_corner' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] 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 | ||||||
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. warning: member variable 'k_corner' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] Tensor<int> k_corner; // z-index of bottom-left grid point
^ |
||||||
|
||||||
// Basis functions for cubic Hermite spline interpolation | ||||||
// see http://en.wikipedia.org/wiki/Cubic_Hermite_spline | ||||||
|
@@ -152,12 +156,32 @@ protected: | |||||
Field3D h10_z; | ||||||
Field3D h11_z; | ||||||
|
||||||
std::vector<Field3D> newWeights; | ||||||
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. warning: member variable 'h11_z' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] Field3D h11_z;
^ 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. warning: member variable 'newWeights' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] std::vector<Field3D> newWeights;
^ |
||||||
|
||||||
#if HS_USE_PETSC | ||||||
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. warning: member variable 'newWeights' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] std::vector<Field3D> newWeights;
^ |
||||||
PetscLib* petsclib; | ||||||
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. warning: member variable 'petsclib' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] PetscLib* petsclib;
^ |
||||||
bool isInit{false}; | ||||||
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. warning: member variable 'isInit' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] bool isInit{false};
^ |
||||||
Mat petscWeights; | ||||||
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. warning: member variable 'petsclib' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] PetscLib* petsclib;
^ 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. warning: member variable 'petscWeights' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] Mat petscWeights;
^ |
||||||
Vec rhs, result; | ||||||
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. warning: member variable 'isInit' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] bool isInit{false};
^ 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. warning: member variable 'rhs' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] Vec rhs, result;
^ 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. warning: member variable 'result' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] Vec rhs, result;
^ |
||||||
#endif | ||||||
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. warning: member variable 'petscWeights' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] Mat petscWeights;
^ |
||||||
|
||||||
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. warning: member variable 'rhs' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] Vec rhs, result;
^ 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. warning: member variable 'result' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] Vec rhs, result;
^ |
||||||
public: | ||||||
XZHermiteSpline(Mesh* mesh = nullptr) : XZHermiteSpline(0, mesh) {} | ||||||
XZHermiteSpline(int y_offset = 0, Mesh* mesh = nullptr); | ||||||
XZHermiteSpline(const BoutMask& mask, int y_offset = 0, Mesh* mesh = nullptr) | ||||||
: XZHermiteSpline(y_offset, mesh) { | ||||||
region = regionFromMask(mask, localmesh); | ||||||
setRegion(regionFromMask(mask, localmesh)); | ||||||
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. warning: no matching member function for call to 'setRegion' [clang-diagnostic-error] setRegion(regionFromMask(mask, localmesh));
^ Additional contextinclude/bout/interpolation_xz.hxx:77: candidate function not viable: no known conversion from 'XZHermiteSpline' to 'XZInterpolation' for object argument void setRegion(const std::unique_ptr<Region<Ind3D>> region) { setRegion(*region); }
^ include/bout/interpolation_xz.hxx:74: candidate function not viable: no known conversion from 'XZHermiteSpline' to 'XZInterpolation' for object argument void setRegion(const std::string& region_name) {
^ include/bout/interpolation_xz.hxx:78: candidate function not viable: no known conversion from 'XZHermiteSpline' to 'XZInterpolation' for object argument void setRegion(const Region<Ind3D>& region) {
^ |
||||||
} | ||||||
~XZHermiteSpline() { | ||||||
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. warning: annotate this function with 'override' or (rarely) 'final' [cppcoreguidelines-explicit-virtual-functions]
Suggested change
|
||||||
#if HS_USE_PETSC | ||||||
if (isInit) { | ||||||
MatDestroy(&petscWeights); | ||||||
VecDestroy(&rhs); | ||||||
VecDestroy(&result); | ||||||
isInit = false; | ||||||
delete petsclib; | ||||||
} | ||||||
#endif | ||||||
} | ||||||
|
||||||
void calcWeights(const Field3D& delta_x, const Field3D& delta_z, | ||||||
|
@@ -188,11 +212,23 @@ public: | |||||
/// problems most obviously occur. | ||||||
class XZMonotonicHermiteSpline : public XZHermiteSpline { | ||||||
public: | ||||||
XZMonotonicHermiteSpline(Mesh* mesh = nullptr) : XZHermiteSpline(0, mesh) {} | ||||||
XZMonotonicHermiteSpline(Mesh* mesh = nullptr) : XZHermiteSpline(0, mesh) { | ||||||
if (localmesh->getNXPE() > 1) { | ||||||
throw BoutException("Do not support MPI splitting in X"); | ||||||
} | ||||||
} | ||||||
XZMonotonicHermiteSpline(int y_offset = 0, Mesh* mesh = nullptr) | ||||||
: XZHermiteSpline(y_offset, mesh) {} | ||||||
: XZHermiteSpline(y_offset, mesh) { | ||||||
if (localmesh->getNXPE() > 1) { | ||||||
throw BoutException("Do not support MPI splitting in X"); | ||||||
} | ||||||
} | ||||||
XZMonotonicHermiteSpline(const BoutMask& mask, int y_offset = 0, Mesh* mesh = nullptr) | ||||||
: XZHermiteSpline(mask, y_offset, mesh) {} | ||||||
: XZHermiteSpline(mask, y_offset, mesh) { | ||||||
if (localmesh->getNXPE() > 1) { | ||||||
throw BoutException("Do not support MPI splitting in X"); | ||||||
} | ||||||
} | ||||||
|
||||||
using XZHermiteSpline::interpolate; | ||||||
/// Interpolate using precalculated weights. | ||||||
|
@@ -213,7 +249,7 @@ public: | |||||
XZLagrange4pt(int y_offset = 0, Mesh* mesh = nullptr); | ||||||
XZLagrange4pt(const BoutMask& mask, int y_offset = 0, Mesh* mesh = nullptr) | ||||||
: XZLagrange4pt(y_offset, mesh) { | ||||||
region = regionFromMask(mask, localmesh); | ||||||
setRegion(regionFromMask(mask, localmesh)); | ||||||
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. warning: no matching member function for call to 'setRegion' [clang-diagnostic-error] setRegion(regionFromMask(mask, localmesh));
^ Additional contextinclude/bout/interpolation_xz.hxx:77: candidate function not viable: no known conversion from 'XZLagrange4pt' to 'XZInterpolation' for object argument void setRegion(const std::unique_ptr<Region<Ind3D>> region) { setRegion(*region); }
^ include/bout/interpolation_xz.hxx:74: candidate function not viable: no known conversion from 'XZLagrange4pt' to 'XZInterpolation' for object argument void setRegion(const std::string& region_name) {
^ include/bout/interpolation_xz.hxx:78: candidate function not viable: no known conversion from 'XZLagrange4pt' to 'XZInterpolation' for object argument void setRegion(const Region<Ind3D>& region) {
^ |
||||||
} | ||||||
|
||||||
void calcWeights(const Field3D& delta_x, const Field3D& delta_z, | ||||||
|
@@ -246,7 +282,7 @@ public: | |||||
XZBilinear(int y_offset = 0, Mesh* mesh = nullptr); | ||||||
XZBilinear(const BoutMask& mask, int y_offset = 0, Mesh* mesh = nullptr) | ||||||
: XZBilinear(y_offset, mesh) { | ||||||
region = regionFromMask(mask, localmesh); | ||||||
setRegion(regionFromMask(mask, localmesh)); | ||||||
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. warning: no matching member function for call to 'setRegion' [clang-diagnostic-error] setRegion(regionFromMask(mask, localmesh));
^ Additional contextinclude/bout/interpolation_xz.hxx:77: candidate function not viable: no known conversion from 'XZBilinear' to 'XZInterpolation' for object argument void setRegion(const std::unique_ptr<Region<Ind3D>> region) { setRegion(*region); }
^ include/bout/interpolation_xz.hxx:74: candidate function not viable: no known conversion from 'XZBilinear' to 'XZInterpolation' for object argument void setRegion(const std::string& region_name) {
^ include/bout/interpolation_xz.hxx:78: candidate function not viable: no known conversion from 'XZBilinear' to 'XZInterpolation' for object argument void setRegion(const Region<Ind3D>& region) {
^ |
||||||
} | ||||||
|
||||||
void calcWeights(const Field3D& delta_x, const Field3D& delta_z, | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: macro 'USE_NEW_WEIGHTS' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage]