Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added HomogeneousTrialFESpace and other enhancements in TrialFESpace #226

Merged
merged 1 commit into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/FESpaces/FESpaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ export is_a_fe_cell_basis

export TrialFESpace
export TrialFESpace!
export HomogeneousTrialFESpace
export HomogeneousTrialFESpace!
export TestFESpace
export compute_conforming_cell_dofs
export SparseMatrixAssembler
Expand Down
28 changes: 21 additions & 7 deletions src/FESpaces/TrialFESpaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,34 @@ struct TrialFESpace{B} <: SingleFieldFESpace
dirichlet_values::AbstractVector
cell_basis::CellBasis
constraint_style::Val{B}

function TrialFESpace(dirichlet_values::AbstractVector,space::SingleFieldFESpace)
cell_basis = _prepare_trial_cell_basis(space)
cs = constraint_style(space)
B = get_val_parameter(cs)
new{B}(space,dirichlet_values,cell_basis,cs)
end
end

"""
"""
function TrialFESpace(space::SingleFieldFESpace)
dirichlet_values = get_dirichlet_values(space)
cell_basis = _prepare_trial_cell_basis(space)
TrialFESpace(space,dirichlet_values,cell_basis,constraint_style(space))
TrialFESpace(dirichlet_values,space)
end

"""
"""
function TrialFESpace(space::SingleFieldFESpace,objects)
dirichlet_values = compute_dirichlet_values_for_tags(space,objects)
cell_basis = _prepare_trial_cell_basis(space)
TrialFESpace(space,dirichlet_values,cell_basis,constraint_style(space))
TrialFESpace(dirichlet_values,space)
end

"""
"""
function TrialFESpace(dir_values::AbstractVector,space::SingleFieldFESpace,objects)
function TrialFESpace!(dir_values::AbstractVector,space::SingleFieldFESpace,objects)
dir_values = compute_dirichlet_values_for_tags!(dir_values,space,objects)
cell_basis = _prepare_trial_cell_basis(space)
TrialFESpace(space,dir_values,cell_basis,constraint_style(space))
TrialFESpace(dir_values,space)
end

"""
Expand All @@ -42,6 +46,16 @@ function TrialFESpace(space::TrialFESpace)
space
end

function HomogeneousTrialFESpace(U::FESpace)
dirichlet_values = zero_dirichlet_values(U)
TrialFESpace(dirichlet_values,U)
end

function HomogeneousTrialFESpace!(dirichlet_values::AbstractVector,U::FESpace)
fill!(dirichlet_values,zero(eltype(dirichlet_values)))
TrialFESpace(dirichlet_values,U)
end

function _prepare_trial_cell_basis(space)
cb = get_cell_basis(space)
a = get_array(cb)
Expand Down
10 changes: 9 additions & 1 deletion test/FESpacesTests/TrialFESpacesTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ isa(V,SingleFieldFESpace)
ud = compute_dirichlet_values_for_tags!(v,V,[4,3])
@test all(ud .== v)
test_single_field_fe_space(U)
U = TrialFESpace(v,V,[4,3])
U = TrialFESpace!(v,V,[4,3])


matvecdata = ([],[],[])
Expand All @@ -46,6 +46,14 @@ TrialFESpace!(U,[1,2])
cell_basis = get_cell_basis(U)
@test is_trial(cell_basis)

U0 = HomogeneousTrialFESpace(V)
@test get_dirichlet_values(U0) == zeros(6)

U0 = HomogeneousTrialFESpace!(v,V)
@test v === get_dirichlet_values(U0)
@test v == zeros(6)
@test get_dirichlet_values(U0) == zeros(6)

#trian = get_triangulation(model)
#
#using Gridap.Visualization
Expand Down