-
Notifications
You must be signed in to change notification settings - Fork 62
Draft: add basis transformation procedure #984
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 4 commits
70aa74e
c7b1451
74b8495
1eebdd9
6ade65d
4c3e40c
233a8d6
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 |
|---|---|---|
|
|
@@ -1219,6 +1219,69 @@ int CeedBasisDestroy(CeedBasis *basis) { | |
| return CEED_ERROR_SUCCESS; | ||
| } | ||
|
|
||
| /** | ||
| @brief Hale and Trefethen strip transformation | ||
|
|
||
| @param[in] Q Number of quadrature points | ||
| @param[in] rho sum of semiminor and major axis | ||
| @param[out] g conformal map | ||
| @param[out] g_prime derivative of conformal map g | ||
|
|
||
| @return An error code: 0 - success, otherwise - failure | ||
|
|
||
| @ref Utility | ||
| **/ | ||
| int CeedHaleTrefethenStripMap(CeedInt Q, CeedScalar rho, CeedScalar *g, CeedScalar *g_prime) { | ||
| CeedScalar i, tau, d, C, PI2, PI = 4.0*atan(1.0); | ||
| CeedScalar u[Q]; | ||
| tau = PI / log(rho); | ||
| d = .5 + 1. / (exp(tau * PI) + 1.0) | ||
| PI2 = PI / 2.0; | ||
| // u = asin(s) | ||
| for (int i = 0; i < Q; i++) { | ||
| u[i] = (asin(PI) * i) / Q; | ||
| // Unscaled function of u | ||
| g_u[i] = log(1.0 + exp(-tau * (PI2 + u[i]))) - log(1.0 + exp(-tau * (PI2 - u[i]))) + d * tau * u[i]; | ||
| g_prime_u[i] = 1.0 / (exp(tau * (PI2 + u[i])) + 1) + 1.0 / (exp(tau * (PI2 - u[i])) + 1) - d; | ||
| // Normalizing factor and scaled function of s | ||
| C = 1.0 / log(1.0 + exp(-tau * (PI2 + PI2))) - log(1.0 + exp(-tau * (PI2 - PI2))) + d * tau * PI2; | ||
| g[i] = C * g_u[i]; | ||
| g_prime[i] = -tau * C / sqrt(1.0 - sin(u[i]) * sin(u[i])) * g_prime_u[u[i]]; | ||
| } | ||
| return CEED_ERROR_SUCCESS; | ||
| } | ||
|
|
||
| /** | ||
| @brief Transform quadrature by applying a smooth mapping = (g, g_prime) | ||
|
|
||
| @param Q Number of quadrature points | ||
|
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. In general, every argument has to be documented. I don't know what you intend this function to do; maybe it can be deleted or maybe it needs to take a |
||
|
|
||
| @return An error code: 0 - success, otherwise - failure | ||
|
|
||
| @ref Utility | ||
| **/ | ||
| int CeedTransformQuadrature(CeeddInt Q, CeedScalar *q_weight_1d) { | ||
| CeedScalar points, m_points, m_weights; | ||
| if (!mapping) { | ||
| if (!q_weight_1d) | ||
| points = Q; | ||
| else | ||
| points = Q; | ||
| weights = q_weight_1d; | ||
| } | ||
|
|
||
| m_points = ; // apply map g on quadrature points | ||
| if (q_weight_1d) { | ||
| m_weights = ; //apply derivative of map g on quadrature weights evaluated at quadrature points | ||
| m_points = ; | ||
| m_weights = ; | ||
| } | ||
| else { | ||
| m_points = ; | ||
| } | ||
| return CEED_ERROR_SUCCESS; | ||
| } | ||
|
|
||
| /** | ||
| @brief Construct a Gauss-Legendre quadrature | ||
|
|
||
|
|
@@ -1270,6 +1333,8 @@ int CeedGaussQuadrature(CeedInt Q, CeedScalar *q_ref_1d, | |
| q_ref_1d[i] = -xi; | ||
| q_ref_1d[Q-1-i]= xi; | ||
| } | ||
| // Call transformed Gauss-Legendre quadrature | ||
|
||
|
|
||
| return CEED_ERROR_SUCCESS; | ||
| } | ||
|
|
||
|
|
@@ -1342,6 +1407,8 @@ int CeedLobattoQuadrature(CeedInt Q, CeedScalar *q_ref_1d, | |
| q_ref_1d[i] = -xi; | ||
| q_ref_1d[Q-1-i]= xi; | ||
| } | ||
| // Call transformed Gauss-Legendre-Lobatto quadrature | ||
|
|
||
| return CEED_ERROR_SUCCESS; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /// @file | ||
| /// Test that Hale-Trefethen transform works | ||
| /// \test Test that Hale-Trefethen transform works | ||
| #include <ceed.h> | ||
| #include <math.h> | ||
|
|
||
| int main(int argc, char **argv) { | ||
| Ceed ceed; | ||
| CeedInt Q = 16; | ||
| CeedScalar rho; | ||
| CeedScalar *g, *g_prime; | ||
|
|
||
| CeedHaleTrefethenStripMap(); | ||
|
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. |
||
|
|
||
|
|
||
| CeedDestroy(&ceed); | ||
| return 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /// @file | ||
| /// Test that quadrature formula is transformed | ||
| /// \test Test that quadrature formula is transformed | ||
| #include <ceed.h> | ||
|
|
||
| int main(int argc, char **argv) { | ||
| Ceed ceed; | ||
| CeedInt Q = 16; | ||
| CeedScalar *q_weight_1d; | ||
| CeedBasis basis; | ||
|
|
||
| CeedTransformQuadrature(); | ||
|
|
||
| CeedDestroy(&ceed) | ||
| return 0; | ||
| } |

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.
This still isn't a function$g(s)$ as we've discussed. You'll need to take

const CeedScalar *sas an argument, then writeg[i]as a function ofs[i].