-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add feature to save
NodeSet
s to VTK file (#38)
* add feature to save NodeSets to VTK file * format * bump compat of WriteVTK to 1.7
- Loading branch information
1 parent
61ce1d7
commit e1d415e
Showing
6 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
vtk_save(filename, nodeset::NodeSet, functions...; | ||
keys = "value_" .* string.(eachindex(functions))) | ||
Save a `NodeSet` to a VTK file. You can optionally pass a list of functions to save | ||
the values of the functions at the nodes. The functions can also be passed as `Interpolation`. | ||
The optional keyword argument `keys` is used to specify the names of the data arrays in the VTK file. | ||
""" | ||
function vtk_save(filename, nodeset::NodeSet, functions...; | ||
keys = "value_" .* string.(eachindex(functions))) | ||
@assert dim(nodeset)<=3 "Only 1D, 2D, and 3D data can be saved to VTK files." | ||
cells = [MeshCell(VTKCellTypes.VTK_VERTEX, (i,)) for i in eachindex(nodeset)] | ||
points = values_along_dim.(Ref(nodeset), eachdim(nodeset)) | ||
vtk_grid(filename, points..., cells, append = false) do vtk | ||
for (i, func) in enumerate(functions) | ||
vtk["$(keys[i])"] = func.(nodeset) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters