mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-09-26 20:01:32 +00:00
added parameters to ip & element fields
This commit is contained in:
+44
-13
@@ -71,22 +71,34 @@ typealias Elasticity2DVolumeElements Union{Tri3, Tri6, Quad4, Quad8, Quad9}
|
||||
typealias Elasticity3DSurfaceElements Union{Poi1, Tri3, Tri6, Quad4, Quad8, Quad9}
|
||||
typealias Elasticity3DVolumeElements Union{Tet4, Wedge6, Hex8, Tet10, Hex20, Hex27}
|
||||
|
||||
function get_internal_params(params, ip_id, ::Type{Val{:type_2d}})
|
||||
if !(ip_id in keys(params))
|
||||
params[ip_id] = Dict{Any, Any}()
|
||||
params[ip_id]["last_stress"] = [0.0,0.0,0.0]
|
||||
params[ip_id]["last_strain"] = [0.0,0.0,0.0]
|
||||
function initialize_internal_params!(params, ip, ::Type{Val{:type_2d}})
|
||||
param_keys = keys(params)
|
||||
all_keys = ip.fields.keys
|
||||
ip_fields = filter(x->isdefined(all_keys, x), collect(1:length(all_keys)))
|
||||
|
||||
if !("params_initialized" in ip_fields)
|
||||
for key in param_keys
|
||||
update!(ip, key, 0.0 => params[key])
|
||||
end
|
||||
update!(ip, "stress", 0.0 => [0.0,0.0,0.0])
|
||||
update!(ip, "strain", 0.0 => [0.0,0.0,0.0])
|
||||
update!(ip, "prev_time", 0.0 => 0.0)
|
||||
update!(ip, "params_initialized", 0.0 => true)
|
||||
end
|
||||
return (params[ip_id]["last_stress"], params[ip_id]["last_strain"])
|
||||
end
|
||||
|
||||
function get_internal_params(params, ip_id, ::Type{Val{:type_3d}})
|
||||
function get_keys(element)
|
||||
all_keys = element.fields.keys
|
||||
idx = filter(x->isdefined(all_keys, x), collect(1:length(all_keys)))
|
||||
map(x -> all_keys[x], idx)
|
||||
end
|
||||
|
||||
function initialize_internal_params!(params, ip_id, ::Type{Val{:type_3d}})
|
||||
if !(ip_id in keys(params))
|
||||
params[ip_id] = Dict{Any, Any}()
|
||||
params[ip_id]["last_stress"] = [0.0,0.0,0.0,0.0,0.0,0.0]
|
||||
params[ip_id]["last_strain"] = [0.0,0.0,0.0,0.0,0.0,0.0]
|
||||
end
|
||||
return (params[ip_id]["last_stress"], params[ip_id]["last_strain"])
|
||||
end
|
||||
|
||||
""" Elasticity equations for 2d cases. """
|
||||
@@ -153,16 +165,34 @@ function assemble{El<:Elasticity2DVolumeElements}(problem::Problem{Elasticity},
|
||||
else
|
||||
error("unknown plane formulation: $(props.formulation)")
|
||||
end
|
||||
|
||||
# calculate stress
|
||||
if "plasticity" in keys(element.dev)
|
||||
plastic_def = element.dev["plasticity"]
|
||||
calculate_stress! = plastic_def["stress"]
|
||||
element_keys = get_keys(element)
|
||||
|
||||
if "plasticity" in element_keys
|
||||
plastic_def = element("plasticity")[ip.id]
|
||||
|
||||
calculate_stress! = plastic_def["type"]
|
||||
yield_surface_ = plastic_def["yield_surface"]
|
||||
params = plastic_def["params"]
|
||||
(stress_last, strain_last) = get_internal_params(element.dev, ip.id, Val{:type_2d})
|
||||
|
||||
initialize_internal_params!(params, ip, Val{:type_2d})
|
||||
|
||||
if time == 0.0
|
||||
error("Given step time = $(time). Please select time > 0.0")
|
||||
end
|
||||
|
||||
t_last = ip("prev_time", time)
|
||||
update!(ip, "prev_time", time => t_last)
|
||||
|
||||
dt = time - t_last
|
||||
|
||||
stress_last = ip("stress", t_last)
|
||||
strain_last = ip("strain", t_last)
|
||||
|
||||
dstrain_vec = strain_vec - strain_last
|
||||
stress_vec = [0.0, 0.0, 0.0]
|
||||
calculate_stress!(stress_vec, stress_last, dstrain_vec, D, params, Dtan, yield_surface_, Val{:type_2d})
|
||||
calculate_stress!(stress_vec, stress_last, dstrain_vec, D, params, Dtan, yield_surface_, time, dt, Val{:type_2d})
|
||||
else
|
||||
stress_vec = D * ([1.0, 1.0, 2.0] .* strain_vec)
|
||||
Dtan[:,:] = D[:,:]
|
||||
@@ -176,6 +206,7 @@ function assemble{El<:Elasticity2DVolumeElements}(problem::Problem{Elasticity},
|
||||
|
||||
Km += w*BL'*Dtan*BL
|
||||
|
||||
|
||||
# stress = [stress_vec[1] stress_vec[3]; stress_vec[3] stress_vec[2]]
|
||||
# cauchy_stress = F'*stress*F/det(F)
|
||||
# cauchy_stress = [cauchy_stress[1,1]; cauchy_stress[2,2]; cauchy_stress[1,2]]
|
||||
|
||||
Reference in New Issue
Block a user