-
Notifications
You must be signed in to change notification settings - Fork 99
Pyramids #623
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
Pyramids #623
Conversation
src/interpolations.jl
Outdated
zzero = z ≈ 1.0 | ||
i == 1 && return zzero ? 0.0 : (-x*y+(z-1)*(-x-y-z+1))/(z-1) |

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 means the derivative can't be evaluated at z = 1.0
(truncating the dual part of the input, so it will have 0 derivative).

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.
At least not until ForwardDiff 0.16.
But this is discontinuous around z = 1? Is that intended?
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 used this as ref https://defelement.com/elements/examples/pyramid-Lagrange-1.html
I think that the pyramid is degenerate at the fifth node. But note that N_I = 1 at node I, and zero at the other nodes is still true for pyramids
Maybe @termi-official has some insight regarding pyramid elements
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.
One of the basis functions is If you want the derivative at this specific point you can formulate y and x as a function of z and apply l'Hospital.
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.
Wieners, C. (1997). Conforming discretizations on tetrahedrons, pyramids, prisms and hexahedrons. Preprint, University of Stuttgart. has a proof that there exists no continuous differentiable (bi-)linear function on pyramids.
src/interpolations.jl
Outdated
i == 2 && return zzero ? 0.0 : x*(y+z-1)/(z-1) | ||
i == 3 && return zzero ? 0.0 : -x*y/(z-1) | ||
i == 4 && return zzero ? 0.0 : y*(x+z-1)/(z-1) | ||
i == 5 && return zzero ? 1.0 : z |
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 one is at least not problematic:
i == 5 && return zzero ? 1.0 : z | |
i == 5 && return z |
For the other ones, if we are sufficiently close to z = 1, can we replac them with expressions that have the same value and derivative in the limit perhaps?
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.
There is no derivative at and close to z=1 with x=y=0. See e.g. l'Hospital on the basis function i=3
with the coordinates x and y depending on z gives you
src/docs.jl
Outdated
Vertex numbers: | Vertex coordinates: | ||
| v1: 𝛏 = (-1.0, -1.0, -1.0) | ||
5 -. _ 5 -. _ | v2: 𝛏 = ( 1.0, -1.0, -1.0) | ||
| \ \._ |\ \._ | v3: 𝛏 = ( 1.0, 1.0, -1.0) | ||
^ ξ₃ | \ \ _ | \ \ _ | v4: 𝛏 = (-1.0, 1.0, -1.0) | ||
| ξ₂ | \ 3 | 4--------- 3 | v5: 𝛏 = (-1.0, -1.0, 1.0) | ||
| / | \ / | / / | v6: 𝛏 = ( 1.0, -1.0, 1.0) | ||
|/_ _ | \ / |/ / | v7: 𝛏 = ( 1.0, 1.0, 1.0) | ||
ξ₁ 1----------2 1----------2 | v8: 𝛏 = (-1.0, 1.0, 1.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.
I think the coordinates are wrong.
src/docs.jl
Outdated
+----8---+ +----8---+ | | ||
5/ /| 5/| | | e1: (v1, v2), e2: (v2, v3) | ||
/ 7/ |12 / |9 12| | e3: (v3, v4), e4: (v4, v1) | ||
+----6---+ | + | | | e5: (v5, v6), e6: (v6, v7) | ||
| | + | +---4----+ | e7: (v7, v8), e8: (v8, v5) | ||
10| 11| / 10| /1 / | e9: (v1, v5), e10: (v2, v6) | ||
| |/3 |/ /3 | e11: (v3, v7), e12: (v4, v8) | ||
+---2----+ +---2----+ | |
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 think the edge numbering and picture is wrong.
|
I added quadratic interpolations aswell. I also noticed that I had not used defelements numberings scheme, so I updated that aswell. (Note however that did not match VTK numbering scheme for pyramids) The quadratic elements does not coverge for the heat equations problem, so there is something wrong... |
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## master #623 +/- ##
==========================================
- Coverage 92.40% 91.88% -0.53%
==========================================
Files 32 33 +1
Lines 4779 4916 +137
==========================================
+ Hits 4416 4517 +101
- Misses 363 399 +36
☔ View full report in Codecov by Sentry. |
The quadratic interpolation for pyramids does not converge for some reason, even though in passes all the tests in test_interpolation.jl. I have double checked with defelements, and I am using the same numbering scheme. @termi-official Any idea what the issue could be? 🤔 |
The quadrature rule seems to be broken. Choose N=20 and qr order=3 for the linear element and it also diverges. |
Ok thanks for checking. Is N=20 the number of elements in each direction? Maybe qr order=3 is simply to few points? Edit: From the paper: "We note that pyramidal elements are unique among the family of three-dimensional finite elements in that the functions spaces used span complete polynomials of a fixed degree and also include nonpolynomial functions; see, for example, [14]. Thus, even for relatively low-order pyramidal elements, sufficiently high-degree integration formulas should be used to minimize approximation error." |
Yes.
As stated in your edit, there is no exact quadrature rule for pyramids, because some basis functions are fractional polynomials. This was just an example. If you take the quadratic pyramids and increase the quadrature, then the error should not approximately double, even if you are not exactly integrating. The solution to this heat problem is actually super simple and we use a regular discretization, so there is no reason that any of your basis functions should heavily oscillate on such a fine mesh on any element.
I do not think that polyquad is per-se the issue, because it is known to work well. However, I do not fully understand your transformation in the quadrature rule. You seem to move some of the integration points outside the integration domain, which breaks the numerical integration.
|
Thanks @termi-official . There was in issue with the mapping of the quadrature points. Now it seems like the both the linear and quadratic interpolations converge. Do you have any more feedback on this PR? Do you think we should add some docs in this PR or #689 ? |
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.
Do you have any more feedback on this PR? Do you think we should add some docs in this PR or #689 ?
Since the linked PR will take care of the docs (and seems to have already for Pyramids) lets leave it separate.
src/interpolations.jl
Outdated
function shape_value(ip::Lagrange{RefPyramid,1}, ξ::Vec{3}, i::Int) | ||
(x,y,z) = ξ | ||
zzero = z ≈ 1.0 | ||
i == 1 && return zzero ? 0.0 : (-x*y+(z-1)*(-x-y-z+1))/(z-1) |
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 == 1 && return zzero ? 0.0 : (-x*y+(z-1)*(-x-y-z+1))/(z-1) | |
i == 1 && return zzero ? zero(x) : (-x*y+(z-1)*(-x-y-z+1))/(z-1) |
To make type-stable for non-Float64 input? (Same below for 2nd order)
Docs will be fixed in another PR, but in case we want ascii-documentation in the future, I paste possible representations here: alt 1
Alt 2:
|
Adds RefPyramid, Pyramid cells, Lagrange{RefPyramid, 1&2}