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

Physical fes #216

Merged
merged 53 commits into from
Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a43b645
Corrected some typos and added a PhysicalBasesTests.jl
santiagobadia Mar 2, 2020
a826fc8
Problem with zero()
santiagobadia Mar 2, 2020
beb79d5
Minor to use `change_basis` function as a kernel
fverdugo Mar 3, 2020
21b5025
Typo labeing -> labeling + added a new function for computation FE sp…
santiagobadia Mar 3, 2020
152df55
Added a new method for physical FE spaces
santiagobadia Mar 4, 2020
5d1764c
Current version
santiagobadia Mar 4, 2020
015ee82
Now new method working in test
santiagobadia Mar 6, 2020
7f9ab1f
Further modifications
santiagobadia Mar 6, 2020
ca1cae0
Added method to FESpaces
santiagobadia Mar 6, 2020
adf80fd
GenericNodalRefFE -> GenericNodalCartesianRefFE
santiagobadia Mar 6, 2020
878287d
get_nodes from dofbasis et al
santiagobadia Mar 6, 2020
7210eec
Now everything works for physical space defined Lagrangian and RT ref…
santiagobadia Mar 7, 2020
bc2cec4
Better internal structure methods
santiagobadia Mar 7, 2020
1c5f941
Test improvements
santiagobadia Mar 7, 2020
78d783a
Machinery for creating Grand and Curl conforming FE spaces with DOFs …
santiagobadia Mar 7, 2020
0fd0aea
Added methods for interpolation in the physical space
santiagobadia Mar 9, 2020
160c05a
Added tests
santiagobadia Mar 9, 2020
5d6df6e
Bug in FE factories
santiagobadia Mar 9, 2020
2eadae1
Merge branch 'master' of github.com:gridap/Gridap.jl into physical-fes
santiagobadia Mar 9, 2020
ddd4c1d
Typos
santiagobadia Mar 9, 2020
51eda45
curl in physical
santiagobadia Mar 9, 2020
9ba259d
CellDofBasis and Traits for CellFieldLike
santiagobadia Mar 12, 2020
5a1fcfd
Added CellDofBasis to FE spaces constructors
santiagobadia Mar 12, 2020
2f53775
Fixing bugs
santiagobadia Mar 12, 2020
f7421a8
fixing extended fe space
santiagobadia Mar 12, 2020
213cccd
Adding methods, traits, fixing bugs
santiagobadia Mar 13, 2020
cdeb6bf
Now working interpolation
santiagobadia Mar 13, 2020
8e15408
minor
santiagobadia Mar 13, 2020
ec1453b
Adding Trails to CellBasis and CellFields
santiagobadia Mar 17, 2020
f748683
Fixing typos, misc changes
santiagobadia Mar 18, 2020
5055e2a
Fixing typos, e.g., extended fe spaces
santiagobadia Mar 19, 2020
09a9cb4
Added tests, fixing typos
santiagobadia Mar 19, 2020
a7c3a38
Added tests, fixes
santiagobadia Mar 19, 2020
cbcdabd
Added poisson test in physical space
santiagobadia Mar 19, 2020
6e1b494
Merge branch 'master' of github.com:gridap/Gridap.jl into physical-fes
santiagobadia Mar 19, 2020
19313fa
Fixing Hcurl, order in RT
santiagobadia Mar 19, 2020
4306a8f
Renamed RefTrat -> RefStyle
santiagobadia Mar 19, 2020
5fff1f6
Moving RefStyle to CellFieldLike
santiagobadia Mar 19, 2020
86077f0
Moving RefStyle to CellFieldLike 2
santiagobadia Mar 19, 2020
67ae319
More on the same REfStyle move
santiagobadia Mar 19, 2020
9acce8f
Removed inner constructor
santiagobadia Mar 19, 2020
380c716
Improving CellDofBasis
santiagobadia Mar 19, 2020
2b69c80
Added to_ref_space and to_physical_space methods for CellFieldLike
santiagobadia Mar 19, 2020
bcec842
Some minor changes
santiagobadia Mar 19, 2020
47dde12
Moving methods to CellFieldLike, intensive cleaning up, etc
santiagobadia Mar 20, 2020
1e677db
Cleaning up
santiagobadia Mar 20, 2020
593246e
Adding RefStyle to more CellFieldLike subtypes
santiagobadia Mar 20, 2020
11f5598
Eliminating trait from evaluate_dof_array
santiagobadia Mar 20, 2020
08fb421
No RefStyle in Interpolate
santiagobadia Mar 20, 2020
5e2885d
Reactivating some docs
fverdugo Mar 20, 2020
685a4fb
Misc changes to make phys ref spaces work (single field)
fverdugo Mar 20, 2020
1cfe779
physical fe spaces also for multi-field
fverdugo Mar 20, 2020
f87a951
Corrected DG space w/ physical, multifield tests
santiagobadia Mar 21, 2020
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
4 changes: 2 additions & 2 deletions docs/src/ReferenceFEs.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ get_face_own_nodes_permutations(reffe::NodalReferenceFE,d::Integer)
get_face_nodes(reffe::NodalReferenceFE,d::Integer)
```

### GenericNodalRefFE
### GenericNodalCartesianRefFE

```@docs
GenericNodalRefFE
GenericNodalCartesianRefFE
```

### Lagrangian reference elements
Expand Down
2 changes: 1 addition & 1 deletion docs/src/TensorValues.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ n_components
inner
outer
meas
symmetic_part
symmetric_part
```

