From 97da4380889b6a9cc69fa7eff83e4dcc2531adda Mon Sep 17 00:00:00 2001 From: Jukka Aho Date: Thu, 20 Jul 2017 17:10:15 +0300 Subject: [PATCH] add CheckHeader and CheckTabs (#125) * add `CheckHeader.jl` and `CheckTabs.jl` to `travis.yml` * fix tab -> 4 spaces --- .travis.yml | 4 +++ src/elements_lagrange.jl | 16 ++++++------ src/problems_mortar.jl | 2 +- ...ity_hollow_sphere_with_surface_pressure.jl | 25 +++++++++--------- test/test_elasticity_med_pyr5_point_load.jl | 10 +++---- test/test_elasticity_pyr5_point_load.jl | 26 +++++++++---------- test/test_preprocess_abaqus_reader.jl | 2 +- 7 files changed, 44 insertions(+), 41 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8a7b7b1..418c8d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,12 @@ before_script: - julia --color=yes -e 'Pkg.add("Coverage")' - julia --color=yes -e 'Pkg.add("Documenter")' - julia --color=yes -e 'Pkg.add("Lint")' + - julia --color=yes -e 'Pkg.clone("https://github.com/ahojukka5/CheckHeader.jl.git")' + - julia --color=yes -e 'Pkg.clone("https://github.com/ahojukka5/CheckTabs.jl.git")' script: - julia --color=yes -e 'Pkg.build("JuliaFEM")' + - julia --color=yes -e 'using CheckHeader; checkheader("JuliaFEM")' + - julia --color=yes -e 'using CheckTabs; checktabs("JuliaFEM")' - julia --color=yes -e 'Pkg.test("JuliaFEM", coverage=true)' after_success: - julia --color=yes -e 'cd(Pkg.dir("JuliaFEM", "test")); include("run_lint.jl")' diff --git a/src/elements_lagrange.jl b/src/elements_lagrange.jl index 9dfad83..d3f3d42 100644 --- a/src/elements_lagrange.jl +++ b/src/elements_lagrange.jl @@ -372,19 +372,19 @@ end function get_interpolation_polynomial(::Type{Pyr5}, xi) [ - 1.0/8.0*(1.0-1.0*xi[1])*(1.0-1.0*xi[2])*(1.0-1.0*xi[3]) - 1.0/8.0*(1.0+1.0*xi[1])*(1.0-1.0*xi[2])*(1.0-1.0*xi[3]) - 1.0/8.0*(1.0+1.0*xi[1])*(1.0+1.0*xi[2])*(1.0-1.0*xi[3]) - 1.0/8.0*(1.0-1.0*xi[1])*(1.0+1.0*xi[2])*(1.0-1.0*xi[3]) - 1.0/2.0*(1.0+xi[3]) + 1.0/8.0*(1.0-1.0*xi[1])*(1.0-1.0*xi[2])*(1.0-1.0*xi[3]) + 1.0/8.0*(1.0+1.0*xi[1])*(1.0-1.0*xi[2])*(1.0-1.0*xi[3]) + 1.0/8.0*(1.0+1.0*xi[1])*(1.0+1.0*xi[2])*(1.0-1.0*xi[3]) + 1.0/8.0*(1.0-1.0*xi[1])*(1.0+1.0*xi[2])*(1.0-1.0*xi[3]) + 1.0/2.0*(1.0+xi[3]) ]' end function get_interpolation_polynomial(::Type{Pyr5}, xi, ::Type{Val{:partial_derivatives}}) [ - -0.125*(1.0-xi[2])*(1.0-xi[3]) 0.125*(1.0-xi[2])*(1.0-xi[3]) 0.125*(1.0+xi[2])*(1.0-xi[3]) -0.125*(1.0+xi[2])*(1.0-xi[3]) 0.0 - -0.125*(1.0-xi[1])*(1.0-xi[3]) -0.125*(1.0+xi[1])*(1.0-xi[3]) 0.125*(1.0+xi[1])*(1.0-xi[3]) 0.125*(1.0-xi[1])*(1.0-xi[3]) 0.0 - -0.125*(1.0-xi[1])*(1.0-xi[2]) -0.125*(1.0+xi[1])*(1.0-xi[2]) -0.125*(1.0+xi[1])*(1.0+xi[2]) -0.125*(1.0-xi[1])*(1.0+xi[2]) 0.5 + -0.125*(1.0-xi[2])*(1.0-xi[3]) 0.125*(1.0-xi[2])*(1.0-xi[3]) 0.125*(1.0+xi[2])*(1.0-xi[3]) -0.125*(1.0+xi[2])*(1.0-xi[3]) 0.0 + -0.125*(1.0-xi[1])*(1.0-xi[3]) -0.125*(1.0+xi[1])*(1.0-xi[3]) 0.125*(1.0+xi[1])*(1.0-xi[3]) 0.125*(1.0-xi[1])*(1.0-xi[3]) 0.0 + -0.125*(1.0-xi[1])*(1.0-xi[2]) -0.125*(1.0+xi[1])*(1.0-xi[2]) -0.125*(1.0+xi[1])*(1.0+xi[2]) -0.125*(1.0-xi[1])*(1.0+xi[2]) 0.5 ] end diff --git a/src/problems_mortar.jl b/src/problems_mortar.jl index 73e8178..29e9cea 100644 --- a/src/problems_mortar.jl +++ b/src/problems_mortar.jl @@ -209,7 +209,7 @@ function diagnose_interface(problem::Problem{Mortar}, time::Float64) all_cells = get_cells(P, C0) info("Polygon is splitted to $(length(all_cells)) integration cells.") for (cell_id, cell) in enumerate(all_cells) - C_area = 0.0 + C_area = 0.0 virtual_element = Element(Tri3, Int[]) update!(virtual_element, "geometry", cell) diff --git a/test/test_elasticity_hollow_sphere_with_surface_pressure.jl b/test/test_elasticity_hollow_sphere_with_surface_pressure.jl index 9e91361..1d023e0 100644 --- a/test/test_elasticity_hollow_sphere_with_surface_pressure.jl +++ b/test/test_elasticity_hollow_sphere_with_surface_pressure.jl @@ -38,16 +38,16 @@ function lsq_fit(elements, field, time) gdofs = get_connectivity(element) # increase integration order by 1 from default for ip in get_integration_points(element, 1) - detJ = element(ip, time, Val{:detJ}) - w = ip.weight*detJ - N = element(ip, time) - f = field(element, ip, time) - add!(A, gdofs, gdofs, w*kron(N', N)) - for i=1:length(f) + detJ = element(ip, time, Val{:detJ}) + w = ip.weight*detJ + N = element(ip, time) + f = field(element, ip, time) + add!(A, gdofs, gdofs, w*kron(N', N)) + for i=1:length(f) add!(b, gdofs, w*f[i]*N, i) end volume += w - end + end end info("Mass matrix for least-squares fit is assembled. Total volume to fit: $volume") A = sparse(A) @@ -155,13 +155,13 @@ function test_wedge_sphere(model, u_CA, S_CA) break end end - # Stress state in M141 element - S_CA_gp = Dict() + # Stress state in M141 element + S_CA_gp = Dict() S_CA_gp[1] = [-2.31497155149131E+04, -2.30873958541450E+04, -2.59731750416165E+04, 1.16262216932559E+04, 1.05883267606309E+04, 1.04255059462671E+04] S_CA_gp[2] = [-2.20268425477595E+04, -2.59602179285979E+04, -2.45141753387488E+04, 1.08344827948196E+04, 1.02393080182646E+04, 1.18221520216293E+04] S_CA_gp[3] = [-2.12175032863505E+04, -2.38106746858742E+04, -2.75848287641255E+04, 1.23383626529382E+04, 9.45231798421561E+03, 1.04600859263009E+04] S_CA_gp[4] = [-2.88674347639302E+04, -2.90047144010521E+04, -3.19545639967296E+04, 1.24436733999204E+04, 1.14033189825355E+04, 1.09837505652098E+04] - S_CA_gp[5] = [-2.76741820176108E+04, -3.20576001061179E+04, -3.04041166591832E+04, 1.16023096459047E+04, 1.10324243354755E+04, 1.24679360552984E+04] + S_CA_gp[5] = [-2.76741820176108E+04, -3.20576001061179E+04, -3.04041166591832E+04, 1.16023096459047E+04, 1.10324243354755E+04, 1.24679360552984E+04] S_CA_gp[6] = [-2.68141147396280E+04, -2.97733271271234E+04, -3.36672334497799E+04, 1.32004501509553E+04, 1.01961070966382E+04, 1.10204979599285E+04] time = 0.0 @@ -169,12 +169,11 @@ function test_wedge_sphere(model, u_CA, S_CA) element.id == 141 || continue for (i, ip) in enumerate(get_integration_points(element)) S = get_stress(element, ip, time) - rtol = norm(S - S_CA_gp[i]) / max(norm(S), norm(S_CA_gp[i])) + rtol = norm(S - S_CA_gp[i]) / max(norm(S), norm(S_CA_gp[i])) info("$i $S, rtol=$rtol") - @test isapprox(S, S_CA_gp[i]) + @test isapprox(S, S_CA_gp[i]) end end - end @testset """1/8 hollow sphere with surface load""" begin diff --git a/test/test_elasticity_med_pyr5_point_load.jl b/test/test_elasticity_med_pyr5_point_load.jl index 8cf3ecc..6b8403c 100644 --- a/test/test_elasticity_med_pyr5_point_load.jl +++ b/test/test_elasticity_med_pyr5_point_load.jl @@ -18,25 +18,25 @@ using JuliaFEM.Testing update!([element1,baseQuad,tipPoint], "geometry", mesh.nodes) update!([element1], "youngs modulus", 288.0) update!([element1], "poissons ratio", 1/3) - + update!([tipPoint], "displacement traction force 1", 5.0) update!([tipPoint], "displacement traction force 2", -7.0) update!([tipPoint], "displacement traction force 3", 3.0) - + elasticity_problem = Problem(Elasticity, "solve continuum block", 3) elasticity_problem.properties.finite_strain = false push!(elasticity_problem, element1) push!(elasticity_problem, tipPoint) - + baseQuad[1]["displacement 1"] = 0.0 baseQuad[1]["displacement 2"] = 0.0 baseQuad[1]["displacement 3"] = 0.0 boundary_problem = Problem(Dirichlet, "Boundary conditions", 3, "displacement") push!(boundary_problem, baseQuad) - + solver = LinearSolver(elasticity_problem, boundary_problem) solver() - + disp = element1[1]("displacement", [0.0, 0.0, 1.0], 0.0) info("########################################################") info("displacement at tip: $disp") diff --git a/test/test_elasticity_pyr5_point_load.jl b/test/test_elasticity_pyr5_point_load.jl index 3ac86dd..15819a3 100644 --- a/test/test_elasticity_pyr5_point_load.jl +++ b/test/test_elasticity_pyr5_point_load.jl @@ -6,38 +6,38 @@ using JuliaFEM.Preprocess using JuliaFEM.Testing @testset "test Pyr5 elasticity with point load" begin - nodes = Dict{Int64, Node}( - 1 => [-1.0,-1.0,-1.0], - 2 => [ 1.0,-1.0,-1.0], - 3 => [ 1.0, 1.0,-1.0], - 4 => [-1.0, 1.0,-1.0], - 5 => [ 0.0, 0.0, 1.0]) - + nodes = Dict{Int64, Node}( + 1 => [-1.0,-1.0,-1.0], + 2 => [ 1.0,-1.0,-1.0], + 3 => [ 1.0, 1.0,-1.0], + 4 => [-1.0, 1.0,-1.0], + 5 => [ 0.0, 0.0, 1.0]) + element1 = Element(Pyr5, [1, 2, 3, 4, 5]) baseQuad = Element(Quad4, [1, 2, 3, 4]) tipPoint = Element(Poi1, [5,]) - + update!([element1,baseQuad,tipPoint], "geometry", nodes) update!([element1], "youngs modulus", 288.0) update!([element1], "poissons ratio", 1/3) - + update!([tipPoint], "displacement traction force 1", 5.0) update!([tipPoint], "displacement traction force 2", -7.0) update!([tipPoint], "displacement traction force 3", 3.0) - + elasticity_problem = Problem(Elasticity, "solve continuum block", 3) elasticity_problem.properties.finite_strain = false push!(elasticity_problem, element1, baseQuad, tipPoint) - + baseQuad["displacement 1"] = 0.0 baseQuad["displacement 2"] = 0.0 baseQuad["displacement 3"] = 0.0 boundary_problem = Problem(Dirichlet, "Boundary conditions", 3, "displacement") push!(boundary_problem, baseQuad) - + solver = LinearSolver(elasticity_problem, boundary_problem) solver() - + disp = element1("displacement", [0.0, 0.0, 1.0], 0.0) info("########################################################") info("displacement at tip: $disp") diff --git a/test/test_preprocess_abaqus_reader.jl b/test/test_preprocess_abaqus_reader.jl index 87cbe5e..94a7973 100644 --- a/test/test_preprocess_abaqus_reader.jl +++ b/test/test_preprocess_abaqus_reader.jl @@ -75,7 +75,7 @@ end 1, 2.649428 , -21.93735 , 217.2934 2, 27.54531 , 1.108443 , 228.8077 """ - fn = tempname() * ".inp" + fn = tempname() * ".inp" open(fn, "w") do fid write(fid, data) end mesh = abaqus_read_mesh(fn) @test length(mesh.nodes) == 2