Skip to content

Commit f9fca06

Browse files
authored
Merge branch 'release-0.2' into rhs_assembly
2 parents 0a5776b + bfa427b commit f9fca06

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

Manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ version = "0.10.21"
148148

149149
[[Gridap]]
150150
deps = ["AbstractTrees", "BSON", "BlockArrays", "Combinatorics", "DocStringExtensions", "FastGaussQuadrature", "FileIO", "FillArrays", "ForwardDiff", "JLD2", "JSON", "LineSearches", "LinearAlgebra", "NLsolve", "NearestNeighbors", "QuadGK", "Random", "SparseArrays", "SparseMatricesCSR", "StaticArrays", "Test", "WriteVTK"]
151-
git-tree-sha1 = "1c5c6b7cbdc5895f690d731e3653d01636eaa243"
151+
git-tree-sha1 = "d3bfeb769259b08f7385bdad91681f38c50fc519"
152152
repo-rev = "gridap_distributed"
153153
repo-url = "https://github.com/gridap/Gridap.jl"
154154
uuid = "56d4f2e9-7ea1-5844-9cf6-b9c51ca7ce8e"

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1010
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
1111
PartitionedArrays = "5a9dfac6-5c52-46f7-8278-5e2210713be9"
1212
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
13+
WriteVTK = "64499a7a-5c06-52f2-abe2-ccb03c286192"
1314

1415
[compat]
1516
FillArrays = "0.8.4, 0.9, 0.10, 0.11, 0.12"

src/GridapDistributed.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ using PartitionedArrays
1515
const PArrays = PartitionedArrays
1616

1717
using SparseArrays
18+
using WriteVTK
1819

1920
import Gridap.TensorValues: inner, outer, double_contraction, symmetric_part
2021
import LinearAlgebra: det, tr, cross, dot,

src/Visualization.jl

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function Base.getproperty(x::DistributedVisualizationData, sym::Symbol)
66
if sym == :grid
77
map_parts(i->i.grid,x.visdata)
88
elseif sym == :filebase
9-
map_parts(i->i.filebase,x.visdata)
9+
get_part(x.visdata).filebase
1010
elseif sym == :celldata
1111
map_parts(i->i.celldata,x.visdata)
1212
elseif sym == :nodaldata
@@ -32,8 +32,7 @@ function Visualization.visualization_data(
3232
vd = map_parts(
3333
parts,model.models,model.gids.partition,labels.labels) do part,model,gids,labels
3434

35-
n = lpad(part,ceil(Int,log10(nparts)),'0')
36-
vd = visualization_data(model,"$(filebase)_$(n)";labels=labels)
35+
vd = visualization_data(model,filebase;labels=labels)
3736
vd_cells = vd[end]
3837
push!(vd_cells.celldata, "gid" => gids.lid_to_gid)
3938
push!(vd_cells.celldata, "part" => gids.lid_to_part)
@@ -63,11 +62,16 @@ function Visualization.visualization_data(
6362

6463
vd = map_parts(
6564
parts,trians,cdat,fdat) do part,trian,celldata,cellfields
66-
n = lpad(part,ceil(Int,log10(nparts)),'0')
65+
_celldata = Dict{Any,Any}(celldata)
66+
# we do not use "part" since it is likely to be used by the user
67+
if haskey(_celldata,"piece")
68+
@unreachable "piece is a reserved cell data name"
69+
end
70+
_celldata["piece"] = fill(part,num_cells(trian))
6771
vd = visualization_data(
68-
trian,"$(filebase)_$(n)";
72+
trian,filebase;
6973
order=order,nsubcells=nsubcells,
70-
celldata=celldata,cellfields=cellfields)
74+
celldata=_celldata,cellfields=cellfields)
7175
@assert length(vd) == 1
7276
vd[1]
7377
end
@@ -131,19 +135,21 @@ end
131135

132136
# Vtk related
133137

134-
# TODO use pvd format
135-
136138
function Visualization.write_vtk_file(
137139
grid::AbstractPData{<:Grid}, filebase; celldata, nodaldata)
138-
map_parts(grid,filebase,celldata,nodaldata) do g,f,c,n
139-
write_vtk_file(g,f;celldata=c,nodaldata=n)
140-
end
140+
pvtk = Visualization.create_vtk_file(grid,filebase;celldata=celldata,nodaldata=nodaldata)
141+
map_parts(vtk_save,pvtk)
141142
end
142143

143144
function Visualization.create_vtk_file(
144145
grid::AbstractPData{<:Grid}, filebase; celldata, nodaldata)
145-
map_parts(grid,filebase,celldata,nodaldata) do g,f,c,n
146-
create_vtk_file(g,f;celldata=c,nodaldata=n)
146+
parts = get_part_ids(grid)
147+
nparts = length(parts)
148+
map_parts(parts,grid,celldata,nodaldata) do part,g,c,n
149+
Visualization.create_pvtk_file(
150+
g,filebase;
151+
pvtkargs=[:part=>part,:nparts=>nparts],
152+
celldata=c,nodaldata=n)
147153
end
148154
end
149155

0 commit comments

Comments
 (0)