GridapP4est.jl extension
Building on top of GridapP4est.jl, GridapSolvers provides tools to use the P4est library to build DiscreteModelHierarchy
objects.
GridapSolvers.P4estCartesianModelHierarchy
— FunctionP4estCartesianModelHierarchy(
ranks,np_per_level,domain,nc;
num_refs_coarse::Integer = 0,
add_labels!::Function = (labels -> nothing),
map::Function = identity,
isperiodic = Tuple(fill(false,length(nc)))
)
Returns a ModelHierarchy
with a Cartesian model as coarsest level, using GridapP4est.jl. The i-th level will be distributed among np_per_level[i]
processors. The seed model is given by cmodel = CartesianDiscreteModel(domain,nc)
.
Examples of usage
# Start from a coarse mesh, then refine
function p4est_mesh_by_refinement(distribute,np_per_level,domain,nc;nrefs=0)
GridapP4est.with(parts) do
parts = distribute(LinearIndices((np_per_level[1],)))
cparts = generate_subparts(parts,np_per_level[end])
base = CartesianDiscreteModel(domain,nc)
cmodel = OctreeDistributedDiscreteModel(cparts,base,nrefs)
return ModelHierarchy(parts,cmodel,np_per_level)
end
end
# Start from a fine mesh, then coarsen
function p4est_mesh_by_coarsening(distribute,np_per_level,domain,nc;nrefs=0)
GridapP4est.with(parts) do
n_levs = length(np_per_level)
fparts = distribute(LinearIndices((np_per_level[1],)))
base = CartesianDiscreteModel(domain,nc)
fmodel = OctreeDistributedDiscreteModel(fparts,base,nrefs+n_levs)
return ModelHierarchy(parts,fmodel,np_per_level)
end
end