-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replicated Raviart-Thomas refes with new machinery
- Loading branch information
1 parent
f2d896d
commit 06fe0d4
Showing
11 changed files
with
483 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
|
||
struct DivConformity <: Conformity end | ||
abstract type DivConforming <: ReferenceFEName end | ||
|
||
# RaviartThomas | ||
|
||
struct RaviartThomas <: DivConforming end | ||
const raviart_thomas = RaviartThomas() | ||
|
||
""" | ||
RaviartThomasRefFE(::Type{et},p::Polytope,order::Integer) where et | ||
The `order` argument has the following meaning: the divergence of the functions in this basis | ||
is in the Q space of degree `order`. | ||
""" | ||
function RaviartThomasRefFE( | ||
::Type{T},p::Polytope{D},order::Integer | ||
) where {T,D} | ||
|
||
if is_n_cube(p) | ||
prebasis = QCurlGradJacobiPolynomialBasis{D}(T,order) # Prebasis | ||
cb = QGradJacobiPolynomialBasis{D}(T,order-1) # Cell basis | ||
fb = JacobiPolynomialBasis{D}(T,order,Polynomials._q_filter) # Face basis | ||
elseif is_simplex(p) | ||
prebasis = PCurlGradMonomialBasis{D}(et,order) # Prebasis | ||
cb = MonomialBasis{D}(T,order-1,Polynomials._p_filter) # Cell basis | ||
fb = JacobiPolynomialBasis{D}(T,order,Polynomials._p_filter) # Face basis | ||
else | ||
@notimplemented "H(div) Reference FE only available for cubes and simplices" | ||
end | ||
|
||
function cmom(φ,μ,ds) # Cell moment function | ||
Broadcasting(Operation(⋅))(φ,μ) | ||
end | ||
function fmom(φ,μ,ds) # Face moment function | ||
n = get_normal(ds) | ||
φn = Broadcasting(Operation(⋅))(φ,n) | ||
Broadcasting(Operation(*))(φn,μ) | ||
end | ||
moments = [ | ||
(get_dimrange(p,D-1),fmom,fb), # Face moments | ||
(get_dimrange(p,D),cmom,cb) # Cell moments | ||
] | ||
|
||
return MomentBasedReferenceFE(RaviartThomas(),p,prebasis,moments,DivConformity()) | ||
end | ||
|
||
function ReferenceFE(p::Polytope,::RaviartThomas,order;kwargs...) | ||
RaviartThomasRefFE(Float64,p,order;kwargs...) | ||
end | ||
|
||
function ReferenceFE(p::Polytope,::RaviartThomas,::Type{T},order;kwargs...) where T | ||
RaviartThomasRefFE(T,p,order;kwargs...) | ||
end | ||
|
||
function Conformity(reffe::GenericRefFE{RaviartThomas},sym::Symbol) | ||
hdiv = (:Hdiv,:HDiv) | ||
if sym == :L2 | ||
L2Conformity() | ||
elseif sym in hdiv | ||
DivConformity() | ||
else | ||
@unreachable """\n | ||
It is not possible to use conformity = $sym on a Raviart Thomas reference FE. | ||
Possible values of conformity for this reference fe are $((:L2, hdiv...)). | ||
""" | ||
end | ||
end | ||
|
||
function get_face_own_dofs(reffe::GenericRefFE{RaviartThomas}, conf::DivConformity) | ||
get_face_dofs(reffe) | ||
end | ||
|
||
# TODO: Please remove me | ||
function JacobiBasis(::Type{T},p::Polytope,orders) where T | ||
compute_jacobi_basis(T,p,orders) | ||
end | ||
function JacobiBasis(::Type{T},p::Polytope{D},order::Int) where {D,T} | ||
orders = tfill(order,Val{D}()) | ||
JacobiBasis(T,p,orders) | ||
end | ||
function compute_jacobi_basis(::Type{T},p::ExtrusionPolytope{D},orders) where {D,T} | ||
extrusion = Tuple(p.extrusion) | ||
terms = _monomial_terms(extrusion,orders) | ||
JacobiPolynomialBasis{D}(T,orders,terms) | ||
end | ||
|
||
# ContraVariantPiolaMap | ||
|
||
struct ContraVariantPiolaMap <: Map end | ||
|
||
function evaluate!( | ||
cache, | ||
::Broadcasting{typeof(∇)}, | ||
a::Fields.BroadcastOpFieldArray{ContraVariantPiolaMap} | ||
) | ||
v, Jt, sign_flip = a.args | ||
∇v = Broadcasting(∇)(v) | ||
k = ContraVariantPiolaMap() | ||
Broadcasting(Operation(k))(∇v,Jt,sign_flip) | ||
end | ||
|
||
function lazy_map( | ||
::Broadcasting{typeof(gradient)}, | ||
a::LazyArray{<:Fill{Broadcasting{Operation{ContraVariantPiolaMap}}}} | ||
) | ||
v, Jt, sign_flip = a.args | ||
∇v = lazy_map(Broadcasting(∇),v) | ||
k = ContraVariantPiolaMap() | ||
lazy_map(Broadcasting(Operation(k)),∇v,Jt,sign_flip) | ||
end | ||
|
||
function lazy_map( | ||
k::ContraVariantPiolaMap, | ||
cell_ref_shapefuns::AbstractArray{<:AbstractArray{<:Field}}, | ||
cell_map::AbstractArray{<:Field}, | ||
sign_flip::AbstractArray{<:AbstractArray{<:Field}} | ||
) | ||
cell_Jt = lazy_map(∇,cell_map) | ||
lazy_map(Broadcasting(Operation(k)),cell_ref_shapefuns,cell_Jt,sign_flip) | ||
end | ||
|
||
function evaluate!( | ||
cache,::ContraVariantPiolaMap, | ||
v::Number, | ||
Jt::Number, | ||
sign_flip::Bool | ||
) | ||
idetJ = 1/meas(Jt) | ||
((-1)^sign_flip*v)⋅(idetJ*Jt) | ||
end | ||
|
||
function evaluate!( | ||
cache, | ||
k::ContraVariantPiolaMap, | ||
v::AbstractVector{<:Field}, | ||
phi::Field, | ||
sign_flip::AbstractVector{<:Field} | ||
) | ||
Jt = ∇(phi) | ||
Broadcasting(Operation(k))(v,Jt,sign_flip) | ||
end |
Oops, something went wrong.