-
Notifications
You must be signed in to change notification settings - Fork 38
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
Idea: MixedTensor #188
base: master
Are you sure you want to change the base?
Idea: MixedTensor #188
Conversation
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 #188 +/- ##
==========================================
- Coverage 96.78% 92.89% -3.89%
==========================================
Files 17 18 +1
Lines 1338 1394 +56
==========================================
Hits 1295 1295
- Misses 43 99 +56
☔ View full report in Codecov by Sentry. |
This one would be really great to have! As a first note, we do not need this for H(div) and H(curl) spaces. To elaborate where I utilize such embedding: I have sometimes problems with surface flows, surface reaction-diffusion systems or reaction-diffusion systems in "bioeletrical wires", which are all embedded in 3D. However, different from solid mechanics problems, it is possible to treat this problem as if it was an actual 1D/2D element (because stuff happening in the radial/normal direction can be neglected). Another question here: This should already (or almost already) work for mixed derivatives, right? Turns out for multiphysics problems (or also sometimes mechanics problems with internal variables) we need partial derivatives of the form Edit 1: To also give some explanation on the CellRTValues - if I understand the implementation correctly, then this should be a so-called boundary element method, where you solve the problem only on a discretization of the boundary of your domain. Hence your elements naturally have codimension 1. I need more context from the original author on the exact formulation, because I have no experience for embedded H(curl) and H(div) problems. |
Nice to hear! Thanks for the comments! The I have not included (in this PR) support for different orders than the current 1, 2, and 4. At this stage, this is just an idea, so I wouldn't count on it being merged any time soon. One potential issue is increasing compilation time due to the high amount of different possible combinations. |
Is the precompilation increase really this significant? If this is a problem for users, wouldn't be the actual solution to build a sysimage? |
Ah, right - I was worried about "Combinatorial Type Explosion", but as long as not explicitly precompiled, I suppose this should only lead to performance degradation for type-unstable code that code using Tensors should normally avoid? (Of course also a slight degradation for compilation, but that is likely negligible as you say) @KristofferC or @fredrikekre: would you like such a feature in Tensors? |
# where the dimensions of the coordinate and shape function is not | ||
# the same (and shape function is not scalar) | ||
struct MixedTensor{order, dims, T, M} <: AbstractTensor{order, dims, T} | ||
data::NTuple{M, T} |
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.
Maybe it make sense to have data::SMatrix
which I think already has the correct parametrization?
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.
Yes,
struct MyTensor{order, dims, T, M}
data::SArray{dims, T, order, M}
end
would simplify (at least) single dot-products a lot!
Random comment:
Not sure if therye would be any major benifit with this though |
Also, MixedTensors could be benifical when working with shells (and beams), where we have two surface coordinates (xi and eta) in 3d space, and it quite common to want to take the gradient dx/d\Xi which would be a 3x2 tensor. Currently what I do is just to store them as two vectors: dx/dxi and dx/deta instead (which also works fine). |
Great that it can be useful for more cases! After talking to @fredrikekre earlier, a possible way forward is to define only a the functionality required for specific cases and consider the mixed tensor an in-development feature. In Ferrite, that means we can have shape gradients etc. output mixed tensors instead of StaticArrays as is currently returned.
Does that mean that the regular tensor would change to, e.g. |
I agree, it makes sense to view mixed tensors (and 3rd order tensors) as in-development, and to not implement all operations/features for them all at once. For example, with shells I have wanted to have 3rd order tensors basically just for storage (of higher order gradients), and not for doing multiplication/addition/other operations with. |
In some cases, a tensor could have mixed bases, e.g. a 2x3 tensor. This PR is a first tryout that is currently not super performant, but I think that can be "easily" fixed by using the same code-generation strategies as currently done for the existing
Tensor
-type.The motivation came from looking at the
CellVectorValues
in Ferrite thinking that for the special interpolations that were recently discussed, it might be good to have e.g. 3d shape functions for 2d coordinates or vice-versa. @termi-official / Ferrite-FEM/Ferrite.jl#569 / CellRTValues?Some examples and ideas
where the point of the last is to show that it should always eagerly transform back to regular tensors whenever possible (i.e. when
allequal(dims)
- all bases are the same)Parameterization
Currently, the type is parameterized by
MixedTensor{order, dims, T, M}
wheredims
is checked during construction to be anNTuple{order,Int}
. Not sure what is the best option here,SArray
useTuple{dims...}
(E.g.Tuple{2,3}
. Perhaps a more general method would be to define a basis type, e.g.But this makes construction less convenient, e.g.
compared to the current