Skip to content

Commit

Permalink
Merge pull request #156 from gridap/vtk-kwargs
Browse files Browse the repository at this point in the history
Added VTK kwargs
  • Loading branch information
JordiManyer authored Aug 14, 2024
2 parents 80b3d1d + 23bfc2f commit e58f280
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

- Added kwargs for VTK encoding options. Since PR[#156](https://github.com/gridap/GridapDistributed.jl/pull/156).

### Fixed

- Fixed distributed interpolators for Vector-Valued FESpaces. Since PR[#152](https://github.com/gridap/GridapDistributed.jl/pull/152).
Expand Down
41 changes: 31 additions & 10 deletions src/Visualization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ end
function Visualization.visualization_data(
model::DistributedDiscreteModel{Dc},
filebase::AbstractString;
labels=get_face_labeling(model)) where Dc
labels=get_face_labeling(model)
) where Dc

cell_gids = get_cell_gids(model)
vd = map(local_views(model),partition(cell_gids),labels.labels) do model,gids,labels
Expand All @@ -57,7 +58,8 @@ function Visualization.visualization_data(
order=-1,
nsubcells=-1,
celldata=nothing,
cellfields=nothing)
cellfields=nothing
)

trians = trian.trians
cell_gids = get_cell_gids(trian.model)
Expand Down Expand Up @@ -145,42 +147,61 @@ end

function Visualization.write_vtk_file(
parts::AbstractArray,
grid::AbstractArray{<:Grid}, filebase; celldata, nodaldata)
pvtk = Visualization.create_vtk_file(parts,grid,filebase;celldata=celldata,nodaldata=nodaldata)
grid::AbstractArray{<:Grid}, filebase; celldata, nodaldata,
compress=false,append=true,ascii=false,vtkversion=:default
)
pvtk = Visualization.create_vtk_file(
parts,grid,filebase;celldata=celldata,nodaldata=nodaldata,
compress=compress,append=append,ascii=ascii,vtkversion=vtkversion
)
map(vtk_save,pvtk)
end

function Visualization.create_vtk_file(
parts::AbstractArray,
grid::AbstractArray{<:Grid},
filebase;
celldata, nodaldata)
celldata, nodaldata,
compress=false,append=true,ascii=false,vtkversion=:default
)
nparts = length(parts)
map(parts,grid,celldata,nodaldata) do part,g,c,n
Visualization.create_pvtk_file(
g,filebase;
part=part,nparts=nparts,
celldata=c,nodaldata=n)
celldata=c,nodaldata=n,
compress=compress,append=append,ascii=ascii,vtkversion=vtkversion
)
end
end

const DistributedModelOrTriangulation = Union{DistributedDiscreteModel,DistributedTriangulation}

function Visualization.writevtk(arg::DistributedModelOrTriangulation,args...;kwargs...)
function Visualization.writevtk(
arg::DistributedModelOrTriangulation,args...;
compress=false,append=true,ascii=false,vtkversion=:default,kwargs...
)
parts=get_parts(arg)
map(visualization_data(arg,args...;kwargs...)) do visdata
write_vtk_file(
parts,visdata.grid,visdata.filebase,celldata=visdata.celldata,nodaldata=visdata.nodaldata)
parts,visdata.grid,visdata.filebase,celldata=visdata.celldata,nodaldata=visdata.nodaldata,
compress=compress, append=append, ascii=ascii, vtkversion=vtkversion
)
end
end

function Visualization.createvtk(arg::DistributedModelOrTriangulation,args...;kwargs...)
function Visualization.createvtk(
arg::DistributedModelOrTriangulation,args...;
compress=false,append=true,ascii=false,vtkversion=:default,kwargs...
)
v = visualization_data(arg,args...;kwargs...)
parts=get_parts(arg)
@notimplementedif length(v) != 1
visdata = first(v)
Visualization.create_vtk_file(
parts,visdata.grid,visdata.filebase,celldata=visdata.celldata,nodaldata=visdata.nodaldata)
parts,visdata.grid,visdata.filebase,celldata=visdata.celldata,nodaldata=visdata.nodaldata,
compress=compress, append=append, ascii=ascii, vtkversion=vtkversion
)
end

struct DistributedPvd{T<:AbstractArray}
Expand Down

0 comments on commit e58f280

Please sign in to comment.