2015-10-28 04:29:14 +02:00
|
|
|
# This file is a part of JuliaFEM.
|
|
|
|
|
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
|
|
|
|
|
|
2016-02-03 06:49:42 +02:00
|
|
|
""" Concrete Elasticity type. """
|
|
|
|
|
type Elasticity <: FieldProblem
|
|
|
|
|
# these are found from problem.properties for type Problem{Elasticity}
|
|
|
|
|
formulation :: Symbol
|
2016-02-13 01:10:03 +02:00
|
|
|
finite_strain :: Bool
|
2016-02-23 15:00:30 +02:00
|
|
|
use_forwarddiff :: Bool
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
|
|
|
|
function Elasticity()
|
2016-02-11 02:50:43 +02:00
|
|
|
# formulations: plane_stress, plane_strain, continuum
|
2016-02-23 15:00:30 +02:00
|
|
|
return Elasticity(:continuum, true, false)
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# in case of experimenting new things;
|
|
|
|
|
# 1. import JuliaFEM.Core: assemble!
|
|
|
|
|
# 2. copy/paste assemble! code to notebook
|
|
|
|
|
# 3. change to last argument, i.e. ::Type{Val{:plane_stress}} to ::Type{Val{:my_formulation}}
|
|
|
|
|
# 4. when running code: set problem.properties.formulation = :my_formulation
|
|
|
|
|
# 5. let multiple dispatch do the magic for you
|
|
|
|
|
|
|
|
|
|
function get_unknown_field_name(::Type{Elasticity})
|
|
|
|
|
return "displacement"
|
|
|
|
|
end
|
|
|
|
|
|
2016-02-11 02:50:43 +02:00
|
|
|
function get_formulation_type(problem::Problem{Elasticity})
|
2016-02-11 12:07:25 +02:00
|
|
|
# we are solving residual and add increment to previous solution vector
|
2016-02-11 02:50:43 +02:00
|
|
|
return :incremental
|
|
|
|
|
end
|
|
|
|
|
|
2016-02-03 06:49:42 +02:00
|
|
|
function assemble!(assembly::Assembly, problem::Problem{Elasticity}, element::Element, time::Real)
|
2016-02-11 02:50:43 +02:00
|
|
|
props = problem.properties
|
2016-02-11 16:16:15 +02:00
|
|
|
gdofs = get_gdofs(problem, element)
|
2016-02-23 15:00:30 +02:00
|
|
|
if props.use_forwarddiff
|
|
|
|
|
Kt, f = assemble(problem, element, time, Val{:forwarddiff})
|
|
|
|
|
elseif props.formulation == :continuum
|
2016-02-11 16:16:15 +02:00
|
|
|
Kt, f = assemble(problem, element, time, Val{:continuum})
|
2016-02-11 02:50:43 +02:00
|
|
|
elseif (props.formulation == :plane_stress) || (props.formulation == :plane_strain)
|
|
|
|
|
Kt, f = assemble(problem, element, time, Val{:plane})
|
2016-02-08 02:35:39 +02:00
|
|
|
end
|
2016-02-11 16:16:15 +02:00
|
|
|
add!(assembly.K, gdofs, gdofs, Kt)
|
|
|
|
|
add!(assembly.f, gdofs, f)
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
|
|
|
|
|
2016-05-22 00:22:17 +03:00
|
|
|
function assemble(problem::Problem{Elasticity}, element::Element, time=0.0)
|
2016-05-22 02:34:38 +03:00
|
|
|
problem.properties
|
|
|
|
|
if problem.properties.formulation in [:plane_stress, :plane_strain]
|
|
|
|
|
return assemble(problem, element, time, Val{:plane})
|
|
|
|
|
end
|
|
|
|
|
return assemble(problem, element, time, Val{problem.properties.formulation})
|
2016-05-22 00:22:17 +03:00
|
|
|
end
|
2016-02-11 02:50:43 +02:00
|
|
|
|
|
|
|
|
""" Elasticity equations for 2d cases. """
|
2016-05-22 02:34:38 +03:00
|
|
|
function assemble{El<:Union{Tri3,Tri6,Quad4}}(problem::Problem{Elasticity}, element::Element{El}, time, ::Type{Val{:plane}})
|
2016-02-03 06:49:42 +02:00
|
|
|
|
2016-02-08 02:35:39 +02:00
|
|
|
props = problem.properties
|
2016-02-11 02:50:43 +02:00
|
|
|
dim = get_unknown_field_dimension(problem)
|
2016-05-22 00:22:17 +03:00
|
|
|
nnodes = length(element)
|
2016-02-11 02:50:43 +02:00
|
|
|
BL = zeros(3, dim*nnodes)
|
|
|
|
|
BNL = zeros(4, dim*nnodes)
|
|
|
|
|
Kt = zeros(dim*nnodes, dim*nnodes)
|
|
|
|
|
f = zeros(dim*nnodes)
|
|
|
|
|
|
2016-05-22 00:22:17 +03:00
|
|
|
for (w, xi) in get_integration_points(element)
|
2016-02-11 02:50:43 +02:00
|
|
|
|
2016-05-22 17:00:01 +03:00
|
|
|
detJ = element(xi, time, Val{:detJ})
|
2016-05-22 00:22:17 +03:00
|
|
|
N = element(xi, time)
|
|
|
|
|
dN = element(xi, time, Val{:Grad})
|
2016-02-11 02:50:43 +02:00
|
|
|
|
|
|
|
|
# kinematics; calculate deformation gradient and strain
|
2016-02-13 01:10:03 +02:00
|
|
|
gradu = zeros(dim, dim)
|
2016-02-11 02:50:43 +02:00
|
|
|
if haskey(element, "displacement")
|
2016-05-22 00:22:17 +03:00
|
|
|
gradu += element("displacement", xi, time, Val{:Grad})
|
2016-02-13 01:10:03 +02:00
|
|
|
end
|
|
|
|
|
strain = zeros(dim , dim)
|
|
|
|
|
strain += 1/2*(gradu' + gradu)
|
|
|
|
|
F = eye(dim)
|
|
|
|
|
if props.finite_strain
|
2016-02-11 02:50:43 +02:00
|
|
|
F += gradu
|
2016-02-13 01:10:03 +02:00
|
|
|
strain += 1/2*gradu'*gradu
|
2016-02-11 02:50:43 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# constitutive equations; material model (isotropic linear material here)
|
|
|
|
|
# get_material(problem, element, ...)
|
2016-05-22 00:22:17 +03:00
|
|
|
E = element("youngs modulus", xi, time)
|
|
|
|
|
nu = element("poissons ratio", xi, time)
|
2016-05-22 02:34:38 +03:00
|
|
|
if props.formulation == :plane_stress
|
|
|
|
|
D = E/(1.0 - nu^2) .* [
|
|
|
|
|
1.0 nu 0.0
|
|
|
|
|
nu 1.0 0.0
|
|
|
|
|
0.0 0.0 (1.0-nu)/2.0]
|
|
|
|
|
elseif props.formulation == :plane_strain
|
|
|
|
|
D = E/((1+nu)*(1-2*nu)) .* [
|
|
|
|
|
1-nu nu 0
|
|
|
|
|
nu 1-nu 0
|
|
|
|
|
0 0 (1-2*nu)/2]
|
|
|
|
|
else
|
|
|
|
|
error("unknown plane formulation: $(props.formulation)")
|
|
|
|
|
end
|
2016-02-13 01:10:03 +02:00
|
|
|
|
|
|
|
|
# calculate stress
|
|
|
|
|
S = D*[strain[1,1]; strain[2,2]; 2*strain[1,2]]
|
2016-02-11 02:50:43 +02:00
|
|
|
|
|
|
|
|
# add contributions: material and geometric stiffness + internal forces
|
|
|
|
|
fill!(BL, 0.0)
|
|
|
|
|
for i=1:size(dN, 2)
|
|
|
|
|
BL[1, 2*(i-1)+1] = F[1,1]*dN[1,i]
|
|
|
|
|
BL[1, 2*(i-1)+2] = F[2,1]*dN[1,i]
|
|
|
|
|
BL[2, 2*(i-1)+1] = F[1,2]*dN[2,i]
|
|
|
|
|
BL[2, 2*(i-1)+2] = F[2,2]*dN[2,i]
|
|
|
|
|
BL[3, 2*(i-1)+1] = F[1,1]*dN[2,i] + F[1,2]*dN[1,i]
|
|
|
|
|
BL[3, 2*(i-1)+2] = F[2,1]*dN[2,i] + F[2,2]*dN[1,i]
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
2016-02-11 02:50:43 +02:00
|
|
|
fill!(BNL, 0.0)
|
|
|
|
|
for i=1:size(dN, 2)
|
|
|
|
|
BNL[1, 2*(i-1)+1] = dN[1,i]
|
|
|
|
|
BNL[2, 2*(i-1)+1] = dN[2,i]
|
|
|
|
|
BNL[3, 2*(i-1)+2] = dN[1,i]
|
|
|
|
|
BNL[4, 2*(i-1)+2] = dN[2,i]
|
|
|
|
|
end
|
|
|
|
|
S2 = zeros(2*dim, 2*dim)
|
|
|
|
|
S2[1,1] = S[1]
|
|
|
|
|
S2[2,2] = S[2]
|
|
|
|
|
S2[1,2] = S2[2,1] = S[3]
|
|
|
|
|
S2[3:4,3:4] = S2[1:2,1:2]
|
|
|
|
|
|
2016-05-22 17:00:01 +03:00
|
|
|
Kt += w*BL'*D*BL*detJ # material stiffness
|
2016-02-13 01:10:03 +02:00
|
|
|
if props.finite_strain # add geometric stiffness
|
2016-05-22 17:00:01 +03:00
|
|
|
Kt += w*BNL'*S2*BNL*detJ # geometric stiffness
|
2016-02-13 01:10:03 +02:00
|
|
|
end
|
2016-05-22 17:00:01 +03:00
|
|
|
f -= w*BL'*S*detJ # internal force
|
2016-02-11 02:50:43 +02:00
|
|
|
|
|
|
|
|
# volume load
|
2016-02-03 06:49:42 +02:00
|
|
|
if haskey(element, "displacement load")
|
2016-05-22 00:22:17 +03:00
|
|
|
b = element("displacement load", xi, time)
|
2016-05-22 17:00:01 +03:00
|
|
|
f += w*vec(N'*b)*detJ
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
2016-02-11 02:50:43 +02:00
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return Kt, f
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function assemble{El<:Union{Seg2,Seg3}}(problem::Problem{Elasticity}, element::Element{El}, time::Real, ::Type{Val{:plane}})
|
|
|
|
|
|
|
|
|
|
props = problem.properties
|
|
|
|
|
dim = get_unknown_field_dimension(problem)
|
|
|
|
|
nnodes = size(element, 2)
|
|
|
|
|
Kt = zeros(dim*nnodes, dim*nnodes)
|
|
|
|
|
f = zeros(dim*nnodes)
|
|
|
|
|
|
2016-05-22 02:34:38 +03:00
|
|
|
for (w, xi) in get_integration_points(element)
|
2016-02-11 02:50:43 +02:00
|
|
|
|
2016-05-22 17:00:01 +03:00
|
|
|
detJ = element(xi, time, Val{:detJ})
|
2016-05-22 02:34:38 +03:00
|
|
|
N = element(xi, time)
|
2016-02-11 02:50:43 +02:00
|
|
|
|
2016-02-03 06:49:42 +02:00
|
|
|
if haskey(element, "displacement traction force")
|
2016-05-22 02:34:38 +03:00
|
|
|
T = element("displacement traction force", xi, time)
|
|
|
|
|
f += w*vec(T*N)*detJ
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
2016-02-11 02:50:43 +02:00
|
|
|
|
|
|
|
|
for i=1:dim
|
|
|
|
|
# traction force for ith component
|
|
|
|
|
if haskey(element, "displacement traction force $i")
|
2016-05-22 02:34:38 +03:00
|
|
|
T = element("displacement traction force $i", xi, time)
|
|
|
|
|
f[i:dim:end] += w*vec(T*N)*detJ
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
|
|
|
|
end
|
2016-02-11 02:50:43 +02:00
|
|
|
|
|
|
|
|
if haskey(element, "nt displacement traction force")
|
|
|
|
|
# traction force given in normal-tangential direction
|
2016-05-22 02:34:38 +03:00
|
|
|
T = element("nt displacement traction force", xi, time)
|
|
|
|
|
Q = element("normal-tangential coordinates", xi, time)
|
|
|
|
|
f += w*vec(Q'*T*N)*detJ
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
2016-02-11 02:50:43 +02:00
|
|
|
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
2016-02-11 02:50:43 +02:00
|
|
|
|
|
|
|
|
return Kt, f
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""" Elasticity equations, continuum formulation. """
|
2016-02-11 16:16:15 +02:00
|
|
|
function assemble{El<:Union{Tet4, Tet10, Hex8}}(problem::Problem{Elasticity}, element::Element{El}, time::Real, ::Type{Val{:continuum}})
|
|
|
|
|
|
|
|
|
|
props = problem.properties
|
|
|
|
|
dim = get_unknown_field_dimension(problem)
|
|
|
|
|
nnodes = size(element, 2)
|
|
|
|
|
BL = zeros(6, dim*nnodes)
|
|
|
|
|
BNL = zeros(9, dim*nnodes)
|
|
|
|
|
Kt = zeros(dim*nnodes, dim*nnodes)
|
|
|
|
|
f = zeros(dim*nnodes)
|
2016-02-03 06:49:42 +02:00
|
|
|
|
2016-05-22 17:00:01 +03:00
|
|
|
for (w, xi) in get_integration_points(element)
|
|
|
|
|
detJ = element(xi, time, Val{:detJ})
|
|
|
|
|
N = element(xi, time)
|
|
|
|
|
dN = element(xi, time, Val{:Grad})
|
2016-02-11 16:16:15 +02:00
|
|
|
|
|
|
|
|
# kinematics; calculate deformation gradient and strain
|
2016-02-13 01:10:03 +02:00
|
|
|
gradu = zeros(dim, dim)
|
2016-02-11 16:16:15 +02:00
|
|
|
if haskey(element, "displacement")
|
2016-05-22 17:00:01 +03:00
|
|
|
gradu += element("displacement", xi, time, Val{:Grad})
|
2016-02-13 01:10:03 +02:00
|
|
|
end
|
|
|
|
|
strain = zeros(dim , dim)
|
|
|
|
|
strain += 1/2*(gradu' + gradu)
|
|
|
|
|
F = eye(dim)
|
|
|
|
|
if props.finite_strain
|
2016-02-11 16:16:15 +02:00
|
|
|
F += gradu
|
2016-02-13 01:10:03 +02:00
|
|
|
strain += 1/2*gradu'*gradu
|
2016-02-11 16:16:15 +02:00
|
|
|
end
|
|
|
|
|
|
2016-05-22 17:00:01 +03:00
|
|
|
E = element("youngs modulus", xi, time)
|
|
|
|
|
nu = element("poissons ratio", xi, time)
|
2016-02-11 16:16:15 +02:00
|
|
|
|
|
|
|
|
a = 1 - nu
|
|
|
|
|
b = 1 - 2*nu
|
|
|
|
|
c = 1 + nu
|
|
|
|
|
D = E/(b*c) .* [
|
|
|
|
|
a nu nu 0 0 0
|
|
|
|
|
nu a nu 0 0 0
|
|
|
|
|
nu nu a 0 0 0
|
|
|
|
|
0 0 0 b 0 0
|
|
|
|
|
0 0 0 0 b 0
|
|
|
|
|
0 0 0 0 0 b]
|
|
|
|
|
|
|
|
|
|
# # PK2 stress tensor in voigt notation
|
2016-02-13 01:10:03 +02:00
|
|
|
S = D*[strain[1,1]; strain[2,2]; strain[3,3]; 2*strain[2,3]; 2*strain[1,3]; 2*strain[1,2]]
|
2016-02-11 16:16:15 +02:00
|
|
|
|
|
|
|
|
# add contributions: material and geometric stiffness + internal forces
|
|
|
|
|
fill!(BL, 0.0)
|
|
|
|
|
for i=1:size(dN, 2)
|
|
|
|
|
BL[1, 3*(i-1)+1] = F[1,1]*dN[1,i]
|
|
|
|
|
BL[1, 3*(i-1)+2] = F[2,1]*dN[1,i]
|
|
|
|
|
BL[1, 3*(i-1)+3] = F[3,1]*dN[1,i]
|
|
|
|
|
BL[2, 3*(i-1)+1] = F[1,2]*dN[2,i]
|
|
|
|
|
BL[2, 3*(i-1)+2] = F[2,2]*dN[2,i]
|
|
|
|
|
BL[2, 3*(i-1)+3] = F[3,2]*dN[2,i]
|
|
|
|
|
BL[3, 3*(i-1)+1] = F[1,3]*dN[3,i]
|
|
|
|
|
BL[3, 3*(i-1)+2] = F[2,3]*dN[3,i]
|
|
|
|
|
BL[3, 3*(i-1)+3] = F[3,3]*dN[3,i]
|
|
|
|
|
BL[4, 3*(i-1)+1] = F[1,1]*dN[2,i] + F[1,2]*dN[1,i]
|
|
|
|
|
BL[4, 3*(i-1)+2] = F[2,1]*dN[2,i] + F[2,2]*dN[1,i]
|
|
|
|
|
BL[4, 3*(i-1)+3] = F[3,1]*dN[2,i] + F[3,2]*dN[1,i]
|
|
|
|
|
BL[5, 3*(i-1)+1] = F[1,2]*dN[3,i] + F[1,3]*dN[2,i]
|
|
|
|
|
BL[5, 3*(i-1)+2] = F[2,2]*dN[3,i] + F[2,3]*dN[2,i]
|
|
|
|
|
BL[5, 3*(i-1)+3] = F[3,2]*dN[3,i] + F[3,3]*dN[2,i]
|
|
|
|
|
BL[6, 3*(i-1)+1] = F[1,3]*dN[1,i] + F[1,1]*dN[3,i]
|
|
|
|
|
BL[6, 3*(i-1)+2] = F[2,3]*dN[1,i] + F[2,1]*dN[3,i]
|
|
|
|
|
BL[6, 3*(i-1)+3] = F[3,3]*dN[1,i] + F[3,1]*dN[3,i]
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
2016-02-11 16:16:15 +02:00
|
|
|
fill!(BNL, 0.0)
|
|
|
|
|
for i=1:size(dN, 2)
|
|
|
|
|
BNL[1, 3*(i-1)+1] = dN[1,i]
|
|
|
|
|
BNL[2, 3*(i-1)+1] = dN[2,i]
|
|
|
|
|
BNL[3, 3*(i-1)+1] = dN[3,i]
|
|
|
|
|
BNL[4, 3*(i-1)+2] = dN[1,i]
|
|
|
|
|
BNL[5, 3*(i-1)+2] = dN[2,i]
|
|
|
|
|
BNL[6, 3*(i-1)+2] = dN[3,i]
|
|
|
|
|
BNL[7, 3*(i-1)+3] = dN[1,i]
|
|
|
|
|
BNL[8, 3*(i-1)+3] = dN[2,i]
|
|
|
|
|
BNL[9, 3*(i-1)+3] = dN[3,i]
|
|
|
|
|
end
|
|
|
|
|
S3 = zeros(3*dim, 3*dim)
|
|
|
|
|
S3[1,1] = S[1]
|
|
|
|
|
S3[2,2] = S[2]
|
|
|
|
|
S3[3,3] = S[3]
|
|
|
|
|
S3[2,3] = S3[3,2] = S[4]
|
|
|
|
|
S3[1,3] = S3[3,1] = S[5]
|
|
|
|
|
S3[1,2] = S3[2,1] = S[6]
|
|
|
|
|
S3[4:6,4:6] = S3[7:9,7:9] = S3[1:3,1:3]
|
|
|
|
|
|
2016-05-22 17:00:01 +03:00
|
|
|
Kt += w*BL'*D*BL*detJ
|
2016-02-13 01:10:03 +02:00
|
|
|
if props.finite_strain
|
2016-05-22 17:00:01 +03:00
|
|
|
Kt += w*BNL'*S3*BNL*detJ
|
2016-02-13 01:10:03 +02:00
|
|
|
end
|
2016-05-22 17:00:01 +03:00
|
|
|
f -= w*BL'*S*detJ
|
2016-02-11 16:16:15 +02:00
|
|
|
|
|
|
|
|
# volume load
|
2016-02-03 06:49:42 +02:00
|
|
|
if haskey(element, "displacement load")
|
2016-02-11 16:16:15 +02:00
|
|
|
T = element("displacement load", ip, time)
|
2016-05-22 17:00:01 +03:00
|
|
|
f += w*vec(T*N)*detJ
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
2016-02-11 16:16:15 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return Kt, f
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
""" Elasticity equations, surface traction for continuum formulation. """
|
|
|
|
|
function assemble{El<:Union{Tri3, Tri6, Quad4}}(problem::Problem{Elasticity}, element::Element{El}, time::Real, ::Type{Val{:continuum}})
|
|
|
|
|
|
|
|
|
|
props = problem.properties
|
|
|
|
|
dim = get_unknown_field_dimension(problem)
|
|
|
|
|
nnodes = size(element, 2)
|
|
|
|
|
Kt = zeros(dim*nnodes, dim*nnodes)
|
|
|
|
|
f = zeros(dim*nnodes)
|
|
|
|
|
|
2016-05-22 17:00:01 +03:00
|
|
|
for (w, xi) in get_integration_points(element)
|
|
|
|
|
detJ = element(xi, time, Val{:detJ})
|
|
|
|
|
N = element(xi, time)
|
2016-02-03 06:49:42 +02:00
|
|
|
if haskey(element, "displacement traction force")
|
2016-05-22 17:00:01 +03:00
|
|
|
T = element("displacement traction force", xi, time)
|
|
|
|
|
f += w*vec(T*N)*detJ
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
2016-02-11 16:16:15 +02:00
|
|
|
for i in 1:dim
|
|
|
|
|
if haskey(element, "displacement traction force $i")
|
2016-05-22 17:00:01 +03:00
|
|
|
T = element("displacement traction force $i", xi, time)
|
|
|
|
|
f[i:dim:end] += w*vec(T*N)*detJ
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2016-02-11 16:16:15 +02:00
|
|
|
return Kt, f
|
2016-02-03 06:49:42 +02:00
|
|
|
end
|
|
|
|
|
|
2016-02-23 15:00:30 +02:00
|
|
|
""" Elasticity equations using ForwardDiff
|
|
|
|
|
|
|
|
|
|
Formulation
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
Field equation is:
|
|
|
|
|
∂u/∂t = ∇⋅f - b
|
|
|
|
|
|
|
|
|
|
Weak form is: find u∈U such that ∀v in V
|
|
|
|
|
|
|
|
|
|
δW := ∫ρ₀∂²u/∂t²⋅δu dV₀ + ∫S:δE dV₀ - ∫b₀⋅δu dV₀ - ∫t₀⋅δu dA₀ = 0
|
|
|
|
|
|
|
|
|
|
where
|
|
|
|
|
|
|
|
|
|
ρ₀ = density
|
|
|
|
|
b₀ = displacement load
|
|
|
|
|
t₀ = displacement traction
|
|
|
|
|
|
|
|
|
|
References
|
|
|
|
|
----------
|
|
|
|
|
|
|
|
|
|
https://en.wikipedia.org/wiki/Linear_elasticity
|
|
|
|
|
https://en.wikipedia.org/wiki/Finite_strain_theory
|
|
|
|
|
https://en.wikipedia.org/wiki/Stress_measures
|
|
|
|
|
https://en.wikipedia.org/wiki/Mooney%E2%80%93Rivlin_solid
|
|
|
|
|
https://en.wikipedia.org/wiki/Strain_energy_density_function
|
|
|
|
|
https://en.wikipedia.org/wiki/Plane_stress
|
|
|
|
|
https://en.wikipedia.org/wiki/Hooke's_law
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
function assemble(problem::Problem{Elasticity}, element::Element, time::Real, ::Type{Val{:forwarddiff}})
|
|
|
|
|
|
|
|
|
|
dim = get_unknown_field_dimension(problem)
|
|
|
|
|
nnodes = size(element, 2)
|
|
|
|
|
|
|
|
|
|
function get_residual_vector(u::Vector)
|
|
|
|
|
u = reshape(u, dim, nnodes)
|
|
|
|
|
u = Field([u[:,i] for i=1:nnodes])
|
|
|
|
|
r = zeros(dim, nnodes)
|
|
|
|
|
|
|
|
|
|
for ip in get_integration_points(element)
|
|
|
|
|
|
|
|
|
|
JT = transpose(get_jacobian(element, ip, time))
|
|
|
|
|
n, m = size(JT)
|
|
|
|
|
if n == m
|
|
|
|
|
w = ip.weight*det(JT)
|
|
|
|
|
elseif m == 1
|
|
|
|
|
w = ip.weight*norm(JT)
|
|
|
|
|
elseif m == 2
|
|
|
|
|
w = ip.weight*norm(cross(JT[:,1], JT[:,2]))
|
|
|
|
|
else
|
|
|
|
|
error("jacobian $JT")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# calculate internal forces
|
|
|
|
|
if haskey(element, "youngs modulus") && haskey(element, "poissons ratio")
|
|
|
|
|
grad = element(ip, time, Val{:grad})
|
|
|
|
|
gradu = grad*u
|
|
|
|
|
|
|
|
|
|
# kinematics
|
|
|
|
|
F = I + gradu
|
|
|
|
|
E = 1/2*(F'*F - I)
|
|
|
|
|
|
|
|
|
|
# material
|
|
|
|
|
young = element("youngs modulus", ip, time)
|
|
|
|
|
poisson = element("poissons ratio", ip, time)
|
|
|
|
|
mu = young/(2*(1+poisson))
|
|
|
|
|
lambda = young*poisson/((1+poisson)*(1-2*poisson))
|
|
|
|
|
if problem.properties.formulation == :plane_stress
|
|
|
|
|
lambda = 2*lambda*mu/(lambda + 2*mu) # <- correction for plane stress
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# stress
|
|
|
|
|
S = lambda*trace(E)*I + 2*mu*E
|
|
|
|
|
|
|
|
|
|
r += w*F*S*grad
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# calculate external forces - volume load
|
|
|
|
|
if haskey(element, "displacement load")
|
|
|
|
|
basis = element(ip, time)
|
|
|
|
|
b = element("displacement load", ip, time)
|
|
|
|
|
r -= w*b*basis
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# external forces - surface traction force
|
|
|
|
|
if haskey(element, "displacement traction force")
|
|
|
|
|
basis = element(ip, time)
|
|
|
|
|
T = element("displacement traction force", ip, time)
|
|
|
|
|
r -= w*T*basis
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return vec(r)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
field = element("displacement", time)
|
|
|
|
|
Kt, allresults = ForwardDiff.jacobian(get_residual_vector, vec(field),
|
|
|
|
|
AllResults, cache=autodiffcache)
|
|
|
|
|
f = -ForwardDiff.value(allresults)
|
|
|
|
|
return Kt, f
|
|
|
|
|
end
|
|
|
|
|
|
2016-02-03 06:49:42 +02:00
|
|
|
|
|
|
|
|
###############################
|
|
|
|
|
# Plastic material #
|
|
|
|
|
###############################
|
|
|
|
|
#=
|
|
|
|
|
include("vonmises.jl")
|
|
|
|
|
abstract PlaneStressLinearElasticPlasticProblem <: LinearElasticityProblem
|
|
|
|
|
|
|
|
|
|
function PlaneStressLinearElasticPlasticProblem(name="plane stress linear elasticity", dim::Int=2, elements=[])
|
|
|
|
|
return Problem{PlaneStressLinearElasticPlasticProblem}(name, dim, elements)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
""" Elasticity equations, plane stress. """
|
|
|
|
|
function assemble!{E<:CG, P<:PlaneStressLinearElasticPlasticProblem}(assembly::Assembly, problem::Problem{P}, element::Element{E}, time::Real)
|
|
|
|
|
|
|
|
|
|
gdofs = get_gdofs(element, problem.dim)
|
|
|
|
|
ndim, nnodes = size(E)
|
|
|
|
|
B = zeros(3, 2*nnodes)
|
|
|
|
|
for ip in get_integration_points(element)
|
|
|
|
|
w = ip.weight
|
|
|
|
|
J = get_jacobian(element, ip, time)
|
|
|
|
|
N = element(ip, time)
|
|
|
|
|
if haskey(element, "youngs modulus") && haskey(element, "poissons ratio")
|
|
|
|
|
nu = element("poissons ratio", ip, time)
|
|
|
|
|
E_ = element("youngs modulus", ip, time)
|
|
|
|
|
C = E_/(1.0 - nu^2) .* [
|
|
|
|
|
1.0 nu 0.0
|
|
|
|
|
nu 1.0 0.0
|
|
|
|
|
0.0 0.0 (1.0-nu)/2.0]
|
|
|
|
|
dN = element(ip, time, Val{:grad})
|
|
|
|
|
fill!(B, 0.0)
|
|
|
|
|
for i=1:size(dN, 2)
|
|
|
|
|
B[1, 2*(i-1)+1] = dN[1,i]
|
|
|
|
|
B[2, 2*(i-1)+2] = dN[2,i]
|
|
|
|
|
B[3, 2*(i-1)+1] = dN[2,i]
|
|
|
|
|
B[3, 2*(i-1)+2] = dN[1,i]
|
|
|
|
|
end
|
|
|
|
|
add!(assembly.stiffness_matrix, gdofs, gdofs, w*B'*C*B*det(J))
|
|
|
|
|
end
|
|
|
|
|
if haskey(element, "displacement load")
|
|
|
|
|
b = element("displacement load", ip, time)
|
|
|
|
|
add!(assembly.force_vector, gdofs, w*N'*b*det(J))
|
|
|
|
|
end
|
|
|
|
|
if haskey(element, "displacement traction force")
|
|
|
|
|
T = element("displacement traction force", ip, time)
|
|
|
|
|
L = w*T*N*norm(J)
|
|
|
|
|
add!(assembly.force_vector, gdofs, vec(L))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-12-17 17:13:23 +02:00
|
|
|
include("elasticplastic.jl")
|
2015-12-12 15:22:31 +02:00
|
|
|
|
2015-10-28 04:29:14 +02:00
|
|
|
# Elasticity problems
|
2015-12-17 17:13:23 +02:00
|
|
|
abstract ElasticityProblem <: AbstractProblem
|
|
|
|
|
abstract PlaneStressElasticityProblem <: ElasticityProblem
|
2015-10-28 04:29:14 +02:00
|
|
|
|
2015-11-27 10:10:00 +02:00
|
|
|
function get_unknown_field_name{P<:ElasticityProblem}(::Type{P})
|
|
|
|
|
return "displacement"
|
|
|
|
|
end
|
2015-10-28 04:29:14 +02:00
|
|
|
|
2015-11-27 10:10:00 +02:00
|
|
|
function get_unknown_field_type{P<:ElasticityProblem}(::Type{P})
|
|
|
|
|
return Vector{Float64}
|
2015-10-28 04:29:14 +02:00
|
|
|
end
|
|
|
|
|
|
2015-12-17 15:47:36 +02:00
|
|
|
|
2016-02-03 06:49:42 +02:00
|
|
|
|
|
|
|
|
=#
|