-
Notifications
You must be signed in to change notification settings - Fork 24
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
absolute tagging #902
absolute tagging #902
Changes from all commits
6822967
0f755f9
1fa03ba
85df275
f5f2f05
e513179
d03d643
08ce776
b7b6db9
4c99903
fef5511
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 | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -108,9 +108,10 @@ void DefaultHybridTaggerStrategy<HybridModel>::tag(HybridModel& model, | |||||||||||||||||
{ | ||||||||||||||||||
auto field_diff = [&](auto const& F) // | ||||||||||||||||||
{ | ||||||||||||||||||
return std::make_tuple( | ||||||||||||||||||
std::abs((F(ix + 2, iy) - F(ix, iy)) / (1 + F(ix + 1, iy) - F(ix, iy))), | ||||||||||||||||||
std::abs((F(ix, iy + 2) - F(ix, iy)) / (F(ix, iy + 1) - F(ix, iy) + 1))); | ||||||||||||||||||
return std::make_tuple(std::abs((F(ix + 2, iy) - F(ix, iy)) | ||||||||||||||||||
/ (1 + std::abs(F(ix + 1, iy) - F(ix, iy)))), | ||||||||||||||||||
std::abs(F(ix, iy + 2) - F(ix, iy)) | ||||||||||||||||||
/ (std::abs(F(ix, iy + 1) - F(ix, iy)) + 1)); | ||||||||||||||||||
Comment on lines
+111
to
+114
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. 🛠️ Refactor suggestion Approved: Changes align with PR objectives and improve formula consistency. The modifications to the A minor optimization suggestion: Consider factoring out the common return std::make_tuple(std::abs((F(ix + 2, iy) - F(ix, iy))
/ (1 + std::abs(F(ix + 1, iy) - F(ix, iy)))),
std::abs(F(ix, iy + 2) - F(ix, iy))
- / (std::abs(F(ix, iy + 1) - F(ix, iy)) + 1));
+ / (1 + std::abs(F(ix, iy + 1) - F(ix, iy)))); This change makes the second tuple element consistent with the first one and potentially improves readability. 📝 Committable suggestion
Suggested change
|
||||||||||||||||||
}; | ||||||||||||||||||
|
||||||||||||||||||
auto const& [Bx_x, Bx_y] = field_diff(Bx); | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -112,14 +112,15 @@ namespace core | |||||
GridLayout(std::array<double, dimension> const& meshSize, | ||||||
std::array<std::uint32_t, dimension> const& nbrCells, | ||||||
Point<double, dimension> const& origin, | ||||||
Box<int, dimension> AMRBox = Box<int, dimension>{}) | ||||||
Box<int, dimension> AMRBox = Box<int, dimension>{}, int level_number = 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. Ensure consistent parameter type for The new constructor parameter Apply this diff to change the parameter type: -Box<int, dimension> AMRBox = Box<int, dimension>{}, int level_number = 0)
+Box<int, dimension> AMRBox = Box<int, dimension>{}, std::size_t level_number = 0) 📝 Committable suggestion
Suggested change
|
||||||
: meshSize_{meshSize} | ||||||
, origin_{origin} | ||||||
, nbrPhysicalCells_{nbrCells} | ||||||
, physicalStartIndexTable_{initPhysicalStart_()} | ||||||
, physicalEndIndexTable_{initPhysicalEnd_()} | ||||||
, ghostEndIndexTable_{initGhostEnd_()} | ||||||
, AMRBox_{AMRBox} | ||||||
, levelNumber_{level_number} | ||||||
{ | ||||||
if (AMRBox_.isEmpty()) | ||||||
{ | ||||||
|
@@ -1073,6 +1074,7 @@ namespace core | |||||
*/ | ||||||
NO_DISCARD auto static constexpr JzToMoments() { return GridLayoutImpl::JzToMoments(); } | ||||||
|
||||||
NO_DISCARD auto static constexpr BxToEx() { return GridLayoutImpl::BxToEx(); } | ||||||
|
||||||
/** | ||||||
* @brief ByToEx return the indexes and associated coef to compute the linear | ||||||
|
@@ -1088,13 +1090,15 @@ namespace core | |||||
NO_DISCARD auto static constexpr BzToEx() { return GridLayoutImpl::BzToEx(); } | ||||||
|
||||||
|
||||||
|
||||||
/** | ||||||
* @brief BxToEy return the indexes and associated coef to compute the linear | ||||||
* interpolation necessary to project Bx onto Ey. | ||||||
*/ | ||||||
NO_DISCARD auto static constexpr BxToEy() { return GridLayoutImpl::BxToEy(); } | ||||||
|
||||||
|
||||||
NO_DISCARD auto static constexpr ByToEy() { return GridLayoutImpl::ByToEy(); } | ||||||
|
||||||
/** | ||||||
* @brief BzToEy return the indexes and associated coef to compute the linear | ||||||
|
@@ -1118,6 +1122,8 @@ namespace core | |||||
*/ | ||||||
NO_DISCARD auto static constexpr ByToEz() { return GridLayoutImpl::ByToEz(); } | ||||||
|
||||||
NO_DISCARD auto static constexpr BzToEz() { return GridLayoutImpl::BzToEz(); } | ||||||
|
||||||
|
||||||
|
||||||
/** | ||||||
|
@@ -1165,6 +1171,7 @@ namespace core | |||||
evalOnBox_(field, fn, indices); | ||||||
} | ||||||
|
||||||
auto levelNumber() const { return levelNumber_; } | ||||||
|
||||||
private: | ||||||
template<typename Field, typename IndicesFn, typename Fn> | ||||||
|
@@ -1508,6 +1515,8 @@ namespace core | |||||
// arrays will be accessed with [primal] and [dual] indexes. | ||||||
constexpr static std::array<int, 2> nextIndexTable_{{nextPrimal_(), nextDual_()}}; | ||||||
constexpr static std::array<int, 2> prevIndexTable_{{prevPrimal_(), prevDual_()}}; | ||||||
|
||||||
int levelNumber_ = 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. 🛠️ Refactor suggestion Consider using Since Apply this diff: -int levelNumber_;
+std::size_t levelNumber_; 📝 Committable suggestion
Suggested change
|
||||||
}; | ||||||
|
||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -685,6 +685,47 @@ namespace core | |
} | ||
} | ||
|
||
NO_DISCARD auto static constexpr BxToEx() | ||
{ | ||
// Bx is primal dual dual | ||
// Ex is dual primal primal | ||
// operation is pdd to dpp | ||
[[maybe_unused]] auto constexpr p2dShift = primalToDual(); | ||
[[maybe_unused]] auto constexpr d2pShift = dualToPrimal(); | ||
|
||
if constexpr (dimension == 1) | ||
{ | ||
constexpr WeightPoint<dimension> P1{Point<int, dimension>{0}, 0.5}; | ||
constexpr WeightPoint<dimension> P2{Point<int, dimension>{p2dShift}, 0.5}; | ||
return std::array<WeightPoint<dimension>, 2>{P1, P2}; | ||
} | ||
else if constexpr (dimension == 2) | ||
{ | ||
constexpr WeightPoint<dimension> P1{Point<int, dimension>{0, 0}, 0.25}; | ||
constexpr WeightPoint<dimension> P2{Point<int, dimension>{0, d2pShift}, 0.25}; | ||
constexpr WeightPoint<dimension> P3{Point<int, dimension>{p2dShift, 0}, 0.25}; | ||
constexpr WeightPoint<dimension> P4{Point<int, dimension>{p2dShift, d2pShift}, | ||
0.25}; | ||
return std::array<WeightPoint<dimension>, 4>{P1, P2, P3, P4}; | ||
} | ||
else if constexpr (dimension == 3) | ||
{ | ||
constexpr WeightPoint<dimension> P1{Point<int, dimension>{0, 0, 0}, 0.125}; | ||
constexpr WeightPoint<dimension> P2{Point<int, dimension>{0, d2pShift, 0}, 0.125}; | ||
constexpr WeightPoint<dimension> P3{Point<int, dimension>{p2dShift, 0, 0}, 0.125}; | ||
constexpr WeightPoint<dimension> P4{Point<int, dimension>{p2dShift, d2pShift, 0}, | ||
0.125}; | ||
|
||
constexpr WeightPoint<dimension> P5{Point<int, dimension>{0, 0, d2pShift}, 0.125}; | ||
constexpr WeightPoint<dimension> P6{Point<int, dimension>{0, d2pShift, d2pShift}, | ||
0.125}; | ||
constexpr WeightPoint<dimension> P7{Point<int, dimension>{p2dShift, 0, d2pShift}, | ||
0.125}; | ||
constexpr WeightPoint<dimension> P8{ | ||
Point<int, dimension>{p2dShift, d2pShift, d2pShift}, 0.125}; | ||
return std::array<WeightPoint<dimension>, 8>{P1, P2, P3, P4, P5, P6, P7, P8}; | ||
} | ||
} | ||
Comment on lines
+688
to
+728
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. 🛠️ Refactor suggestion Consider refactoring The |
||
|
||
|
||
NO_DISCARD auto static constexpr ByToEx() | ||
|
@@ -744,6 +785,47 @@ namespace core | |
} | ||
|
||
|
||
NO_DISCARD auto static constexpr BzToEz() | ||
{ | ||
// Bz is dual dual primal | ||
// Ez is primal primal dual | ||
// operation is thus ddp to ppd | ||
auto constexpr p2dShift = primalToDual(); | ||
auto constexpr d2pShift = dualToPrimal(); | ||
|
||
if constexpr (dimension == 1) | ||
{ | ||
constexpr WeightPoint<dimension> P1{Point<int, dimension>{0}, 0.5}; | ||
constexpr WeightPoint<dimension> P2{Point<int, dimension>{d2pShift}, 0.5}; | ||
return std::array<WeightPoint<dimension>, 2>{P1, P2}; | ||
} | ||
|
||
else if constexpr (dimension == 2) | ||
{ | ||
constexpr WeightPoint<dimension> P1{Point<int, dimension>{0, 0}, 0.25}; | ||
constexpr WeightPoint<dimension> P2{Point<int, dimension>{d2pShift, 0}, 0.25}; | ||
constexpr WeightPoint<dimension> P3{Point<int, dimension>{0, d2pShift}, 0.25}; | ||
constexpr WeightPoint<dimension> P4{Point<int, dimension>{d2pShift, d2pShift}, | ||
0.25}; | ||
return std::array<WeightPoint<dimension>, 4>{P1, P2, P3, P4}; | ||
} | ||
else if constexpr (dimension == 3) | ||
{ | ||
constexpr WeightPoint<dimension> P1{Point<int, dimension>{0, 0, 0}, 0.25}; | ||
constexpr WeightPoint<dimension> P2{Point<int, dimension>{d2pShift, 0, 0}, 0.25}; | ||
constexpr WeightPoint<dimension> P3{Point<int, dimension>{0, d2pShift, 0}, 0.25}; | ||
constexpr WeightPoint<dimension> P4{Point<int, dimension>{d2pShift, d2pShift, 0}, | ||
0.25}; | ||
constexpr WeightPoint<dimension> P5{Point<int, dimension>{0, 0, p2dShift}, 0.25}; | ||
constexpr WeightPoint<dimension> P6{Point<int, dimension>{d2pShift, 0, p2dShift}, | ||
0.25}; | ||
constexpr WeightPoint<dimension> P7{Point<int, dimension>{0, d2pShift, p2dShift}, | ||
0.25}; | ||
constexpr WeightPoint<dimension> P8{ | ||
Point<int, dimension>{d2pShift, d2pShift, p2dShift}, 0.25}; | ||
return std::array<WeightPoint<dimension>, 8>{P1, P2, P3, P4, P5, P6, P7, P8}; | ||
} | ||
} | ||
|
||
|
||
NO_DISCARD auto static constexpr ByToEz() | ||
|
@@ -838,6 +920,46 @@ namespace core | |
} | ||
|
||
|
||
NO_DISCARD auto static constexpr ByToEy() | ||
{ | ||
// By is dual primal dual | ||
// Ey is primal dual primal | ||
// the operation is thus dpd to pdp | ||
auto constexpr p2dShift = primalToDual(); | ||
auto constexpr d2pShift = dualToPrimal(); | ||
|
||
if constexpr (dimension == 1) | ||
{ | ||
constexpr WeightPoint<dimension> P1{Point<int, dimension>{0}, 0.5}; | ||
constexpr WeightPoint<dimension> P2{Point<int, dimension>{d2pShift}, 0.5}; | ||
return std::array<WeightPoint<dimension>, 2>{P1, P2}; | ||
} | ||
else if constexpr (dimension == 2) | ||
{ | ||
constexpr WeightPoint<dimension> P1{Point<int, dimension>{0, 0}, 0.25}; | ||
constexpr WeightPoint<dimension> P2{Point<int, dimension>{d2pShift, 0}, 0.25}; | ||
constexpr WeightPoint<dimension> P3{Point<int, dimension>{0, p2dShift}, 0.25}; | ||
constexpr WeightPoint<dimension> P4{Point<int, dimension>{d2pShift, p2dShift}, | ||
0.25}; | ||
return std::array<WeightPoint<dimension>, 4>{P1, P2, P3, P4}; | ||
} | ||
else if constexpr (dimension == 3) | ||
{ | ||
constexpr WeightPoint<dimension> P1{Point<int, dimension>{0, 0, 0}, 0.25}; | ||
constexpr WeightPoint<dimension> P2{Point<int, dimension>{d2pShift, 0, 0}, 0.25}; | ||
constexpr WeightPoint<dimension> P3{Point<int, dimension>{0, p2dShift, 0}, 0.25}; | ||
constexpr WeightPoint<dimension> P4{Point<int, dimension>{d2pShift, p2dShift, 0}, | ||
0.25}; | ||
constexpr WeightPoint<dimension> P5{Point<int, dimension>{0, 0, d2pShift}, 0.25}; | ||
constexpr WeightPoint<dimension> P6{Point<int, dimension>{d2pShift, 0, d2pShift}, | ||
0.25}; | ||
constexpr WeightPoint<dimension> P7{Point<int, dimension>{0, p2dShift, d2pShift}, | ||
0.25}; | ||
constexpr WeightPoint<dimension> P8{ | ||
Point<int, dimension>{d2pShift, p2dShift, d2pShift}, 0.25}; | ||
return std::array<WeightPoint<dimension>, 8>{P1, P2, P3, P4, P5, P6, P7, P8}; | ||
} | ||
} | ||
|
||
|
||
NO_DISCARD auto static constexpr BzToEy() | ||
|
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.
🛠️ Refactor suggestion
Consider improving backwards compatibility and documentation
The addition of the patch level number (
lvlNbr
) to theGridLayoutT
constructor is a valuable change that can enhance level-specific operations and debugging. However, this modification has some implications:layoutFromPatch
.To address these issues:
Consider using a default parameter to maintain backwards compatibility:
If
lvlNbr
is not provided, you can still obtain it frompatch.getPatchLevelNumber()
.Update the function documentation to describe the new
lvlNbr
parameter and its purpose.Here's a suggested implementation with improved documentation:
This approach maintains backwards compatibility while allowing explicit specification of the level number when needed.