mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-09-22 02:40:51 +00:00
convenience function for interpolating field variables
This commit is contained in:
@@ -10,6 +10,56 @@ VERSION < v"0.4-" && using Docile
|
||||
# directly if needed or using general interface combining data model and
|
||||
# solver.
|
||||
|
||||
|
||||
@doc """
|
||||
Interpolate field variable using basis functions f for point ip.
|
||||
This function tries to be as general as possible and allows interpolating
|
||||
lot of different fields.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
field :: Array{Number, dim}
|
||||
Field variable
|
||||
basis :: Function
|
||||
Basis functions
|
||||
ip :: Array{Number, 1}
|
||||
Point to interpolate
|
||||
""" ->
|
||||
function interpolate(field::Array{Float64,1}, basis::Function, ip)
|
||||
result = dot(field, basis(ip))
|
||||
return result
|
||||
end
|
||||
function interpolate(field::Array{Float64,2}, basis::Function, ip)
|
||||
m, n = size(field)
|
||||
bip = basis(ip)
|
||||
tmp = size(bip)
|
||||
if length(tmp) == 1
|
||||
ndim = 1
|
||||
nnodes = tmp[1]
|
||||
else
|
||||
ndim, nnodes = size(bip)
|
||||
end
|
||||
if ndim == 1
|
||||
if n == nnodes
|
||||
result = field * bip
|
||||
elseif m == nnodes
|
||||
result = field' * bip
|
||||
end
|
||||
else
|
||||
if n == nnodes
|
||||
result = bip' * field
|
||||
elseif m == nnodes
|
||||
result = bip' * field'
|
||||
end
|
||||
end
|
||||
if length(result) == 1
|
||||
result = result[1]
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
|
||||
@doc """
|
||||
Calculate local tangent stiffness matrix and residual force vector R = T - F
|
||||
""" ->
|
||||
@@ -25,9 +75,13 @@ function calc_local_matrices!(X, u, R, Kt, N, dNdξ, λ_, μ_, ipoints, iweights
|
||||
w = iweights[m]
|
||||
ξ = ipoints[m, :]
|
||||
# interpolate material parameters from element node fields
|
||||
λ = (λ_*N(ξ))[1]
|
||||
μ = (μ_*N(ξ))[1]
|
||||
Jᵀ = X*dNdξ(ξ)
|
||||
#λ = (λ_*N(ξ))[1]
|
||||
#μ = (μ_*N(ξ))[1]
|
||||
# Jᵀ = X*dNdξ(ξ)
|
||||
#@debug("Jt:\n",Jᵀ)
|
||||
λ = interpolate(λ_, N, ξ)
|
||||
μ = interpolate(μ_, N, ξ)
|
||||
Jᵀ = interpolate(X, dNdξ, ξ)'
|
||||
detJ = det(Jᵀ)
|
||||
∇N = inv(Jᵀ)*dNdξ(ξ)'
|
||||
∇u = u*∇N'
|
||||
@@ -283,8 +337,7 @@ function solve_elasticity_increment!(X, u, du, elmap, nodalloads,
|
||||
# solution
|
||||
free_dofs = find(isnan(dirichletbc))
|
||||
#du[free_dofs] = Kt[free_dofs, free_dofs] \ -reshape(R, 8)[free_dofs]
|
||||
# TODO: cholesky decomposition
|
||||
du[free_dofs] = full(A) \ -full(b)
|
||||
du[free_dofs] = lufact(A) \ -full(b)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user