Skip to content

Commit

Permalink
Started adding sero-mean FESpace
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Jul 23, 2024
1 parent 9e1e6e9 commit 4b0d45d
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/FESpaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,13 @@ function _EvaluationFunction(func,
end

function FESpaces.get_fe_basis(f::DistributedSingleFieldFESpace)
fields = map(get_fe_basis,f.spaces)
fields = map(get_fe_basis,local_views(f))
trian = get_triangulation(f)
DistributedCellField(fields,trian)
end

function FESpaces.get_trial_fe_basis(f::DistributedSingleFieldFESpace)
fields = map(get_trial_fe_basis,f.spaces)
fields = map(get_trial_fe_basis,local_views(f))
trian = get_triangulation(f)
DistributedCellField(fields,trian)
end
Expand Down Expand Up @@ -702,3 +702,32 @@ function FESpaces.SparseMatrixAssembler(
Tm = SparseMatrixCSC{T,Int}
SparseMatrixAssembler(Tm,Tv,trial,test,par_strategy)
end

# ZeroMean FESpace

#const DistributedZeroMeanFESpace = DistributedSingleFieldFESpace{}

struct ZeroMeanCache{A}
vol_i::A
vol::Float64
end

function FESpaces.ZeroMeanFESpace(space::DistributedFESpace)#,dΩ::DistributedMeasure)
gids = get_free_dof_ids(space)
ranks = get_parts(space)
spaces = map(ranks,partition(gids),local_views(space)) do r, gids, lspace
fix_constant = isone(r) # Only main processor fixes the constant
dof_to_fix = Int(first(own_to_local(gids))) # Make sure it's an owned DoF
FESpaceWithConstantFixed(lspace,fix_constant,dof_to_fix)
end

#vol_i = assemble_vector(v->∫(v)*dΩ,space)
#vol = sum(vol_i)
#metadata = ZeroMeanCache(vol_i,vol)

trian = get_triangulation(space)
model = get_background_model(trian)
gids = generate_gids(model,spaces)
vector_type = _find_vector_type(spaces,gids)
DistributedSingleFieldFESpace(spaces,gids,trian,vector_type)
end

0 comments on commit 4b0d45d

Please sign in to comment.