Skip to content

Commit 54a8da5

Browse files
committed
at-points: change at-points operators to use Chebyshev polynomials of the first kind (normalized)
1 parent bc0cf4a commit 54a8da5

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Specifically, directories set with `CeedAddJitSourceRoot(ceed, "foo/bar")` will
3030
- Added support to code generation backends `/gpu/cuda/gen` and `/gpu/hip/gen` for operators with both tensor and non-tensor bases.
3131
- Add `CeedGetGitVersion()` to access the Git commit and dirty state of the repository at build time.
3232
- Add `CeedGetBuildConfiguration()` to access compilers, flags, and related information about the build environment.
33-
- Add support for full `CeedOperator` assembly for operators with multiple active fields with different bases for CPU backends and `/gpu/cuda/ref` and `/gpu/hip/gen` backends.
33+
- Add support for full `CeedOperator` assembly for operators with multiple active fields with different bases for CPU backends and `/gpu/cuda/ref` and `/gpu/hip/gen` backends.
3434

3535
### Examples
3636

include/ceed/jit-source/cuda/cuda-ref-basis-tensor-at-points.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
template <int Q_1D>
1616
inline __device__ void ChebyshevPolynomialsAtPoint(const CeedScalar x, CeedScalar *chebyshev_x) {
1717
chebyshev_x[0] = 1.0;
18-
chebyshev_x[1] = 2 * x;
18+
chebyshev_x[1] = x;
1919
for (CeedInt i = 2; i < Q_1D; i++) chebyshev_x[i] = 2 * x * chebyshev_x[i - 1] - chebyshev_x[i - 2];
2020
}
2121

@@ -26,10 +26,11 @@ inline __device__ void ChebyshevDerivativeAtPoint(const CeedScalar x, CeedScalar
2626
chebyshev_x[1] = 1.0;
2727
chebyshev_x[2] = 2 * x;
2828
chebyshev_dx[0] = 0.0;
29-
chebyshev_dx[1] = 2.0;
29+
chebyshev_dx[1] = 1.0;
3030
for (CeedInt i = 2; i < Q_1D; i++) {
31+
// dT_i/dx = i * dU_{i-1}/dx
32+
chebyshev_dx[i] = i * chebyshev_x[i % 3];
3133
chebyshev_x[(i + 1) % 3] = 2 * x * chebyshev_x[(i + 0) % 3] - chebyshev_x[(i + 2) % 3];
32-
chebyshev_dx[i] = 2 * x * chebyshev_dx[i - 1] + 2 * chebyshev_x[(i + 0) % 3] - chebyshev_dx[i - 2];
3334
}
3435
}
3536

include/ceed/jit-source/cuda/cuda-shared-basis-tensor-at-points-templates.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
template <int Q_1D>
1616
inline __device__ void ChebyshevPolynomialsAtPoint(const CeedScalar x, CeedScalar *chebyshev_x) {
1717
chebyshev_x[0] = 1.0;
18-
chebyshev_x[1] = 2 * x;
18+
chebyshev_x[1] = x;
1919
for (CeedInt i = 2; i < Q_1D; i++) chebyshev_x[i] = 2 * x * chebyshev_x[i - 1] - chebyshev_x[i - 2];
2020
}
2121

@@ -26,10 +26,11 @@ inline __device__ void ChebyshevDerivativeAtPoint(const CeedScalar x, CeedScalar
2626
chebyshev_x[1] = 1.0;
2727
chebyshev_x[2] = 2 * x;
2828
chebyshev_dx[0] = 0.0;
29-
chebyshev_dx[1] = 2.0;
29+
chebyshev_dx[1] = 1.0;
3030
for (CeedInt i = 2; i < Q_1D; i++) {
31+
// dT_i/dx = i * dU_{i-1}/dx
32+
chebyshev_dx[i] = i * chebyshev_x[i % 3];
3133
chebyshev_x[(i + 1) % 3] = 2 * x * chebyshev_x[(i + 0) % 3] - chebyshev_x[(i + 2) % 3];
32-
chebyshev_dx[i] = 2 * x * chebyshev_dx[i - 1] + 2 * chebyshev_x[(i + 0) % 3] - chebyshev_dx[i - 2];
3334
}
3435
}
3536

interface/ceed-basis.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const CeedBasis CEED_BASIS_NONE = &ceed_basis_none;
4747
**/
4848
static int CeedChebyshevPolynomialsAtPoint(CeedScalar x, CeedInt n, CeedScalar *chebyshev_x) {
4949
chebyshev_x[0] = 1.0;
50-
chebyshev_x[1] = 2 * x;
50+
chebyshev_x[1] = x;
5151
for (CeedInt i = 2; i < n; i++) chebyshev_x[i] = 2 * x * chebyshev_x[i - 1] - chebyshev_x[i - 2];
5252
return CEED_ERROR_SUCCESS;
5353
}
@@ -69,12 +69,13 @@ static int CeedChebyshevDerivativeAtPoint(CeedScalar x, CeedInt n, CeedScalar *c
6969
chebyshev_x[1] = 1.0;
7070
chebyshev_x[2] = 2 * x;
7171
chebyshev_dx[0] = 0.0;
72-
chebyshev_dx[1] = 2.0;
72+
chebyshev_dx[1] = 1.0;
7373
for (CeedInt i = 2; i < n; i++) {
74+
// dT_i/dx = i * dU_{i-1}/dx
7475
chebyshev_x[0] = chebyshev_x[1];
7576
chebyshev_x[1] = chebyshev_x[2];
77+
chebyshev_dx[i] = i * chebyshev_x[1];
7678
chebyshev_x[2] = 2 * x * chebyshev_x[1] - chebyshev_x[0];
77-
chebyshev_dx[i] = 2 * x * chebyshev_dx[i - 1] + 2 * chebyshev_x[1] - chebyshev_dx[i - 2];
7879
}
7980
return CEED_ERROR_SUCCESS;
8081
}
@@ -607,7 +608,6 @@ static int CeedBasisApplyAtPoints_Core(CeedBasis basis, bool apply_add, CeedInt
607608
break;
608609
}
609610
case CEED_TRANSPOSE: {
610-
// Note: No switch on e_mode here because only CEED_EVAL_INTERP is supported at this time
611611
// Arbitrary points to nodes
612612
CeedScalar *chebyshev_coeffs;
613613
const CeedScalar *u_array, *x_array_read;

0 commit comments

Comments
 (0)