Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/reference/export.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ write_cell_data
write_node_data
Ferrite.write_cellset
Ferrite.write_nodeset
Ferrite.write_facetset
Ferrite.write_constraints
Ferrite.write_cell_colors
```
1 change: 1 addition & 0 deletions docs/src/topics/export.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ where `write_solution` is just one example of the following functions that can b
* [`write_projection`](@ref)
* [`Ferrite.write_cellset`](@ref)
* [`Ferrite.write_nodeset`](@ref)
* [`Ferrite.write_facetset`](@ref)
* [`Ferrite.write_constraints`](@ref)
* [`Ferrite.write_cell_colors`](@ref)

Expand Down
22 changes: 22 additions & 0 deletions src/Export/VTK.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This file handler can be used to to write data with
* [`write_node_data`](@ref).
* [`Ferrite.write_cellset`](@ref)
* [`Ferrite.write_nodeset`](@ref)
* [`Ferrite.write_facetset`](@ref)
* [`Ferrite.write_constraints`](@ref)

It is necessary to call `close(::VTKGridFile)` to save the data after writing
Expand Down Expand Up @@ -283,6 +284,27 @@ function write_nodeset(vtk, grid::AbstractGrid, nodeset::String)
return vtk
end

"""
write_facetset(vtk::VTKGridFile, grid::AbstractGrid, facetsetname::String [, facetset::AbstractVecOrSet{FacetIndex}])

Write nodal values of 1 for nodes of the faces in `facetset`, and 0 otherwise
"""
function write_facetset(vtk, grid::AbstractGrid, facetsetname, facetset::AbstractVecOrSet{FacetIndex})
Comment thread
termi-official marked this conversation as resolved.
Outdated
z = zeros(getnnodes(grid))
for (cellid, lfi) in facetset
cell = getcells(grid, cellid)
gip = geometric_interpolation(cell)
facetnodes = facetdof_indices(gip)[lfi]
for facetnode in facetnodes
i = get_node_ids(cell)[facetnode]
z[i] = 1.0
end
end
write_node_data(vtk, z, facetsetname)
return vtk
end
write_facetset(vtk, grid::AbstractGrid, facetset::String) = write_facetset(vtk, grid, facetset, getfacetset(grid, facetset))

"""
write_cellset(vtk, grid::AbstractGrid)
write_cellset(vtk, grid::AbstractGrid, cellset::String)
Expand Down
22 changes: 11 additions & 11 deletions test/checksums.sha1
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
279a353012f816aedcab4ffe08b566562f6b58b7
780cb53436186726b02c525be8120cf3c13fedab
ffc0824476ef6dfce54e5d53eb5dcb71708205cd
70975511109b94cd611364d9a46b324fd91dc095
5761355c16893882fef1e952d703d6c337a37a4f
c1c91d5352611771771c3d92fefc51937812e217
a5003cbddac9bb5279fce2dd4d6f26cd0912f3d8
7b008089f6431a574754499c069251e19b2577dd
23a709dc8931bb2de0bdba793bc290af1a11f16a
a56a590c396991212ad11479350e361da5bf3f0b
76fb94c366f517e87e6559d9ea2fadfdf43e16ff
6c43f459bbea5e3a9f79ec5da91ef9bc8e223027
49f2b223e5d879547929af68cc9f7cdeaf5d6e34
31cf9ecd68f7c0235bf0f6d8b181b0adf9e9ac69
dde376ca8547021a77ca260f79f5bb7e34b7c70b
30f412be44de0bdf7a10aed76eb68d9b5a829fc3
4ad48c5cd4c37231d13bf11547cb9a30f7bb744b
c7e61d0f1015d78f5250f9a5771bfba23be005cd
ddf46e899f5e794bdde219542e1fc5306fc3f300
acae7ae0e10c232c1dd9f7c352f27e0100683b13
7f02dc00f8f55db50ea752400c0f97779d9f0c93
1fc24de1e8c5e06dcd4e4f1cd6544c842845f35e
f592c19830d0560bb29c736764e8af02b442e49b
6c41cbbbcdbefda0afb6208295e6eab9cec6f812
6d86368c529bf5cf7ae28e23a8094501d914d05f
48125fdc01338ae420e04405699d23417babdae2
11549a1498556572a8cfa052b3b06b660fbfe05e
a44e2e480309dbf320a5bf044fd5e97bc73ab28d
9cd7ab5fffd0c3acaf744d8cf721357e97c04267
48528031570b719cd5683ef7fbceefe386dcb10b
c21313b96210736201ad37e0cdc7a5958791041c
ccc8b6567472b159321b4f096d1ce4555d39fac8
Comment thread
termi-official marked this conversation as resolved.
eae4ecbd38cc6ccf249bd931ec6773395180c128
3 changes: 2 additions & 1 deletion test/test_grid_dofhandler_vtk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ else
end

@testset "Grid, DofHandler, vtk" begin
for (celltype, dim) in (
@testset "$celltype" for (celltype, dim) in (
(Line, 1),
(QuadraticLine, 1),
(Quadrilateral, 2),
Expand Down Expand Up @@ -44,6 +44,7 @@ end
@test Ferrite.write_cellset(vtk, grid, "cell-1") === vtk
@test Ferrite.write_cellset(vtk, grid, "middle-cells") === vtk
@test Ferrite.write_nodeset(vtk, grid, "middle-nodes") === vtk
@test Ferrite.write_facetset(vtk, grid, "right") === vtk
end

# test the sha of the file
Expand Down
Loading