3 changes: 1 addition & 2 deletions src/Arrays/Apply.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ end
"""
apply_all(f::Tuple,a::AbstractArray...) -> Tuple

Numerically equivalent to
Numerically equivalent to

tuple( ( apply(fi, a...) for fi in f)... )

Expand Down Expand Up @@ -370,4 +370,3 @@ Base.IndexStyle(::Type{<:ArrayWithCounter{T,N,A}}) where {T,A,N} = IndexStyle(A)
function reset_counter!(a::ArrayWithCounter)
a.counter[:] .= 0
end

6 changes: 2 additions & 4 deletions src/Arrays/Tables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
ptrs::Vector{P}
end

Type representing a list of lists (i.e., a table) in
Type representing a list of lists (i.e., a table) in
compressed format.
"""
struct Table{T,P} <: AbstractVector{Vector{T}}
Expand Down Expand Up @@ -337,7 +337,7 @@ end
"""
collect1d(a)

Equivalent to
Equivalent to

[a[i] for in 1:length(a)]
"""
Expand Down Expand Up @@ -442,5 +442,3 @@ function from_dict(::Type{Table{T,P}}, dict::Dict{Symbol,Any}) where {T,P}
ptrs::Vector{P} = dict[:ptrs]
Table(data,ptrs)
end


9 changes: 4 additions & 5 deletions src/FESpaces/CLagrangianFESpaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
end
"""
struct CLagrangianFESpace{S} <: SingleFieldFESpace
space::UnsconstrainedFESpace
space::UnconstrainedFESpace
grid::Grid
dof_to_node::Vector{Int}
dof_to_comp::Vector{Int8}
Expand All @@ -19,7 +19,7 @@ struct CLagrangianFESpace{S} <: SingleFieldFESpace
CLagrangianFESpace(::Type{T},grid::Grid) where T
"""
function CLagrangianFESpace(::Type{T},grid::Grid) where T
space, dof_to_node, dof_to_comp, node_and_comp_to_dof = _generate_clargangian_fespace(T,grid)
space, dof_to_node, dof_to_comp, node_and_comp_to_dof = _generate_clagrangian_fespace(T,grid)
S = eltype(node_and_comp_to_dof)
new{S}(space,grid,dof_to_node,dof_to_comp,node_and_comp_to_dof)
end
Expand Down Expand Up @@ -81,7 +81,7 @@ end

# Helpers

function _generate_clargangian_fespace(T,grid)
function _generate_clagrangian_fespace(T,grid)

grid_reffes = get_reffes(grid)
function fun(reffe)
Expand Down Expand Up @@ -114,7 +114,7 @@ function _generate_clargangian_fespace(T,grid)
dirichlet_cells = Int[]
ntags = 0

