Skip to content

Commit

Permalink
Added some missing API for MultiField
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Mar 19, 2024
1 parent a5a15eb commit 0372ca6
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/MultiField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,23 @@ function FESpaces.FEFunction(f::DistributedMultiFieldFESpace,x::AbstractVector,i
DistributedMultiFieldFEFunction(field_fe_fun,part_fe_fun,free_values)
end

function FESpaces.FEFunction(
f::DistributedMultiFieldFESpace,x::AbstractVector,
dirichlet_values::AbstractArray{<:AbstractVector},isconsistent=false
)
free_values = GridapDistributed.change_ghost(x,f.gids;is_consistent=isconsistent,make_consistent=true)
part_fe_fun = map(FEFunction,f.part_fe_space,partition(free_values))
field_fe_fun = DistributedSingleFieldFEFunction[]
for i in 1:num_fields(f)
free_values_i = restrict_to_field(f,free_values,i)
dirichlet_values_i = dirichlet_values[i]
fe_space_i = f.field_fe_space[i]
fe_fun_i = FEFunction(fe_space_i,free_values_i,dirichlet_values_i,true)
push!(field_fe_fun,fe_fun_i)
end
DistributedMultiFieldFEFunction(field_fe_fun,part_fe_fun,free_values)
end

function FESpaces.EvaluationFunction(f::DistributedMultiFieldFESpace,x::AbstractVector,isconsistent=false)
free_values = change_ghost(x,f.gids;is_consistent=isconsistent,make_consistent=true)
part_fe_fun = map(EvaluationFunction,f.part_fe_space,partition(free_values))
Expand Down Expand Up @@ -153,6 +170,24 @@ function FESpaces.interpolate!(objects,free_values::AbstractVector,fe::Distribut
DistributedMultiFieldFEFunction(field_fe_fun,part_fe_fun,free_values)
end

function Gridap.FESpaces.interpolate!(
objects::Union{<:DistributedMultiFieldCellField,<:DistributedCellField},
free_values::AbstractVector,
fe::DistributedMultiFieldFESpace
)
part_fe_fun = map(local_views(objects),partition(free_values),local_views(fe)) do objects,x,f
interpolate!(objects,x,f)
end
field_fe_fun = GridapDistributed.DistributedSingleFieldFEFunction[]
for i in 1:num_fields(fe)
free_values_i = Gridap.MultiField.restrict_to_field(fe,free_values,i)
fe_space_i = fe.field_fe_space[i]
fe_fun_i = FEFunction(fe_space_i,free_values_i)
push!(field_fe_fun,fe_fun_i)
end
GridapDistributed.DistributedMultiFieldFEFunction(field_fe_fun,part_fe_fun,free_values)
end

function FESpaces.interpolate_everywhere(objects,fe::DistributedMultiFieldFESpace)
free_values = zero_free_values(fe)
part_fe_fun = map(partition(free_values),local_views(fe)) do x,f
Expand Down

0 comments on commit 0372ca6

Please sign in to comment.