Files
JuliaFEM.jl/test/test_lagrange.jl
T
Jukka Aho c307c1482c Testing/code coverage (#83)
Change the code coverage to green. 

* removed duplicate code

* Removed unused code

* removed unmaintained code

* DCTI + DVTI refactored

* discrete fields refactored and tested

* fields are now tested quite well.

* Removed obsolete code not used anywhere

* Element descriptions to common dictionary

* size in global const dictionary also

* Added coverage to sparse tools and removed couple unused functions

* get nonzero rows from SparseMatrixCSC

* bugfix: extending element basis now working and tested

* Removed two unused functions from elements.jl

* removed useless function

* Useless conversion

* remove elasticity assembly using ForwardDiff because it's not used anywhere'

* Added basic testing for NURBS. Fixed bug in NSolid interpolation.

* removed unused functions

* Removed some debug stuff

* renamed file

* removed field assembly posthook, i think not good idea at all

* test for nnz(K) == 0 and automatic determination of dofs

* Testing that solver is throwing error if having problems with boundary assembly

* Removed some unused options. Refactoring.

* Moved solver non-related code to elements.jl

* Removed custom exception (no need)

* unneeded postprocess code

* More tests for NURBS elements.

* Removed unfinished .mail parser

* proper use of Logging package

* also read results

* renamed test file

* create_surface_elements accepts surface name in String now

* bugfix: remove zero rows from constraint matrix after manually removing dofs from some boundary assemblies.

* New test, displacement 3d patch test

* skip displacement field in surface element splitting if not defined

* test element splitting and linear surface elements, fails.

* Bugfix: Xdmf, not XDMF

* removed nonworking tests, requires bugfix

* abaqus_read_results is not working -> bug
2017-01-30 12:28:33 +02:00

90 lines
2.5 KiB
Julia

# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
using JuliaFEM
using JuliaFEM.Testing
ALL_ELEMENTS = [
Seg2, Seg3,
Tri3, Tri6, Tri7,
Quad4, Quad8, Quad9,
Tet4, Tet10,
Wedge6,
Hex8, Hex20, Hex27
]
info("basic data for elements implemented so far:")
for element_type in [Poi1; ALL_ELEMENTS]
element = Element(element_type, Int[])
element_length = length(element)
element_size = size(element)
element_description = description(element)
info("Element $element_type, description = $element_description, length = $element_length, size = $element_size")
end
ALL_ELEMENTS_NODES = [
[1,2], [1,2,3],
[1,2,3], [1,2,3,4,5,6], [1,2,3,4,5,6,7],
[1,2,3,4], [1,2,3,4,5,6,7,8], [1,2,3,4,5,6,7,8,9],
[1,2,3,4], [1,2,3,4,5,6,7,8,9,10],
[1,2,3,4,5,6],
[1,2,3,4,5,6,7,8],
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,15,17,18,19,20],
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,15,17,18,19,20,
21,22,23,24,25,26,27]
]
@testset "Evaluating basis" begin
for (T, nod) in zip(ALL_ELEMENTS,ALL_ELEMENTS_NODES)
el = Element(T,nod)
nnodes = length(el)
for (i, X) in enumerate(get_reference_coordinates(T))
Ni = vec(el(X))
expected = zeros(nnodes)
expected[i] = 1.0
@test isapprox(Ni, expected)
end
end
end
function get_volume{T<:AbstractElement}(::Type{T},nodes)
X = get_reference_coordinates(T)
element = Element(T,nodes)
update!(element, "geometry", X)
V = 0.0
for ip in get_integration_points(element)
V += ip.weight*element(ip, 0.0, Val{:detJ})
end
return V
end
RESULTS = [2.0, 2.0, 0.5, 0.5, 0.5, 2.0^2, 2.0^2,
2.0^2, 1/6, 1/6, 1.0, 2.0^3, 2.0^3, 2.0^3,]
@testset "Calculate reference element length/area/volume" begin
for (T, nod, res) in zip(ALL_ELEMENTS,ALL_ELEMENTS_NODES,
RESULTS)
@test isapprox(get_volume(T,nod), res)
end
end
SIZES = [(1,2), (1,3), (2,3), (2,6), (2,7), (2,4),
(2,8), (2,9), (3,4), (3,10), (3,6), (3,8),
(3,20), (3,27)]
@testset "element size" begin
for (T, nod, res) in zip(ALL_ELEMENTS,ALL_ELEMENTS_NODES, SIZES)
@test size(Element(T,nod)) == res
end
end
@testset "element length" begin
for i in 1:length(ALL_ELEMENTS)
typ = ALL_ELEMENTS[i]
vec = ALL_ELEMENTS_NODES[i]
el = Element(typ,vec)
@test length(el) == length(vec)
end
end