Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 20 additions & 9 deletions src/ComputationalModels/BoundaryConditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ end

function residual_Neumann(::NothingBC, kwargs...) end

"""
residual_Neumann(...)::Function

Return the Neumann residual as a FUNCTION.
"""
function residual_Neumann(bc::NeumannBC, dΓ::Vector, Λ::Float64)
v -> mapreduce((fi, dΓi) -> ∫(v ⋅ fi(Λ))dΓi, +, bc.values, dΓ)
end

function residual_Neumann(bc::NeumannBC, v, dΓ, Λ)
bc_func_ = Vector{Function}(undef, length(bc.tags))
for (i, f) in enumerate(bc.values)
Expand All @@ -155,20 +164,22 @@ function residual_Neumann(bc::NeumannBC, v, dΓ, Λ⁺, Λ⁻)
return mapreduce(f -> f(v), +, bc_func_)
end

function get_Neumann_dΓ(model, ::NothingBC, degree)
"""
get_Neumann_dΓ(...)::Vector{Gridap.CellData.GenericMeasure}

Return a collection of boundary triangulations at the specified Neumann boundaries.
"""
function get_Neumann_dΓ(model, ::NothingBC, degree::Int)
Vector{Gridap.CellData.GenericMeasure}(undef, 1)
end

function get_Neumann_dΓ(model, bc::NeumannBC, degree)
dΓ = Vector{Gridap.CellData.GenericMeasure}(undef, length(bc.tags))
for i in 1:length(bc.tags)
Γ = BoundaryTriangulation(model, tags=bc.tags[i])
dΓ[i] = Measure(Γ, degree)
end
return dΓ
function get_Neumann_dΓ(model, bc::NeumannBC, degree::Int)
all_Γ = map(tag -> BoundaryTriangulation(model, tags=tag), bc.tags)
all_dΓ = map(Γi -> Measure(Γi, degree), all_Γ)
all_dΓ
end

function get_Neumann_dΓ(model, bc::MultiFieldBC, degree::Int64)
function get_Neumann_dΓ(model, bc::MultiFieldBC, degree::Int)
dΓ = Vector{Vector{Gridap.CellData.GenericMeasure}}(undef, length(bc.BoundaryCondition))
for (i, bc_i) in enumerate(bc.BoundaryCondition)
dΓ[i] = get_Neumann_dΓ(model, bc_i, degree)
Expand Down
25 changes: 25 additions & 0 deletions src/ComputationalModels/PostProcessors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,31 @@ function Cauchy(physmodel::ThermoElectroMechano, uh, φh, θh, Ω, dΩ, Λ=1.0)
end


function Cauchy(model::ViscoElastic, uh, unh, state_vars, Ω, dΩ, t, Δt)
_, ∂Ψu, _ = model(Δt=Δt)
F, _, _ = get_Kinematics(model.Kinematic)
σ = ∂Ψu ∘ (F∘∇(uh), F∘∇(unh), state_vars...)
return interpolate_σ_everywhere(σ, Ω, dΩ)
end


function interpolate_σ_everywhere(σ, Ω, dΩ)
ref_L2 = ReferenceFE(lagrangian, Float64, 0)
ref_fe = ReferenceFE(lagrangian, Float64, 1)
VL2 = FESpace(Ω, ref_L2, conformity=:L2)
V = FESpace(Ω, ref_fe, conformity=:H1)
n1 = VectorValue(1.0, 0.0, 0.0)
n2 = VectorValue(0.0, 1.0, 0.0)
n3 = VectorValue(0.0, 0.0, 1.0)
σ11h = interpolate_everywhere(L2_Projection(n1 ⋅ σ ⋅ n1, dΩ, VL2), V)
σ12h = interpolate_everywhere(L2_Projection(n1 ⋅ σ ⋅ n2, dΩ, VL2), V)
σ13h = interpolate_everywhere(L2_Projection(n1 ⋅ σ ⋅ n3, dΩ, VL2), V)
σ22h = interpolate_everywhere(L2_Projection(n2 ⋅ σ ⋅ n2, dΩ, VL2), V)
σ23h = interpolate_everywhere(L2_Projection(n2 ⋅ σ ⋅ n3, dΩ, VL2), V)
σ33h = interpolate_everywhere(L2_Projection(n3 ⋅ σ ⋅ n3, dΩ, VL2), V)
ph = interpolate_everywhere(L2_Projection(tr ∘ σ, dΩ, VL2), V)
return (σ11h, σ12h, σ13h, σ22h, σ23h, σ33h, ph)
end


function Entropy(physmodel::ThermoElectroMechano, uh, φh, θh, Ω, dΩ, Λ=1.0)
Expand Down
31 changes: 29 additions & 2 deletions src/WeakForms/WeakForms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ end

function residual(physicalmodel::Mechano, u, v, dΩ, Λ=1.0)
DΨ= physicalmodel(Λ)
F,_,_ = get_Kinematics(physicalmodel.Kinematic; Λ=Λ)
F,_,_ = get_Kinematics(physicalmodel.Kinematic; Λ=Λ)
∂Ψu=DΨ[2]

∫(∇(v)' ⊙ (∂Ψu ∘ (F∘(∇(u)'))))dΩ
Expand All @@ -39,11 +39,38 @@ end

function jacobian(physicalmodel::Mechano, u, du, v, dΩ, Λ=1.0)
DΨ= physicalmodel(Λ)
F,_,_ = get_Kinematics(physicalmodel.Kinematic; Λ=Λ)
F,_,_ = get_Kinematics(physicalmodel.Kinematic; Λ=Λ)
∂Ψuu=DΨ[3]
∫(∇(v)' ⊙ ((∂Ψuu ∘ (F∘(∇(u)'))) ⊙ (∇(du)')))dΩ
end

"""
residual(...)::Function

Return the residual for a visco-elastic model as a FUNCTION.
"""
function residual(model::ViscoElastic, un, vars, dΩ; t, Δt)
_, ∂Ψu, _ = model(t, Δt=Δt)
F, _, _ = get_Kinematics(model.Kinematic, Λ=t)
(u, v) -> ∫(∇(v)' ⊙ (∂Ψu∘(F∘∇(u)', F∘∇(un)', vars...)))dΩ
end

"""
jacobian(...)::Function

Return the jacobian for a visco-elastic model as a FUNCTION.
"""
function jacobian(model::ViscoElastic, un, vars, dΩ; t, Δt)
_, _, ∂Ψuu = model(t, Δt=Δt)
F, _, _ = get_Kinematics(model.Kinematic, Λ=t)
(u, du, v) -> ∫(∇(v)' ⊙ (inner ∘ (∂Ψuu∘(F∘∇(u)', F∘∇(un)', vars...), ∇(du)')))dΩ
end


# ===================
# Mass term
# ===================

function mass_term(u, v, Coeff, dΩ)
∫(Coeff* (u⋅v))dΩ
end
Expand Down