Ferrite-FEM / Ferrite.jl

Finite element toolbox for Julia
https://ferrite-fem.github.io
Other
338 stars 86 forks source link

Grid inconsistencies #394

Open koehlerson opened 2 years ago

koehlerson commented 2 years ago

There are a few inconsistencies related to the Grid type

termi-official commented 2 years ago

Let us use this issue to gather general problems with the grid and its interface.

I will pick documenting part of this this. My vote would go for defining different entity types. For example we have partial entities local to a cell (currently named FaceIndex, EdgeIndex and VertexIndex) where I am not sure if vertex cosistently refers to an actual vertex and not also too notes. Further we have the global entities which are defined by sorted tuples of vertices.

nnodes_per_cell has one dispatch which does not work correctly in the case of mixed grid. Probably we should make this two dispatches and add some counter to the grid (e.g. a dict which maps from cell types to an integer counting the number of entities occuring in a grid). I think there are multiple ways to resolve this.

Another issue is that for large grids the recommended way for boundary integrals is O(N), which can become surprisingly slow.

termi-official commented 2 years ago

We also should check for more definition inconsistencies in what edges and faces are.

lijas commented 2 years ago

I dont think CellIndex is used anywhere in ferrite, and one reason to not use it is because then you cant do stuff like cellid + 10 (though, I dont know how common this is either)

KnutAM commented 1 year ago

I tried to get a bit of an overview of the grid interface and figured I could share my notes/thoughts here. I found a few (probably known) inconsistencies and made some suggestions on how they could be fixed. Also related to the get*(...) vs *(...) issue...

Grid interface

Coordinates

Nodes

Cells

Ideas for changes

Deprecation and replacement

Suggestion for new methods

Personal thoughts on naming

I have often wanted to write ndofs=ndofs(dh) ...

Faces, edges, vertices

Tackled in #581, notes here for reference Edit based on @termi-official's clarification below ([ref](https://github.com/Ferrite-FEM/Ferrite.jl/issues/394#issuecomment-1382419257)) and discussion in [581](https://github.com/Ferrite-FEM/Ferrite.jl/pull/581#discussion_r1070295453) * `vertices` * `Interpolation`: Return the local (algebraic) node indices for the vertices in the reference shape * `Cell`: Return the global node numbers for the vertices in the `Cell` * `edges` (only 3d) * `Interpolation`: Return the local (algebraic) node indices on each edge. Order is (vertex 1, vertex 2, in-betweens...) * `Cell`: Return the global node numbers for the vertex nodes that describe each edge in the `Cell` * `faces` * `Interpolation`: Return the local (algebraic) node indices on each face. Order is (vertex_nodes..., edge_nodes..., face_nodes...) * `Cell`: Return the global node numbers for the vertex nodes that describe each face in the `Cell` (The local (algebraic) node index refers to the coordinate number in the `ip::Interpolation`'s `reference_coordinates(ip)`. However, this is rarely used (currently only in `BCValues` and `apply_analytical!`) Following [581](https://github.com/Ferrite-FEM/Ferrite.jl/pull/581#discussion_r1070295453), this behavior might change in the future and actually refer to the local dof-number.
termi-official commented 1 year ago

Note that I suggest a renaming of vertices, faces and edges in #581 to disambiguate.

Edit: Also note that vertices, faces and edges have different semantics for cells and interpolations.

KnutAM commented 1 year ago

Note that I suggest a renaming of vertices, faces and edges in #581 to disambiguate.

Nice change!

Edit: Also note that vertices, faces and edges have different semantics for cells and interpolations.

Im not sure if I follow, do you mean something else than that they return global vs local indices?

termi-official commented 1 year ago

For cells the corresponding vertex node indices are returned while for interpolations all local dof indices on the closure of the entity are returned. E.g. for a quadratic triangle with quadratic Lagrange interpolation faces(cell) would return something like ((1,3),(3,2),(2,1)) while faces(ip) returns something like ((1,3,4),(3,2,5),(2,1,6)).

KnutAM commented 1 year ago

Aha, I missed that completely now. Even more important to have different names as you suggest!

termi-official commented 9 months ago

Related comment for reference https://github.com/Ferrite-FEM/Ferrite.jl/pull/743#discussion_r1254353892 : Is the vertex in 1D a face?