space = UnsconstrainedFESpace(
space = UnconstrainedFESpace(
nfree,
ndirichlet,
cell_dofs,
Expand Down Expand Up @@ -235,4 +235,3 @@ function _fill_cell_dofs_clagrangian_fespace!(
end

end

71 changes: 48 additions & 23 deletions src/FESpaces/CellBases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,20 @@ end

# Define how the metadata is preserved

function change_ref_style(cf::CellBasis)
ref_sty = RefStyle(cf)
bool = !get_val_parameter(ref_sty)
new_sty = Val{bool}()
trial_style = TrialStyle(cf)
ar = get_array(cf)
cm = get_cell_map(cf)
GenericCellBasis(trial_style,ar,cm,new_sty)
end

function similar_object(cf::CellBasis,array::AbstractArray)
cm = get_cell_map(cf)
trial_style = TrialStyle(cf)
GenericCellBasis(trial_style,array,cm)
GenericCellBasis(trial_style,array,cm,RefStyle(cf))
end

function similar_object(a::CellBasis,b::CellField,v::AbstractArray)
Expand Down Expand Up @@ -73,7 +83,8 @@ end

function _similar_cell_basis_test_trial(v,a,b)
cm = get_cell_map(a)
GenericCellMatrixField(v,cm)
@assert is_in_ref_space(a) == is_in_ref_space(b)
GenericCellMatrixField(v,cm,RefStyle(a))
end

# Operations
Expand Down Expand Up @@ -114,13 +125,13 @@ end

function operate(op,cf1::CellBasis,object)
cm = get_cell_map(cf1)
cf2 = convert_to_cell_field(object,cm)
cf2 = convert_to_cell_field(object,cm,RefStyle(cf1))
operate(op,cf1,cf2)
end

function operate(op,object,cf2::CellBasis)
cm = get_cell_map(cf2)
cf1 = convert_to_cell_field(object,cm)
cf1 = convert_to_cell_field(object,cm,RefStyle(cf2))
operate(op,cf1,cf2)
end

Expand Down Expand Up @@ -191,17 +202,16 @@ end

"""
"""
struct GenericCellBasis{T} <: CellBasis
struct GenericCellBasis{T,R} <: CellBasis
trial_style::Val{T}
array
cell_map
ref_trait::Val{R}
end

"""
"""
function GenericCellBasis(array::AbstractArray,cell_map::AbstractArray)
trial_style = Val{false}()
GenericCellBasis(trial_style,array,cell_map)
function GenericCellBasis(trial_style::Val{T},array::AbstractArray,cell_map::AbstractArray) where T
ref_trait = Val{true}()
GenericCellBasis(trial_style,array,cell_map,ref_trait)
end

get_array(a::GenericCellBasis) = a.array
Expand All @@ -212,7 +222,9 @@ function TrialStyle(::Type{<:GenericCellBasis{T}}) where T
Val{T}()
end

# CellMatrixField
function RefStyle(::Type{<:GenericCellBasis{T,R}}) where {T,R}
Val{R}()
end

"""
"""
Expand All @@ -226,9 +238,18 @@ end

# Define how the metadata is preserved

function change_ref_style(cf::CellMatrixField)
ref_sty = RefStyle(cf)
bool = !get_val_parameter(ref_sty)
new_sty = Val{bool}()
ar = get_array(cf)
cm = get_cell_map(cf)
GenericCellMatrixField(ar,cm,new_sty)
end

function similar_object(cf::CellMatrixField,a::AbstractArray)
cm = get_cell_map(cf)
GenericCellMatrixField(a,cm)
GenericCellMatrixField(a,cm,RefStyle(cf))
end

function similar_object(a::CellMatrixField,b::CellField,v::AbstractArray)
Expand Down Expand Up @@ -274,33 +295,38 @@ end

function operate(op,a::CellMatrixField,b)
cm = get_cell_map(a)
_b = convert_to_cell_field(b,cm)
_b = convert_to_cell_field(b,cm,RefStyle(a))
operate(op,a,_b)
end

function operate(op,a,b::CellMatrixField)
cm = get_cell_map(b)
_a = convert_to_cell_field(a,cm)
_a = convert_to_cell_field(a,cm,RefStyle(b))
operate(op,_a,b)
end


# Concrete CellMatrixField

"""
"""
struct GenericCellMatrixField{A,B} <: CellMatrixField
struct GenericCellMatrixField{A,B,R} <: CellMatrixField
array::A
cell_map::B
ref_style::Val{R}
end

RefStyle(::Type{GenericCellMatrixField{A,B,R}}) where {A,B,R} = Val{R}()

get_array(a::GenericCellMatrixField) = a.array

get_cell_map(a::GenericCellMatrixField) = a.cell_map

# Restrictions

function restrict(cf::CellBasis,trian::Triangulation)
a = get_array(cf)
_cf = to_ref_space(cf)
a = get_array(_cf)
r = restrict(a,trian)
trial_style = TrialStyle(cf)
_restrict_cell_basis(trial_style,r,trian)
Expand Down Expand Up @@ -398,13 +424,13 @@ end

function operate(op,cf1::SkeletonCellBasis,object)
cm = get_cell_map(cf1)
cf2 = convert_to_cell_field(object,cm)
cf2 = convert_to_cell_field(object,cm,RefStyle(cf1.left))
operate(op,cf1,cf2)
end

function operate(op,object,cf2::SkeletonCellBasis)
cm = get_cell_map(cf2)
cf1 = convert_to_cell_field(object,cm)
cf1 = convert_to_cell_field(object,cm,RefStyle(cf2.left))
operate(op,cf1,cf2)
end

Expand Down Expand Up @@ -450,13 +476,13 @@ end

function operate(op,cf1::ReducedSkeletonCellBasis,object)
cm = get_cell_map(cf1)
cf2 = convert_to_cell_field(object,cm)
cf2 = convert_to_cell_field(object,cm,RefStyle(cf1.left))
operate(op,cf1,cf2)
end

function operate(op,object,cf2::ReducedSkeletonCellBasis)
cm = get_cell_map(cf2)
cf1 = convert_to_cell_field(object,cm)
cf1 = convert_to_cell_field(object,cm,RefStyle(cf2.left))
operate(op,cf1,cf2)
end

Expand Down Expand Up @@ -533,13 +559,13 @@ end

function operate(op,object,cf2::SkeletonCellMatrixField)
cm = get_cell_map(cf2)
cf1 = convert_to_cell_field(object,cm)
cf1 = convert_to_cell_field(object,cm,RefStyle(cf2.ll))
operate(op,cf1,cf2)
end

function operate(op,cf1::SkeletonCellMatrixField,object)
cm = get_cell_map(cf1)
cf2 = convert_to_cell_field(object,cm)
cf2 = convert_to_cell_field(object,cm,RefStyle(cf1.ll))
operate(op,cf1,cf2)
end

Expand Down Expand Up @@ -645,4 +671,3 @@ end
add_to_array!(vecd,vec)
(mat, vecd)
end

55 changes: 55 additions & 0 deletions src/FESpaces/CellDofBases.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
abstract type CellDofBasis end

Abstract type that represents a cell array of `Dof`. The main motivation for
its definition is to provide a trait that informs whether the `Dof` entries are
defined for functions in the reference or physical space
"""
abstract type CellDofBasis end

santiagobadia marked this conversation as resolved.
Show resolved Hide resolved
RefStyle(::Type{<:CellDofBasis}) = @abstractmethod
get_array(::CellDofBasis) = @abstractmethod

function test_cell_dof_basis(cf::CellDofBasis,f::CellFieldLike)
ar = get_array(cf)
@test isa(ar,AbstractArray)
a = evaluate(cf,f)
_ = collect(a)
rs = RefStyle(cf)
@test isa(get_val_parameter(rs),Bool)
end

"""
evaluate(dof_array::CellDofBasis,field_array::AbstractArray)

Evaluates the `CellDofBasis` for the `Field` objects
at the array `field` element by element.

The result is numerically equivalent to

map(evaluate_dof, dof_array.array, field_array)

but it is described with a more memory-friendly lazy type.
"""
function evaluate(cell_dofs::CellDofBasis,cell_field::CellFieldLike)
_evaluate_cell_dofs(cell_dofs,cell_field,RefStyle(cell_dofs))
end

function _evaluate_cell_dofs(cell_dofs,cell_field,ref_trait::Val{true})
evaluate_dof_array(get_array(cell_dofs),get_array(to_ref_space(cell_field)))
end

function _evaluate_cell_dofs(cell_dofs,cell_field,ref_trait::Val{false})
evaluate_dof_array(get_array(cell_dofs),get_array(to_physical_space(cell_field)))
end

"""
"""
struct GenericCellDofBasis{R} <: CellDofBasis
ref_trait::Val{R}
array::AbstractArray{<:Dof}
end

RefStyle(::Type{<:GenericCellDofBasis{R}}) where R = Val{R}()

get_array(a::GenericCellDofBasis) = a.array
Loading