Skip to content

Commit

Permalink
Topology vroom 1 (Ferrite-FEM#753)
Browse files Browse the repository at this point in the history
* Separate topology from grid.

* Split up topology.

* Remove todo.

* Enhanced type stability.

* Stop topology from overflowing my terminal buffer.

* Optimize algorithm for topology construction by eliminating allocations.

* Update variable names.

* Update variable names 2.

* Derp.

* Fix oopsie.

* Matrices :)

* Replace last dict in topology with vector, too.

* Fix bug.

* Update exports.

* Add note about broken mixed-dimensional queries.

* Update field docs.

* Update doc reference

* Lazy face skeleton.

* Update src/Grid/topology.jl

Co-authored-by: Maximilian Köhler <[email protected]>

* More tweaks.

* Rename as requested.

* Oopsie

* Rename in tests.

* Missing dispathc.

* asdf

* Remove algebraic stuff on EntityNeighborhood.

---------

Co-authored-by: Maximilian Köhler <[email protected]>
  • Loading branch information
2 people authored and AbdAlazezAhmed committed Jul 11, 2023
1 parent 0c5f1e4 commit ca2a4a5
Show file tree
Hide file tree
Showing 9 changed files with 841 additions and 750 deletions.
2 changes: 2 additions & 0 deletions docs/src/reference/grid.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ get_cell_coordinates!
Ferrite.ExclusiveTopology
Ferrite.getneighborhood
Ferrite.faceskeleton
Ferrite.vertex_star_stencils
Ferrite.getstencil
```

### Grid Sets Utility
Expand Down
49 changes: 49 additions & 0 deletions src/Dofs/DofHandler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,17 @@ function sortedge(edge::Tuple{Int,Int})
a < b ? (return (edge, PathOrientationInfo(true))) : (return ((b, a), PathOrientationInfo(false)))
end

"""
sortedge_fast(edge::Tuple{Int,Int})
Returns the unique representation of an edge.
Here the unique representation is the sorted node index tuple.
"""
function sortedge_fast(edge::Tuple{Int,Int})
a, b = edge
a < b ? (return edge) : (return (b, a))
end

"""
sortface(face::Tuple{Int})
sortface(face::Tuple{Int,Int})
Expand All @@ -633,6 +644,20 @@ so the unique representation is always a tuple length 3.
"""
sortface(face::Tuple{Int,Int}) = sortedge(face) # Face in 2D is the same as edge in 3D.


"""
sortface_fast(face::Tuple{Int})
sortface_fast(face::Tuple{Int,Int})
sortface_fast(face::Tuple{Int,Int,Int})
sortface_fast(face::Tuple{Int,Int,Int,Int})
Returns the unique representation of a face.
Here the unique representation is the sorted node index tuple.
Note that in 3D we only need indices to uniquely identify a face,
so the unique representation is always a tuple length 3.
"""
sortface_fast(face::Tuple{Int,Int}) = sortedge_fast(face) # Face in 2D is the same as edge in 3D.

"""
!!!NOTE TODO implement me.
Expand Down Expand Up @@ -669,6 +694,16 @@ function sortface(face::Tuple{Int,Int,Int})
return (a, b, c), SurfaceOrientationInfo() # TODO fill struct
end


function sortface_fast(face::Tuple{Int,Int,Int})
a, b, c = face
b, c = minmax(b, c)
a, c = minmax(a, c)
a, b = minmax(a, b)
return (a, b, c)
end


function sortface(face::Tuple{Int,Int,Int,Int})
a, b, c, d = face
c, d = minmax(c, d)
Expand All @@ -680,7 +715,21 @@ function sortface(face::Tuple{Int,Int,Int,Int})
return (a, b, c), SurfaceOrientationInfo() # TODO fill struct
end


function sortface_fast(face::Tuple{Int,Int,Int,Int})
a, b, c, d = face
c, d = minmax(c, d)
b, d = minmax(b, d)
a, d = minmax(a, d)
b, c = minmax(b, c)
a, c = minmax(a, c)
a, b = minmax(a, b)
return (a, b, c)
end


sortface(face::Tuple{Int}) = face, nothing
sortface_fast(face::Tuple{Int}) = face

"""
find_field(dh::DofHandler, field_name::Symbol)::NTuple{2,Int}
Expand Down
2 changes: 2 additions & 0 deletions src/Ferrite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ include("FEValues/face_integrals.jl")

# Grid
include("Grid/grid.jl")
include("Grid/topology.jl")
include("Grid/utils.jl")
include("Grid/grid_generators.jl")
include("Grid/coloring.jl")

Expand Down
Loading

0 comments on commit ca2a4a5

Please sign in to comment.