Skip to content

Modified handling pvd files when the triangulation is not present on all processes. #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Added support to create pvd files when the triangulation is not there on all processes. To achive this, a new method for the createpvd function is added.

## [0.4.7] 2025-03-04

### Added
Expand Down
46 changes: 38 additions & 8 deletions src/Visualization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,35 @@

struct DistributedPvd{T<:AbstractArray}
pvds::T
parts::AbstractArray
end

function Visualization.createpvd(trian::DistributedTriangulation,parts::AbstractArray,args...;kwargs...)
nparts, new_parts = filter_empty_parts(parts,local_views(trian))
pvds = map(new_parts) do part
if part == 1
paraview_collection(args...;kwargs...)

Check warning on line 232 in src/Visualization.jl

View check run for this annotation

Codecov / codecov/patch

src/Visualization.jl#L228-L232

Added lines #L228 - L232 were not covered by tests
end
end
DistributedPvd(pvds,new_parts)

Check warning on line 235 in src/Visualization.jl

View check run for this annotation

Codecov / codecov/patch

src/Visualization.jl#L235

Added line #L235 was not covered by tests
end

function Visualization.createpvd(f,trian::DistributedTriangulation,parts::AbstractArray,args...;kwargs...)
pvd = createpvd(trian,parts,args...;kwargs...)
try
f(pvd)

Check warning on line 241 in src/Visualization.jl

View check run for this annotation

Codecov / codecov/patch

src/Visualization.jl#L238-L241

Added lines #L238 - L241 were not covered by tests
finally
savepvd(pvd)

Check warning on line 243 in src/Visualization.jl

View check run for this annotation

Codecov / codecov/patch

src/Visualization.jl#L243

Added line #L243 was not covered by tests
end
end

function Visualization.createpvd(parts::AbstractArray,args...;kwargs...)
pvds = map_main(parts) do part
paraview_collection(args...;kwargs...)
pvds = map(parts) do part
if part == 1
paraview_collection(args...;kwargs...)

Check warning on line 250 in src/Visualization.jl

View check run for this annotation

Codecov / codecov/patch

src/Visualization.jl#L248-L250

Added lines #L248 - L250 were not covered by tests
end
end
DistributedPvd(pvds)
DistributedPvd(pvds,parts)

Check warning on line 253 in src/Visualization.jl

View check run for this annotation

Codecov / codecov/patch

src/Visualization.jl#L253

Added line #L253 was not covered by tests
end

function Visualization.createpvd(f,parts::AbstractArray,args...;kwargs...)
Expand All @@ -241,14 +263,22 @@
end

function Visualization.savepvd(pvd::DistributedPvd)
map_main(pvd.pvds) do pvd
vtk_save(pvd)
map(pvd.pvds, pvd.parts) do pvd, part
if part == 1
vtk_save(pvd)

Check warning on line 268 in src/Visualization.jl

View check run for this annotation

Codecov / codecov/patch

src/Visualization.jl#L266-L268

Added lines #L266 - L268 were not covered by tests
end
end
end

function Base.setindex!(pvd::DistributedPvd,pvtk::AbstractArray,time::Real)
map(vtk_save,pvtk)
map_main(pvtk,pvd.pvds) do pvtk,pvd
pvd[time] = pvtk
map(pvtk) do pvtk
if !isnothing(pvtk)
vtk_save(pvtk)

Check warning on line 276 in src/Visualization.jl

View check run for this annotation

Codecov / codecov/patch

src/Visualization.jl#L274-L276

Added lines #L274 - L276 were not covered by tests
end
end
map(pvtk,pvd.pvds,pvd.parts) do pvtk,pvd,part
if part == 1
pvd[time] = pvtk

Check warning on line 281 in src/Visualization.jl

View check run for this annotation

Codecov / codecov/patch

src/Visualization.jl#L279-L281

Added lines #L279 - L281 were not covered by tests
end
end
end
Loading