-
Notifications
You must be signed in to change notification settings - Fork 11
CarpetX: fix bug in hermite prolongation #347
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -187,33 +187,39 @@ template <typename T> struct coeffs1d<CC, POLY, /*order*/ 11, T> { | |
|
|
||
| // Hermite interpolation (with matched first derivatives) | ||
|
|
||
| // Linear Hermite interpolation is the same as linear Lagrange interpolation | ||
| template <typename T> struct coeffs1d<VC, HERMITE, /*order*/ 1, T> { | ||
| static constexpr std::array<T, 4> coeffs = { | ||
| +1 / T(2), | ||
| +1 / T(2), | ||
| }; | ||
| }; | ||
| // Cubic Hermite interpolation is the same as cubic Lagrange interpolation | ||
| template <typename T> struct coeffs1d<VC, HERMITE, /*order*/ 3, T> { | ||
| static constexpr std::array<T, 4> coeffs = { | ||
| -1 / T(16), | ||
| +9 / T(16), | ||
| +9 / T(16), | ||
| -1 / T(16), | ||
| static constexpr std::array<T, 6> coeffs = { | ||
| +1 / T(96), | ||
| -9 / T(96), | ||
| 56 / T(96), | ||
| 56 / T(96), | ||
| -9 / T(96), | ||
| +1 / T(96) | ||
|
Member
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. while I agree that Hermite of same order needs more points, I suspect that we may need to (same as Carpet) read "order" really as "this many ghost points" to be able to mix operators of different orders using the same number of ghost points.
Contributor
Author
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. I'm not sure. If we do that, are we forced to only mix low order of Hermite with high order other method? |
||
| }; | ||
| }; | ||
| template <typename T> struct coeffs1d<VC, HERMITE, /*order*/ 5, T> { | ||
| static constexpr std::array<T, 6> coeffs = { | ||
| +121 / T(8192), -875 / T(8192), +2425 / T(4096), | ||
| +2425 / T(4096), -875 / T(8192), +121 / T(8192), | ||
| static constexpr std::array<T, 8> coeffs = { | ||
| -28 / T(11520), | ||
| 275 / T(11520), | ||
| -1377 / T(11520), | ||
| 6890 / T(11520), | ||
| 6890 / T(11520), | ||
| -1377 / T(11520), | ||
| 275 / T(11520), | ||
| -28 / T(11520) | ||
| }; | ||
| }; | ||
| template <typename T> struct coeffs1d<VC, HERMITE, /*order*/ 7, T> { | ||
| static constexpr std::array<T, 6> coeffs = { | ||
| -129 / T(32768), +1127 / T(36864), -6419 / T(49152), | ||
| +178115 / T(294912), +178115 / T(294912), -6419 / T(49152), | ||
| +1127 / T(36864), -129 / T(32768), | ||
lwJi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| static constexpr std::array<T, 10> coeffs = { | ||
| 689 / T(1290240), | ||
| -7973 / T(1290240), | ||
| 44650 / T(1290240), | ||
| -173642 / T(1290240), | ||
| 781396 / T(1290240), | ||
| -173642 / T(1290240), | ||
| 44650 / T(1290240), | ||
| -7973 / T(1290240), | ||
| 689 / T(1290240) | ||
| }; | ||
| }; | ||
|
|
||
|
|
@@ -513,7 +519,7 @@ template <int ORDER> struct interp1d<CC, POLY, ORDER> { | |
| // off=1: between coarse points | ||
| template <int ORDER> struct interp1d<VC, HERMITE, ORDER> { | ||
| static_assert(ORDER % 2 == 1); | ||
| static constexpr int required_ghosts = (ORDER + 1) / 2; | ||
| static constexpr int required_ghosts = (ORDER + 3) / 2; | ||
| CCTK_DEVICE | ||
| CCTK_HOST constexpr | ||
| __attribute__((__always_inline__, __flatten__)) std::array<int, 2> | ||
|
|
@@ -523,7 +529,7 @@ template <int ORDER> struct interp1d<VC, HERMITE, ORDER> { | |
| #endif | ||
| if (off == 0) | ||
| return {0, 0}; | ||
| constexpr int N = ORDER + 1; | ||
| constexpr int N = ORDER + 3; | ||
| const int i0 = N / 2 - off; | ||
| return {0 - i0, N - 1 - i0}; | ||
| } | ||
|
|
@@ -537,8 +543,8 @@ template <int ORDER> struct interp1d<VC, HERMITE, ORDER> { | |
| if (off == 0) | ||
| return crse(0); | ||
|
|
||
| constexpr int N = ORDER + 1; | ||
| constexpr std::array<T, N> cs = coeffs1d<VC, POLY, N - 1, T>::coeffs; | ||
| constexpr int N = ORDER + 3; | ||
| constexpr std::array<T, N> cs = coeffs1d<VC, HERMITE, ORDER, T>::coeffs; | ||
| const int i0 = N / 2 - off; | ||
| #ifndef __CUDACC__ | ||
| constexpr int i0min = N / 2 - 1; | ||
|
|
@@ -963,7 +969,9 @@ template <int ORDER, typename T> struct test_interp1d<VC, HERMITE, ORDER, T> { | |
| // We carefully choose the test problem so that round-off | ||
| // cannot be a problem here | ||
| assert(isfinite(y1)); | ||
| assert(y1 == y); | ||
| // assert(y1 == y); | ||
| const T tol = 100 * std::numeric_limits<T>::epsilon(); | ||
| assert(std::abs(y1 - y) <= tol); | ||
|
Member
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. ah, but if we carefully chose the test problem such that roundoff is not a problem (see comment in code above) why the (hardcoded!) tol?
Contributor
Author
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. Yeah. That's just a quick fix. I can take a look and see if I can make |
||
| } | ||
| } | ||
| } | ||
|
|
||
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.
if these are actually the same as Langrangian, does it make sense to completely remove them instead and error out?
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.
I guess we can do that. If the use want to use 1st order Hermite, it can error out and say please use Poly for 1st order case