Skip to content

Draft for generating pvd collection files #70

@fverdugo

Description

@fverdugo

Draft for generating pvd collection files. Cc @oriolcg

parts = nothing # For serial
parts = get_part_ids(...) # For distributed

#Serial only
model = CartesianDiscreteModel(domain,cells)

#Serial and parallel
model = CartesianDiscreteModel(parts,domain,cells)

# Serial only
createpvd("results") do pvd
  for (x,t) in xt
    pvtk = createvtk(Ω,"filename_$t",cellfields=["x"=>x])
    pvd[t] = pvtk
  end
end

#Serial and parallel
createpvd(parts,"results") do pvd
  for (x,t) in xt
    pvtk = createvtk(Ω,"filename_$t",cellfields=["x"=>x])
    pvd[t] = pvtk
  end
end


# Serial. #TODO the versions taking nothing

function createpvd(args...;kwargs...)
  paraview_collection(args...;kwargs...)
end

function savepvd(pvd)
  vtk_save(pvd)
end


# Parallel

struct DistributedPvd{T}
  pvds{T}
end

function createpvd(parts::AbstractPData,args...;kwargs...)
  pvds = map_main(parts) do part
    paraview_collection(args...;kwargs...)
  end
  DistributedPvd(pvds)
end

function savepvd(pvd::DistributedPvd)
  map_main(pvd.pvds) do pvd
    vtk_save(pvd)
  end
end

function createpvd(f,parts::AbstractPData,args...;kwargs...)
  pvd = createpvd(parts,args...;kwargs...)
  try
    f(pvd)
  finally
    savepvd(pvd)
  end
end

function setindex!(pvd::DistributedPvd,pvtk::AbstractPData)
  map_parts(vtk_save,pvtk)
  map_main(pvtk,pvd.pvds) do pvtk,pvd
    pvd[t] = pvtk
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions