Skip to content

Commit

Permalink
Save progress
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Dec 11, 2024
1 parent 124ae27 commit 8118a55
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions src/ReferenceFEs/Pullbacks.jl
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@

"""
abstract type Pullback <: Map end
abstract type Pushforward <: Map end
Represents a pullback map F*, defined as
Represents a pushforward map F*, defined as
F* : V̂ -> V
where
- V̂ is a function space on the reference cell K̂ and
- V is a function space on the physical cell K.
"""
abstract type Pullback <: Map end
abstract type Pushforward <: Map end

function lazy_map(
::Broadcasting{typeof(gradient)}, a::LazyArray{<:Fill{Broadcasting{Operation{<:Pullback}}}}
::Broadcasting{typeof(gradient)}, a::LazyArray{<:Fill{Broadcasting{Operation{<:Pushforward}}}}
)
cell_ref_basis, args = a.args
cell_ref_gradient = lazy_map(Broadcasting(∇),cell_ref_basis)
return lazy_map(a.maps.value,cell_ref_gradient,args...)
end

# InversePullback
# InversePushforward

"""
struct InversePullback{PB <: Pullback} <: Map end
struct InversePushforward{PF <: Pushforward} <: Map end
Represents the inverse of a pullback map F*, defined as
Represents the inverse of a pushforward map F*, defined as
(F*)^-1 : V -> V̂
where
- V̂ is a function space on the reference cell K̂ and
- V is a function space on the physical cell K.
"""
struct InversePullback{PB} <: Map
pullback::PB
function InversePullback(pullback::Pullback)
PB = typeof(pullback)
new{PB}(pullback)
struct InversePushforward{PF} <: Map
pushforward::PF
function InversePushforward(pushforward::Pushforward)
PF = typeof(pushforward)
new{PF}(pushforward)
end
end

Arrays.inverse_map(pb::Pullback) = InversePullback(pb)
Arrays.inverse_map(ipb::InversePullback) = ipb.pullback
Arrays.inverse_map(pb::Pushforward) = InversePushforward(pb)
Arrays.inverse_map(ipb::InversePushforward) = ipb.pushforward

# Pushforward

"""
struct Pushforward{PB <: Pullback} <: Map end
struct Pullback{PF <: Pushforward} <: Map end
Represents a pushforward map F**, defined as
F** : V* -> V̂*
where
- V̂* is a dof space on the reference cell K̂ and
- V* is a dof space on the physical cell K.
Its action on physical dofs σ : V -> R is defined in terms of the pullback map F* as
Its action on physical dofs σ : V -> R is defined in terms of the pushforward map F* as
F**(σ) := σ∘F* : V̂ -> R
"""
struct Pushforward{PB} <: Map
pullback::PB
function Pushforward(pullback::Pullback)
PB = typeof(pullback)
new{PB}(pullback)
struct Pullback{PF} <: Map
pushforward::PF
function Pullback(pushforward::Pushforward)
PF = typeof(pushforward)
new{PF}(pushforward)
end
end

Expand All @@ -66,46 +66,46 @@ function Arrays.lazy_map(
)
pf = k.maps.value
phys_cell_dofs, cell_map, pb_args = k.args
phys_cell_basis = lazy_map(pf.pullback,ref_cell_basis,cell_map,pb_args...)
phys_cell_basis = lazy_map(pf.pushforward,ref_cell_basis,cell_map,pb_args...)
return lazy_map(evaluate,phys_cell_dofs,phys_cell_basis)
end

# InversePushforward

"""
struct InversePushforward{PB <: Pullback} <: Map end
struct InversePushforward{PF <: Pushforward} <: Map end
Represents the inverse of the pushforward map F**, defined as
(F**)^-1 : V̂* -> V*
where
- V̂* is a dof space on the reference cell K̂ and
- V* is a dof space on the physical cell K.
Its action on reference dofs ̂σ : V -> R is defined in terms of the pullback map F* as
Its action on reference dofs ̂σ : V -> R is defined in terms of the pushforward map F* as
F**(̂σ) := ̂σ∘(F*)^-1 : V -> R
"""
struct InversePushforward{PB} <: Map
pullback::PB
function InversePushforward(pullback::Pullback)
PB = typeof(pullback)
new{PB}(pullback)
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.pullback)
Arrays.inverse_map(ipf::InversePushforward) = Pushforward(ipf.pullback)
Arrays.inverse_map(pf::Pushforward) = InversePushforward(pf.pushforward)
Arrays.inverse_map(ipf::InversePushforward) = Pushforward(ipf.pushforward)

function Arrays.lazy_map(
::typeof{evaluate},k::LazyArray{<:Fill{<:InversePushforward}},phys_cell_basis
)
pf = inverse_map(k.maps.value)
ref_cell_dofs, cell_map, pb_args = k.args
ref_cell_basis = lazy_map(inverse_map(pf.pullback),phys_cell_basis,cell_map,pb_args...)
ref_cell_basis = lazy_map(inverse_map(pf.pushforward),phys_cell_basis,cell_map,pb_args...)
return lazy_map(evaluate,ref_cell_dofs,ref_cell_basis)
end

# ContraVariantPiolaMap

struct ContraVariantPiolaMap <: Pullback end
struct ContraVariantPiolaMap <: Pushforward end

function lazy_map(
k::ContraVariantPiolaMap,
Expand Down

0 comments on commit 8118a55

Please sign in to comment.