Skip to content

Commit

Permalink
implement mesh reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrKryslUCSD committed Feb 19, 2024
1 parent 5524e76 commit 0013563
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FinEtools"
uuid = "91bb5406-6c9a-523d-811d-0644c4229550"
authors = ["Petr Krysl <[email protected]>"]
version = "8.0.0"
version = "8.0.1"

[deps]
ChunkSplitters = "ae650224-84b6-46f8-82ea-d812ca08434e"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The package supports application packages, for instance:

## News

- 02/19/2024: Implement mesh reordering.
- 02/17/2024: Implement generic parallel matrix assembly using threaded tasks.
- 12/31/2023: Update for Julia 1.10.
- 06/19/2023: Introduce DataCache, generic linear and bilinear forms.
Expand Down
6 changes: 4 additions & 2 deletions src/FinEtools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ using .MeshModificationModule:
pointpartitioning,
interior2boundary,
distortblock,
outer_surface_of_solid
outer_surface_of_solid,
reordermesh
# Exported: extraction of boundary, fusing of nodes and merging of meshes, mesh smoothing, node partitioning
export meshboundary,
fusenodes,
Expand All @@ -312,7 +313,8 @@ export meshboundary,
pointpartitioning,
interior2boundary,
distortblock,
outer_surface_of_solid
outer_surface_of_solid,
reordermesh

using .MeshImportModule: import_NASTRAN, import_ABAQUS, import_MESH, import_H5MESH
# Exported: mesh import functions
Expand Down
15 changes: 14 additions & 1 deletion src/MeshModificationModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ numbering for the nodes.
`new_numbering` = new serial numbers for the nodes. The connectivity
should be changed as `conn[j]` --> `new_numbering[conn[j]]`
Let us say there are nodes not connected to any finite element that you would
Let us say there are nodes not connected to any finite element that we would
like to remove from the mesh: here is how that would be accomplished.
```
connected = findunconnnodes(fens, fes);
Expand Down Expand Up @@ -1238,4 +1238,17 @@ function outer_surface_of_solid(fens::FENodeSet, bdry_fes::ET) where {ET<:Abstra
return subset(bdry_fes, osfesl)
end

"""
reordermesh(fens, fes, ordering)
Reorder mesh (reshuffle nodes, renumber connectivities correspondingly).
The ordering may come from Reverse Cuthill-McKey (package SymRCM).
"""
function reordermesh(fens, fes, ordering)
iordering = collect(1:length(ordering))
iordering[ordering] = iordering
return FENodeSet(fens.xyz[ordering, :]), renumberconn!(fes, iordering)
end

end
84 changes: 84 additions & 0 deletions test/test_meshing_2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1846,3 +1846,87 @@ function test()
end
test()
end


module misc_reorder_1
using FinEtools
using SymRCM
using LinearAlgebra
using Test
function test()
xs = collect(linearspace(0.0, 5 * pi / 2, 6))
ys = collect(linearspace(0.0, 10.0, 7))
zs = collect(linearspace(0.0, 10.0, 7))

for f in (H8blockx, H20blockx, )
# for f in (H8blockx, T4blockx, H20blockx, T10blockx)
fens, fes = f(xs, ys, zs)
geom = NodalField(fens.xyz)
femm = FEMMBase(IntegDomain(bfes, GaussRule(3, 3)))
V0 = integratefunction(femm, geom, (x) -> 1.0)

C = connectionmatrix(FEMMBase(IntegDomain(fes)), count(fens))
ordering = symrcm(C)
fens, fes = reordermesh(fens, fes, ordering)
geom = NodalField(fens.xyz)
femm = FEMMBase(IntegDomain(bfes, GaussRule(3, 3)))
V = integratefunction(femm, geom, (x) -> 1.0)
@test abs(V - V0) / V0 < 1.0e-6

end
nothing
end
test()
end

module misc_reorder_1
using FinEtools
using SymRCM
# using FinEtools.MeshExportModule: VTKWrite
using LinearAlgebra
using Test
function test()
xs = collect(linearspace(0.0, 5 * pi / 2, 6))
ys = collect(linearspace(0.0, 10.0, 7))
zs = collect(linearspace(0.0, 10.0, 7))

for f in (H8blockx, H20blockx )
# for f in (H8blockx, T4blockx, H20blockx, T10blockx)
fens, fes = f(xs, ys, zs)
geom = NodalField(fens.xyz)
femm = FEMMBase(IntegDomain(fes, GaussRule(3, 3)))
V0 = integratefunction(femm, geom, (x) -> 1.0)

C = connectionmatrix(FEMMBase(IntegDomain(fes, GaussRule(3, 3))), count(fens))
ordering = symrcm(C)
fens, fes = reordermesh(fens, fes, ordering)
# File = "misc_reorder_1.vtk"
# VTKWrite.vtkwrite(File, fens, fes)
geom = NodalField(fens.xyz)
femm = FEMMBase(IntegDomain(fes, GaussRule(3, 3)))
V = integratefunction(femm, geom, (x) -> 1.0)
@test abs(V - V0) / V0 < 1.0e-6
end


# for f in (H8blockx, H20blockx )
for f in (T4blockx, T10blockx)
fens, fes = f(xs, ys, zs)
geom = NodalField(fens.xyz)
femm = FEMMBase(IntegDomain(fes, TetRule(4)))
V0 = integratefunction(femm, geom, (x) -> 1.0)

C = connectionmatrix(FEMMBase(IntegDomain(fes, TetRule(4))), count(fens))
ordering = symrcm(C)
fens, fes = reordermesh(fens, fes, ordering)
# File = "misc_reorder_1.vtk"
# VTKWrite.vtkwrite(File, fens, fes)
geom = NodalField(fens.xyz)
femm = FEMMBase(IntegDomain(fes, TetRule(4)))
V = integratefunction(femm, geom, (x) -> 1.0)
@test abs(V - V0) / V0 < 1.0e-6
end
nothing
end
test()
end

2 comments on commit 0013563

@PetrKryslUCSD
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/101203

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v8.0.1 -m "<description of version>" 0013563e7d35614070be77f78bcda08e33cf1c9a
git push origin v8.0.1

Please sign in to comment.