-
Notifications
You must be signed in to change notification settings - Fork 49
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
Draft: add basis transformation procedure #984
base: main
Are you sure you want to change the base?
Changes from 3 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 |
---|---|---|
|
@@ -1231,28 +1231,30 @@ int CeedBasisDestroy(CeedBasis *basis) { | |
|
||
@ref Utility | ||
**/ | ||
int CeedHaleTrefethenStripMap(CeedInt Q, CeedInt rho, CeedScalar *g, CeedScalar *g_prime) { | ||
CeedScalar tau, d, C, PI2, PI = 4.0*atan(1.0); | ||
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 = (PI * i) / Q; | ||
u[i] = (asin(PI) * i) / Q; | ||
// Unscaled function of u | ||
g_u = log(1.0 + exp(-tau * (PI2 + u))) - log(1.0 + exp(-tau * (PI2 - u))) + d * tau * u; | ||
g_prime_u = 1.0 / (exp(tau * (PI2 + u)) + 1) + 1.0 / (exp(tau * (PI2 - u)) + 1) - d; | ||
// Normalizing factor and scaled function | ||
C = 1.0 / g_u; | ||
g = C * g_u; | ||
g_prime = -tau * C ; | ||
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 quadarture points | ||
@param Q Number of quadrature points | ||
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 | ||
|
||
|
@@ -1264,10 +1266,19 @@ int CeedTransformQuadrature(CeeddInt Q, CeedScalar *q_weight_1d) { | |
if (!q_weight_1d) | ||
points = Q; | ||
else | ||
points = Q; | ||
weights = q_weight_1d; | ||
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; | ||
} | ||
|
||
|
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(); | ||
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 *s
as an argument, then writeg[i]
as a function ofs[i]
.