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
1 change: 1 addition & 0 deletions src/ComputationalModels/ComputationalModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export get_test_space
include("PostProcessors.jl")
export PostProcessor
export Cauchy
export Jacobian
export Entropy
export D0
export reset!
Expand Down
42 changes: 42 additions & 0 deletions src/ComputationalModels/PostMetrics.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module PostMetrics

using Gridap
using HyperFEM.PhysicalModels

"""
component_LInf(::FEFunction, ::Symbol, ::Triangulation)::Float64

Calculate the L-inf norm of a vector-valued finite element function.
It could be useful to find the maximum displacement.

# Example
x_max = component_LInf(uh, :x, Ω)
"""
function component_LInf(u, dir, Ω)
if dir === :x
n = VectorValue(1.0, 0.0, 0.0)
elseif dir === :y
n = VectorValue(0.0, 1.0, 0.0)
elseif dir === :z
n = VectorValue(0.0, 0.0, 1.0)
else
throw("Direction must be either :x, :y or :z. Got $dir")
end
reffe = ReferenceFE(lagrangian, Float64, 1)
V = FESpace(Ω, reffe, conformity=:L2)
un = interpolate_everywhere(u⋅n, V)
uall = [un.free_values; un.dirichlet_values]
norm(uall, Inf)
end


"""
Calculate the variation of the volume with respect to the undeformed configuration.
"""
function volume_diff(uh, dΩ)
F, _, J = Kinematics(Mechano).metrics
sum(∫(J ∘ F ∘ ∇(uh) -1.0)dΩ) / sum(∫(1.0)dΩ)
end


end
22 changes: 10 additions & 12 deletions src/ComputationalModels/PostProcessors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ abstract type AbstractPostProcessor end
get_pvd(::AbstractPostProcessor) = @abstractmethod
vtk_save(::AbstractPostProcessor) = @abstractmethod


include("PostMetrics.jl")


mutable struct PostProcessor{A,B,C} <:AbstractPostProcessor
Expand Down Expand Up @@ -71,6 +71,10 @@ function (obj::PostProcessor{<:DynamicNonlinearModel,<:Any,<:Any})(Λ)
obj.cache[1](obj, obj.cache[2]...)
end

function Jacobian(uh)
F, _, J = Kinematics(Mechano).metrics
J ∘ F ∘ ∇(uh)
end

function Cauchy(physmodel::ThermoElectroMechano, uh, φh, θh, Ω, dΩ, Λ=1.0)
DΨ = physmodel(Λ)
Expand Down Expand Up @@ -168,15 +172,9 @@ function D0(physmodel::ThermoElectroMechano, uh, φh, θh, Ω, dΩ, Λ=1.0)
end







function L2_Projection(Field, dΩ, VFE)
a(Fieldh, v) = ∫(Fieldh * v) * dΩ
l(v) = ∫(v * Field) * dΩ
op = AffineFEOperator(a, l, VFE, VFE)
return solve(op)
function L2_Projection(u, dΩ, V)
a(w, v) = ∫(w * v) * dΩ
l(v) = ∫(v * u) * dΩ
op = AffineFEOperator(a, l, V, V)
solve(op)
end

1 change: 1 addition & 0 deletions src/Exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ end
@publish ComputationalModels PostProcessor
@publish ComputationalModels StaggeredModel
@publish ComputationalModels Cauchy
@publish ComputationalModels Jacobian
@publish ComputationalModels Entropy
@publish ComputationalModels D0
@publish ComputationalModels reset!
Expand Down
Loading