-
Notifications
You must be signed in to change notification settings - Fork 85
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
Interpolation parameterization #676
Comments
I like this direction! One question/thought: Wouldn't |
Yea, I suppose it could be, but I think it could also be handled in the CellValues constructor perhaps. The suggested VectorInterpolations would have the same problem. I think it could be nice to keep the interpolations independent of this though, it is only when you couple it with a spacedim from a grid that you have that problem, I think.
Thats one option, but doesn't generalize as nicely IMO. |
For example, I don't think you could include the MixedTensor stuff in the current CellValue struct layout anyway, so that would have to be separate. |
We could also consider removing the |
And also related to this issue, perhaps it would be nice to introduce interpolation_u = Lagrange{RefTriangle,2}()
interpolation_p = Lagrange{RefTriangle,1}() looks better than interpolation_u = Lagrange{2,RefTetrahedron,2}()
interpolation_p = Lagrange{2,RefTetrahedron,1}() IMO. This might make it more difficult to write a dimension independent code, but... is that of much use in practice? We already have different cells (i.e. |
Agreed (that's why I crossed it out:))
True, it would make it type-unstable, I think, but that shouldn't matter since it is during setup.
With the intended implementation, having MixedTensors in that would infer zero additional costs even for cases with regular Tensors. Would just need the added double dimensions. But since it isn't certain that will be implemented, perhaps it isn't relevant anyways it this stage.
For my applications, that would not be an issue. It would also be nice for the quadrature. Furthermore, it clarifies that it is the dim of the shape and not the embedded dimension we are talking about (I think I confused that before). |
Thanks for summarizing the discussion Fredrik! I already started implementing our ideas, but hit a hard wall when trying to fix up the dof distribution for high order elements. This is already an issue in the current api, when we have more than 1 distinct dof locations on the interior of an edge/face with more than one entry. I.e. Ferrite.jl/src/interpolations.jl Line 242 in a917a24
Ferrite.jl/src/interpolations.jl Line 223 in a917a24
Before this is lost, we likely can make the change non-breaking (for the user-facing api) by adding the vectorized versions to the dof handler with the corresponding |
I was imagining something like
I see, would you cast it to the standard tensor types in
There is already
Why do you need to do that? I assumed for Nedelec we could just use Ferrite.jl/src/interpolations.jl Lines 1125 to 1140 in d5f18d9
|
Note that users also sometimes vectorize variables which might note be inherently vectors (see e.g. the angle in the shell example) leading to
Linear elements are no problems. For high order stuff I am not sure how it should be handled and also integral elements (like Nedelec or Raviart-Thomas) do not have reference coordinates, because full geometric entities are the reference thing (because they are defined as integral moments over subentities). |
Yes, (and if not it would convert on the first tensor operation that it is used in.) But yes, it should be prototyped separately and I think there is quite some work to get the same performance as regular tensors for the mixed cases. |
Yea but Ferrite.jl/src/FEValues/face_values.jl Line 245 in aa26130
test/ for testing purposes only). For applying boundary conditions I think another approach would be needed anyway.
|
Regarding #676 (comment), an alternative would be to add the reference dimension as a parameter instead: struct RefCube{rdim} end This, or the proposal to add |
For e.g. CellValues we need julia> struct RefTriangle <: Ferrite.AbstractRefShape end
julia> function Lagrange{RefTriangle,order}() where order
return Lagrange{2,RefTetrahedron,order}()
end
julia> Lagrange{RefTriangle,1}()
Lagrange{2, RefTetrahedron, 1}() to simplify interpolation construction a bit, perhaps. |
Could that be solved by defining e.g. |
|
Although I really like such syntactic sugar to construct elements, what should With such syntax we could also think about tensor-product elements like for example |
Just pointing out that we can make this work: fields = (:u, :p) ∈ Lagrange{2,RefTriangle,2}()^2 × Lagrange{2,RefTriangle,1}()
qr = QuadratureRule(...)
cellvalues = CellValues(qr, fields)
dh = DofHandler(grid)
add!(dh, fields)
close!(dh) |
I imagine this would return a "multivalues" (#674) |
What about something like fields = (:u,) ∈ Lagrange{2,RefTriangle,2}()^2 ⊕ Lagrange{2,RefCube,2}()^2 for mixed grids? Or maybe even fields = (:u,) ∈ Lagrange{rdim=2,order=2}()^2 where Edit: Analogue treatment for the quadrature rules. Edit 2: |
With #679 we can eliminate |
One of the main motivations for the subregion stuff is that it also allows you to specify different fields on different domains, so the extra explicitness for the case when you have the same field everywhere, but different shapes, doesn't bother me that much. One alternative could be to have |
Sure. It also does not bother me to be explicit here, but I thought that it might be a nice convenience feature. |
Resolved by #694, mostly. |
Currently Ferrite only implements scalar interpolations, i.e. interpolations where the shape functions are scalars. When using these for vector-valued function approximations we automatically "vectorize" these in two places:
CellVectorValues
:Ferrite.jl/src/FEValues/cell_values.jl
Line 103 in 247d7c3
dim
argument:Ferrite.jl/src/Dofs/DofHandler.jl
Line 217 in 247d7c3
This becomes a bit awkward for vector-valued interpolations such as e.g. Nédélec or Raviart–Thomas (xref #569). Since these shouldn't be vectorized it isn't clear if one should use
CellScalarValues
orCellVectorValues
, and it isn't clear what to pass as thedim
parameter to the DofHandler.For these reasons I suggest adding abstract types
ScalarInterpolation
andVectorInterpolation
(where all current Ferrite interpolations would be<: ScalarInterpolation
):To use a scalar interpolation like Lagrange we then also add a "vectorization layer" so that this can be encoded already in the interpolation, for example something like:
(For some prior art, DefElement actually considers scalar Lagrange and vector Lagrange to be independent interpolations, and in deal.ii one also have to explicitly vectorize when creating an FESystem: https://www.dealii.org/current/doxygen/deal.II/classFESystem.html.)
Potentially we can implement
ncomponents::Int * ip::ScalarInterpolation)
, orip::ScalarInterpolation ^ ncomponents::Int)
as alternativeVectorizedInterpolation
constructors, similar to what deal.ii does in the FESystem constructor.With the type hierarchy above we can implement dispatches for
CellValues
directly:and we can (probably) remove the FieldTrait:
Ferrite.jl/src/FEValues/common_values.jl
Lines 5 to 7 in aa26130
CellValues{<:ScalarInterpolation}
andCellValues{<:VectorInterpolation}
.For the Taylor-Hood element this would then look like:
The text was updated successfully, but these errors were encountered: