Skip to content

Commit

Permalink
Saved progress
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Dec 18, 2024
1 parent 73909ac commit 2178276
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 38 deletions.
12 changes: 11 additions & 1 deletion docs/src/ReferenceFEs.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,18 @@ Pages = ["LagrangianRefFEs.jl","LagrangianDofBases.jl","SerendipityRefFEs.jl",

### Moment-Based ReferenceFEs

#### Framework

```@autodocs
Modules = [ReferenceFEs,]
Order = [:type, :constant, :macro, :function]
Pages = ["MomentBasedReferenceFEs.jl","Pullbacks.jl"]
```

#### Available Moment-Based ReferenceFEs

```@autodocs
Modules = [ReferenceFEs,]
Order = [:type, :constant, :macro, :function]
Pages = ["MomentBasedReferenceFEs.jl","RaviartThomasRefFEs.jl","NedelecRefFEs.jl","BDMRefFEs.jl","CRRefFEs.jl"]
Pages = ["RaviartThomasRefFEs.jl","NedelecRefFEs.jl","BDMRefFEs.jl","CRRefFEs.jl"]
```
13 changes: 13 additions & 0 deletions src/Arrays/Maps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,16 @@ function inverse_map(f)
Function inverse_map is not implemented yet for objects of type $(typeof(f))
"""
end

struct InverseMap{F} <: Map
original::F
end

function evaluate!(cache,k::InverseMap,args...)
@notimplemented """\n
The inverse evaluation is not implemented yet for maps of type $(typeof(k.original))
"""
end

inverse_map(k::Map) = InverseMap(k)
inverse_map(k::InverseMap) = k.original
12 changes: 6 additions & 6 deletions src/Fields/AffineMaps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ end

affine_map(gradient,origin) = AffineField(gradient,origin)

function Base.zero(::Type{<:AffineField{D1,D2,T}}) where {D1,D2,T}
gradient = TensorValue{D1,D2}(tfill(zero(T),Val{D1*D2}()))
origin = Point{D2,T}(tfill(zero(T),Val{D2}()))
AffineField(gradient,origin)
end

function evaluate!(cache,f::AffineField,x::Point)
G = f.gradient
y0 = f.origin
Expand Down Expand Up @@ -129,9 +135,3 @@ function lazy_map(
origins = a.args[2]
lazy_map(Broadcasting(AffineMap()),gradients,origins,x)
end

function Base.zero(::Type{<:AffineField{D1,D2,T}}) where {D1,D2,T}
gradient = TensorValue{D1,D2}(tfill(zero(T),Val{D1*D2}()))
origin = Point{D2,T}(tfill(zero(T),Val{D2}()))
AffineField(gradient,origin)
end
4 changes: 2 additions & 2 deletions src/Fields/InverseFields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ inverse_map(a::Field) = InverseField(a)
inverse_map(a::InverseField) = a.original

function return_cache(a::InverseField,x::Point)
y₀ = [zero(x)...] # initial guess and solution
F₀ = [zero(x)...] # error
y₀ = [zero(x)...] # initial guess and solution
F₀ = [zero(x)...] # error
return return_cache(a.original,x), return_cache((a.original),x), y₀, F₀
end

Expand Down
37 changes: 8 additions & 29 deletions src/ReferenceFEs/Pullbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end
# InversePushforward

"""
struct InversePushforward{PF <: Pushforward} <: Map end
const InversePushforward{PF} = InverseMap{PF} where PF <: Pushforward
Represents the inverse of a pushforward map F*, defined as
(F*)^-1 : V -> V̂
Expand All @@ -75,16 +75,7 @@ specific pushforward type:
- `evaluate!(cache, k::InversePushforward{PF}, v_phys::Number, args...)`
"""
struct InversePushforward{PF} <: Map
pushforward::PF
function InversePushforward(pushforward::Pushforward)
PF = typeof(pushforward)
new{PF}(pushforward)
end
end

Arrays.inverse_map(pf::Pushforward) = InversePushforward(pf)
Arrays.inverse_map(ipf::InversePushforward) = ipf.pushforward
const InversePushforward{PF} = InverseMap{PF} where PF <: Pushforward

function Arrays.lazy_map(
k::InversePushforward, phys_cell_fields::AbstractArray, pf_args::AbstractArray...
Expand All @@ -97,15 +88,15 @@ function Arrays.return_cache(
)
mock_basis(::VectorValue{D,T}) where {D,T} = one(TensorValue{D,D,T})
v_ref_basis = mock_basis(v_phys)
pf_cache = return_cache(k.pushforward,v_ref_basis,args...)
pf_cache = return_cache(inverse_map(k),v_ref_basis,args...)
return v_ref_basis, pf_cache
end

function Arrays.evaluate!(
cache, k::InversePushforward, v_phys::Number, args...
)
v_ref_basis, pf_cache = cache
change = evaluate!(pf_cache,k.pushforward,v_ref_basis,args...)
change = evaluate!(pf_cache,inverse_map(k),v_ref_basis,args...)
return v_physinv(change)
end

Expand Down Expand Up @@ -180,12 +171,8 @@ where
Its action on physical dofs σ : V -> R is defined in terms of the pushforward map F* as
̂σ = F**(σ) := σ∘F* : V̂ -> R
"""
struct Pullback{PF} <: Map
struct Pullback{PF <: Pushforward} <: Map
pushforward::PF
function Pullback(pushforward::Pushforward)
PF = typeof(pushforward)
new{PF}(pushforward)
end
end

function Arrays.lazy_map(
Expand Down Expand Up @@ -216,16 +203,7 @@ where
Its action on reference dofs ̂σ : V̂ -> R is defined in terms of the pushforward map F* as
σ = (F**)^-1(̂σ) := ̂σ∘(F*)^-1 : V -> R
"""
struct InversePullback{PF} <: Map
pushforward::PF
function InversePullback(pushforward::Pushforward)
PF = typeof(pushforward)
new{PF}(pushforward)
end
end

Arrays.inverse_map(pb::Pullback) = InversePullback(pb.pushforward)
Arrays.inverse_map(ipb::InversePullback) = Pullback(ipb.pushforward)
const InversePullback{PB} = InverseMap{PB} where PB <: Pullback

function Arrays.lazy_map(
::typeof(evaluate), k::LazyArray{<:Fill{<:InversePullback}}, phys_cell_fields::AbstractArray
Expand All @@ -240,7 +218,8 @@ end
function evaluate!(
cache, k::InversePullback, σ_ref::AbstractVector{<:Dof}, args...
)
return MappedDofBasis(inverse_map(k.pushforward),σ_ref,args...)
pb = inverse_map(k)
return MappedDofBasis(inverse_map(pb.pushforward),σ_ref,args...)
end

# ContraVariantPiolaMap
Expand Down

0 comments on commit 2178276

Please sign in to comment.