Skip to content

Commit

Permalink
Added ConstantFESpaces
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Sep 17, 2024
1 parent 32f477f commit 0bc9184
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/FESpaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -869,3 +869,22 @@ function _compute_new_distributed_fixedval(
c = reduce(+,c_i,init=zero(eltype(c_i)))
return c
end

function FESpaces.ConstantFESpace(model::DistributedDiscreteModel;kwargs...)
@warn "ConstantFESpace is NOT scalable in parallel. For testing purposes only."
spaces = map(local_views(model)) do model
ConstantFESpace(model;kwargs...)
end

# Single dof, owned by processor 1 (ghost for all other processors)
cell_gids = get_cell_gids(model)
indices = map(partition(cell_gids)) do cell_indices
me = part_id(cell_indices)
LocalIndices(1,me,Int[1],Int32[1])
end
gids = PRange(indices)

trian = DistributedTriangulation(map(get_triangulation,spaces),model)
vector_type = _find_vector_type(spaces,gids)
return DistributedSingleFieldFESpace(spaces,gids,trian,vector_type)
end
27 changes: 27 additions & 0 deletions test/ConstantFESpacesTests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

using Gridap
using GridapDistributed, PartitionedArrays

using Gridap.FESpaces

np = (2,2)
ranks = with_debug() do distribute
distribute(LinearIndices((prod(np),)))
end

model = CartesianDiscreteModel(ranks,np,(0,1,0,1),(4,4))

Ω = Triangulation(model)
= Measure(Ω,2)

V = ConstantFESpace(model)

gids = get_free_dof_ids(V)
local_to_global(gids)
local_to_owner(gids)
ghost_to_local(gids)
own_to_local(gids)

uh = zero(V)
sum((uh)dΩ)

0 comments on commit 0bc9184

Please sign in to comment.