VTK

Bcube._point_index_from_IJKMethod

Return the node numbering of the node designated by its position in the x and y direction.

See https://www.kitware.com/modeling-arbitrary-order-lagrange-finite-elements-in-the-visualization-toolkit/.

Bcube.vtk_entityMethod
vtk_entity(t::AbstractEntityType)

Convert an AbstractEntityType into a VTKCellType. To find the correspondance, browse the WriteVTK package AND check the Doxygen (for numbering) : https://vtk.org/doc/nightly/html/classvtkTriQuadraticHexahedron.html

Bcube.write_vtkMethod
write_vtk(basename::String, it::Int,time::Real, mesh::AbstractMesh{topoDim,spaceDim}, vars::Dict{String,Tuple{V,L}}; append=false) where{topoDim,spaceDim,V,L<:WriteVTK.AbstractFieldData}

Write a set of variables on the mesh nodes or cell centers to a VTK file.

Example

mesh = basic_mesh()
u = rand(ncells(mesh))
v = rand(nnodes(mesh))
dict_vars = Dict( "u" => (u, VTKCellData()),  "v" => (v, VTKPointData()) )
write_vtk("output", 0, 0.0, mesh, dict_vars)
Bcube.write_vtkMethod
write_vtk(basename::String, mesh::AbstractMesh{topoDim,spaceDim}) where{topoDim,spaceDim}

Write the mesh to a VTK file.

Example

write_vtk("output", basic_mesh())
Bcube.write_vtk_discontinuousMethod

VTK writer for a set of discontinuous functions. vars is a dictionnary of variable name => (values, values_location)

where values is an array of numbers.

Bcube.write_vtk_lagrangeMethod
write_vtk_lagrange(
    basename::String,
    vars::Dict{String, F},
    mesh::AbstractMesh,
    U_export::AbstractFESpace,
    it::Integer = -1,
    time::Real = 0.0;
    collection_append = false,
    vtk_kwargs...,
) where {F <: AbstractLazy}

Write the provided FEFunction/MeshCellData/CellFunction on the mesh with the precision of the Lagrange FESpace provided.

vars is a dictionnary of variable name => Union{FEFunction,MeshCellData,CellFunction} to write.

Example

mesh = rectangle_mesh(6, 7; xmin = -1, xmax = 1.0, ymin = -1, ymax = 1.0)
f_u = PhysicalFunction(x -> x[1]^2 + x[2]^2)
u = FEFunction(TrialFESpace(FunctionSpace(:Lagrange, 4), mesh))
projection_l2!(u, f_u, mesh)

vars = Dict("f_u" => f_u, "u" => u, "grad_u" => ∇(u))

for degree_export in 1:5
    U_export = TrialFESpace(FunctionSpace(:Lagrange, degree_export), mesh)
    Bcube.write_vtk_lagrange(
        joinpath(@__DIR__, "output"),
        vars,
        mesh,
        U_export,
    )
end

Dev notes

  • in order to write an ASCII file, you must pass both ascii = true and append = false
  • collection_append is not named append to enable passing correct kwargs to vtk_grid
  • remove (once fully validated) : write_vtk_discontinuous