fixed problems with surface loads. det(element, ip, time) should be avoided.

This commit is contained in:
Jukka Aho
2015-12-13 13:47:45 +02:00
parent 3242241cd4
commit ccf32d5b76
10 changed files with 102 additions and 63 deletions
+6 -6
View File
@@ -92,7 +92,7 @@ function test_continuum_elasticity_with_surface_load()
set_geometry!(element1, nodes)
# element1["youngs modulus"] = 900.0
# element1["poissons ratio"] = 0.25
element1["youngs modulus"] = 9000.0
element1["youngs modulus"] = 900.0
element1["poissons ratio"] = 0.25
element1["displacement"] = (0.0 => Vector{Float64}[[0.0, 0.0, 0.0] for i=1:8])
@@ -105,7 +105,6 @@ function test_continuum_elasticity_with_surface_load()
push!(problem, element1)
push!(problem, element2)
#=
free_dofs = zeros(Bool, 8, 3)
x = 1
y = 2
@@ -126,8 +125,8 @@ function test_continuum_elasticity_with_surface_load()
info("initial stiffness matrix")
dump(round(Int, full(ass.stiffness_matrix))[free_dofs, free_dofs])
solve!(problem, free_dofs, 0.0; max_iterations=10)
=#
#=
dx = Quad4([1, 4, 8, 5])
dx["displacement 1"] = 0.0
dy = Quad4([1, 5, 6, 2])
@@ -145,17 +144,18 @@ function test_continuum_elasticity_with_surface_load()
solver.dump_matrices = true
solver.name = "3d_hex8"
solver(0.0)
=#
disp = element1("displacement", [1.0, 1.0, 1.0], 0.0)
info("displacement at tip: $disp")
info("displacement on element: ")
for (i, d) in enumerate(element1("displacement", 0.0))
@printf "%d %f %f %f\n" [i;d]...
@printf "%d % f % f % f\n" [i;d]...
end
# verified using Code Aster.
# 2015-12-12-continuum-elasticity/vim c3d_grot_gdep_traction_force.comm
# @test isapprox(disp, [3.17431158889468E-02, 3.17431158889468E-02, -1.38591518927826E-01])
@test isapprox(disp, [2.80559539222183E-03, 2.80559539222183E-03, -1.13019918093242E-02])
@test isapprox(disp, [3.17431158889468E-02, 3.17431158889468E-02, -1.38591518927826E-01])
#@test isapprox(disp, [2.80559539222183E-03, 2.80559539222183E-03, -1.13019918093242E-02])
end
#test_continuum_elasticity_with_surface_load()
+12 -1
View File
@@ -6,7 +6,7 @@ module ElementTests
using JuliaFEM.Test
using JuliaFEM.Core: AbstractElement, Element, Field, FieldSet, test_element
using JuliaFEM.Core: Tri3
using JuliaFEM.Core: Tri3, Quad4
import JuliaFEM.Core: get_basis, get_dbasis, calculate_normal_tangential_coordinates!
import Base: size
@@ -91,4 +91,15 @@ function test_calculate_normal_tangential_coordinates()
end
#test_calculate_normal_tangential_coordinates()
function test_manifold_determinant()
el = Quad4([1, 2, 3, 4])
#el["geometry"] = Vector{Float64}[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]
el["geometry"] = Vector{Float64}[[0.0, 0.0, 1.0], [1.0, 0.0, 1.0], [1.0, 1.0, 1.0], [0.0, 1.0, 1.0]]
# mother element area = 2*2 = 4, this element is 1, determinant should be 1/4 everywhere
d = det(el, [0.1, 0.2], 0.0)
d_expected = 0.25
@test d == d_expected
end
#test_manifold_determinant()
end
+9 -9
View File
@@ -36,13 +36,13 @@ function test_plane_stress_linear_elasticity_with_surface_load()
free_dofs = Int64[3, 5, 6, 8]
info("initial force vector")
ass = assemble(problem, 0.0)
f = full(ass.force_vector)
K = full(ass.stiffness_matrix)
dump(reshape(f, 2, 4))
info("initial stiffness matrix")
dump(round(Int, K)[free_dofs, free_dofs])
# info("initial force vector")
# dump(reshape(f, 2, 4))
# info("initial stiffness matrix")
# dump(round(Int, K)[free_dofs, free_dofs])
u = zeros(2, 4)
u[free_dofs] = K[free_dofs, free_dofs] \ f[free_dofs]
@@ -75,7 +75,7 @@ function test_continuum_elasticity_with_surface_load()
end
element1 = Hex8([1, 2, 3, 4, 5, 6, 7, 8])
set_geometry!(element1, nodes)
element1["youngs modulus"] = 9000.0
element1["youngs modulus"] = 900.0
element1["poissons ratio"] = 0.25
element2 = Quad4([5, 6, 7, 8])
@@ -100,13 +100,13 @@ function test_continuum_elasticity_with_surface_load()
free_dofs = find(vec(free_dofs'))
info("free dofs: $free_dofs")
info("initial force vector")
ass = assemble(problem, 0.0)
f = full(ass.force_vector)
K = full(ass.stiffness_matrix)
dump(reshape(f, 3, 8))
info("initial stiffness matrix")
dump(round(Int, K)[free_dofs, free_dofs])
# info("initial force vector")
# dump(reshape(f, 3, 8))
# info("initial stiffness matrix")
# dump(round(Int, K)[free_dofs, free_dofs])
u = zeros(3, 8)
u[free_dofs] = K[free_dofs, free_dofs] \ f[free_dofs]
+6 -3
View File
@@ -7,7 +7,7 @@ using JuliaFEM.Test
using JuliaFEM.Core: AbstractProblem, Problem
using JuliaFEM.Core: Element, Seg2, Quad4
using JuliaFEM.Core: IntegrationPoint, solve!
using JuliaFEM.Core: IntegrationPoint, solve!, get_jacobian
import JuliaFEM.Core: get_unknown_field_name, get_unknown_field_type, get_potential_energy
@@ -34,7 +34,9 @@ function get_potential_energy(problem::Problem{HeatProblem}, element::Element{Qu
gradT = element("temperature", ip, time, Val{:grad}, variation)
Wint = (k + c*T) * 1/2*vecdot(gradT, gradT)
Wext = f*T
return Wint - Wext
W = Wint - Wext
J = get_jacobian(element, ip, time)
return W*det(J)
end
function get_potential_energy(problem::Problem{HeatProblem}, element::Element{Seg2}, ip::IntegrationPoint, time::Number; variation=nothing)
@@ -45,7 +47,8 @@ function get_potential_energy(problem::Problem{HeatProblem}, element::Element{Se
Wint = 0.0
Wext = q0*T
W = Wint - Wext
return W
J = get_jacobian(element, ip, time)
return W*norm(J)
end
function test_potential_energy_method()
+3 -2
View File
@@ -51,7 +51,7 @@ function test_linearsolver()
info("Temperature at point X = $X is T = $T")
@test isapprox(T, 100.0)
end
#test_basic()
#test_linearsolver()
function test_solvers()
K = [
@@ -88,7 +88,8 @@ function test_solvers()
@test isapprox(u1, expected)
u2, la2 = solve(K, f, C, g, Val{:CHOLMOD})
@test isapprox(u2, expected)
include(Pkg.dir("JuliaFEM"*"/src/petsc.jl"))
# FIXME: how to dynamically include packages only if they are installed?
#include(Pkg.dir("JuliaFEM"*"/src/petsc.jl"))
u3, la3 = solve(K, f, C, g, Val{:PETSc_GMRES})
@test isapprox(u3, expected)
end