|
1 | 1 |
|
2 | 2 | """
|
3 |
| - struct ConstantFESpace <: SingleFieldFESpace |
4 |
| - # private fields |
5 |
| - end |
| 3 | +struct ConstantFESpace <: SingleFieldFESpace |
| 4 | + # private fields |
| 5 | +end |
6 | 6 | """
|
7 | 7 | struct ConstantFESpace{V,T,A,B,C} <: SingleFieldFESpace
|
8 |
| - model::DiscreteModel |
9 |
| - cell_basis::A |
10 |
| - cell_dof_basis::B |
11 |
| - cell_dof_ids::C |
12 |
| - function ConstantFESpace(model; |
13 |
| - vector_type::Type{V}=Vector{Float64}, |
14 |
| - field_type::Type{T}=Float64) where {V,T} |
15 |
| - function setup_cell_reffe(model::DiscreteModel, |
16 |
| - reffe::Tuple{<:Gridap.FESpaces.ReferenceFEName,Any,Any}; kwargs...) |
17 |
| - basis, reffe_args,reffe_kwargs = reffe |
18 |
| - cell_reffe = ReferenceFE(model,basis,reffe_args...;reffe_kwargs...) |
19 |
| - end |
20 |
| - reffe=ReferenceFE(lagrangian,T,0) |
21 |
| - cell_reffe = setup_cell_reffe(model,reffe) |
22 |
| - cell_basis_array=lazy_map(get_shapefuns,cell_reffe) |
23 |
| - |
24 |
| - cell_basis=Gridap.FESpaces.SingleFieldFEBasis( |
25 |
| - cell_basis_array, |
26 |
| - Triangulation(model), |
27 |
| - Gridap.FESpaces.TestBasis(), |
28 |
| - ReferenceDomain()) |
29 |
| - |
30 |
| - cell_dof_basis_array=lazy_map(get_dof_basis,cell_reffe) |
31 |
| - cell_dof_basis=Gridap.CellData.CellDof(cell_dof_basis_array,Triangulation(model),ReferenceDomain()) |
32 |
| - |
33 |
| - cell_dof_ids=Fill(Int32[1],num_cells(model)) |
34 |
| - A=typeof(cell_basis) |
35 |
| - B=typeof(cell_dof_basis) |
36 |
| - C=typeof(cell_dof_ids) |
37 |
| - new{V,T,A,B,C}(model, |
38 |
| - cell_basis, |
39 |
| - cell_dof_basis, |
40 |
| - cell_dof_ids) |
41 |
| - end |
| 8 | +model::DiscreteModel |
| 9 | +cell_basis::A |
| 10 | +cell_dof_basis::B |
| 11 | +cell_dof_ids::C |
| 12 | +function ConstantFESpace(model; |
| 13 | + vector_type::Type{V}=Vector{Float64}, |
| 14 | + field_type::Type{T}=Float64) where {V,T} |
| 15 | +function setup_cell_reffe(model::DiscreteModel, |
| 16 | + reffe::Tuple{<:ReferenceFEName,Any,Any}; kwargs...) |
| 17 | + basis, reffe_args,reffe_kwargs = reffe |
| 18 | + cell_reffe = ReferenceFE(model,basis,reffe_args...;reffe_kwargs...) |
| 19 | +end |
| 20 | +reffe=ReferenceFE(lagrangian,T,0) |
| 21 | +cell_reffe = setup_cell_reffe(model,reffe) |
| 22 | +cell_basis_array=lazy_map(get_shapefuns,cell_reffe) |
| 23 | + |
| 24 | +cell_basis=SingleFieldFEBasis( |
| 25 | + cell_basis_array, |
| 26 | + Triangulation(model), |
| 27 | + TestBasis(), |
| 28 | + ReferenceDomain()) |
| 29 | + |
| 30 | +cell_dof_basis_array=lazy_map(get_dof_basis,cell_reffe) |
| 31 | +cell_dof_basis=CellDof(cell_dof_basis_array,Triangulation(model),ReferenceDomain()) |
| 32 | + |
| 33 | +cell_dof_ids=Fill(Int32[1],num_cells(model)) |
| 34 | +A=typeof(cell_basis) |
| 35 | +B=typeof(cell_dof_basis) |
| 36 | +C=typeof(cell_dof_ids) |
| 37 | +new{V,T,A,B,C}(model, |
| 38 | + cell_basis, |
| 39 | + cell_dof_basis, |
| 40 | + cell_dof_ids) |
| 41 | +end |
42 | 42 | end
|
43 | 43 |
|
44 | 44 | # Genuine functions
|
45 |
| -function Gridap.FESpaces.TrialFESpace(f::ConstantFESpace) |
46 |
| - f |
| 45 | +function TrialFESpace(f::ConstantFESpace) |
| 46 | +f |
47 | 47 | end
|
48 | 48 |
|
49 | 49 | # Delegated functions
|
50 |
| -Gridap.FESpaces.get_triangulation(f::ConstantFESpace) = Triangulation(f.model) |
| 50 | +get_triangulation(f::ConstantFESpace) = Triangulation(f.model) |
51 | 51 |
|
52 |
| -Gridap.FESpaces.ConstraintStyle(::Type{<:ConstantFESpace}) = UnConstrained() |
| 52 | +ConstraintStyle(::Type{<:ConstantFESpace}) = UnConstrained() |
53 | 53 |
|
54 |
| -Gridap.FESpaces.get_dirichlet_dof_values(f::ConstantFESpace{V}) where V = eltype(V)[] |
| 54 | +get_dirichlet_dof_values(f::ConstantFESpace{V}) where V = eltype(V)[] |
55 | 55 |
|
56 |
| -Gridap.FESpaces.get_fe_basis(f::ConstantFESpace) = f.cell_basis |
| 56 | +get_fe_basis(f::ConstantFESpace) = f.cell_basis |
57 | 57 |
|
58 |
| -Gridap.FESpaces.get_fe_dof_basis(f::ConstantFESpace) = f.cell_dof_basis |
| 58 | +get_fe_dof_basis(f::ConstantFESpace) = f.cell_dof_basis |
59 | 59 |
|
60 |
| -Gridap.FESpaces.get_free_dof_ids(f::ConstantFESpace) = Base.OneTo(length(f.cell_dof_ids[1])) |
| 60 | +get_free_dof_ids(f::ConstantFESpace) = Base.OneTo(length(f.cell_dof_ids[1])) |
61 | 61 |
|
62 |
| -Gridap.FESpaces.get_vector_type(f::ConstantFESpace{V}) where V = V |
| 62 | +get_vector_type(f::ConstantFESpace{V}) where V = V |
63 | 63 |
|
64 |
| -Gridap.FESpaces.get_cell_dof_ids(f::ConstantFESpace) = f.cell_dof_ids |
| 64 | +get_cell_dof_ids(f::ConstantFESpace) = f.cell_dof_ids |
65 | 65 |
|
66 |
| -Gridap.FESpaces.get_dirichlet_dof_ids(f::ConstantFESpace) = Base.OneTo(0) |
| 66 | +get_dirichlet_dof_ids(f::ConstantFESpace) = Base.OneTo(0) |
67 | 67 |
|
68 |
| -Gridap.FESpaces.num_dirichlet_tags(f::ConstantFESpace) = 0 |
| 68 | +num_dirichlet_tags(f::ConstantFESpace) = 0 |
69 | 69 |
|
70 |
| -Gridap.FESpaces.get_dirichlet_dof_tag(f::ConstantFESpace) = Int8[] |
| 70 | +get_dirichlet_dof_tag(f::ConstantFESpace) = Int8[] |
71 | 71 |
|
72 |
| -function Gridap.FESpaces.scatter_free_and_dirichlet_values(f::ConstantFESpace,fv,dv) |
73 |
| - cell_dof_ids = get_cell_dof_ids(f) |
74 |
| - lazy_map(Broadcasting(Gridap.Arrays.PosNegReindex(fv,dv)),cell_dof_ids) |
| 72 | +function scatter_free_and_dirichlet_values(f::ConstantFESpace,fv,dv) |
| 73 | +cell_dof_ids = get_cell_dof_ids(f) |
| 74 | +lazy_map(Broadcasting(PosNegReindex(fv,dv)),cell_dof_ids) |
75 | 75 | end
|
76 | 76 |
|
77 |
| -function Gridap.FESpaces.gather_free_and_dirichlet_values(free_vals, |
78 |
| - dirichlet_vals, |
79 |
| - f::ConstantFESpace, |
80 |
| - cell_vals) |
81 |
| - cell_dofs = get_cell_dof_ids(f) |
82 |
| - cache_vals = array_cache(cv) |
83 |
| - cache_dofs = array_cache(cell_dofs) |
84 |
| - cells = 1:length(cell_vals) |
85 |
| - |
86 |
| - Gridap.FESpaces._free_and_dirichlet_values_fill!( |
87 |
| - free_vals, |
88 |
| - dirichlet_vals, |
89 |
| - cache_vals, |
90 |
| - cache_dofs, |
91 |
| - cv, |
92 |
| - cell_dofs, |
93 |
| - cells) |
94 |
| - |
95 |
| - (free_vals,dirichlet_vals) |
| 77 | +function gather_free_and_dirichlet_values!(free_vals, |
| 78 | + dirichlet_vals, |
| 79 | + f::ConstantFESpace, |
| 80 | + cell_vals) |
| 81 | +cell_dofs = get_cell_dof_ids(f) |
| 82 | +cache_vals = array_cache(cell_vals) |
| 83 | +cache_dofs = array_cache(cell_dofs) |
| 84 | +cells = 1:length(cell_vals) |
| 85 | + |
| 86 | +_free_and_dirichlet_values_fill!( |
| 87 | +free_vals, |
| 88 | +dirichlet_vals, |
| 89 | +cache_vals, |
| 90 | +cache_dofs, |
| 91 | +cell_vals, |
| 92 | +cell_dofs, |
| 93 | +cells) |
| 94 | + |
| 95 | +(free_vals,dirichlet_vals) |
96 | 96 | end
|
0 commit comments