From a8a3e0b46e15a1d2590f94ff36b2af24c10f0257 Mon Sep 17 00:00:00 2001 From: "femtocleaner[bot]" Date: Thu, 5 Jul 2018 11:21:10 +0300 Subject: [PATCH] Fix deprecations (#206) --- src/io.jl | 6 +++--- src/preprocess.jl | 6 +++--- src/problems_contact.jl | 2 +- src/problems_dirichlet.jl | 2 +- src/problems_elasticity.jl | 18 +++++++++--------- src/problems_elasticity_2d.jl | 24 ++++++++++++------------ src/problems_mortar.jl | 2 +- src/problems_mortar_3d.jl | 18 +++++++++--------- src/solvers.jl | 8 ++++---- src/solvers_modal.jl | 2 +- test/test_potential_energy.jl | 8 +++++--- test/test_virtual_work.jl | 4 ++-- 12 files changed, 51 insertions(+), 49 deletions(-) diff --git a/src/io.jl b/src/io.jl index 14ca1d9..6b93e0e 100644 --- a/src/io.jl +++ b/src/io.jl @@ -4,7 +4,7 @@ using HDF5 using LightXML -type Xdmf <: AbstractResultsWriter +mutable struct Xdmf <: AbstractResultsWriter name :: String xml :: XMLElement hdf :: HDF5File @@ -261,7 +261,7 @@ function save!(xdmf::Xdmf) save_file(doc, xmffile(xdmf)) end -function new_dataitem{T,N}(xdmf::Xdmf, path::String, data::Array{T,N}) +function new_dataitem(xdmf::Xdmf, path::String, data::Array{T,N}) where {T,N} dataitem = new_element("DataItem") datatype = replace("$T", "64", "") dimensions = join(reverse(size(data)), " ") @@ -293,7 +293,7 @@ end Create a new DataItem element, hdf path automatically determined. """ -function new_dataitem{T,N}(xdmf::Xdmf, data::Array{T,N}) +function new_dataitem(xdmf::Xdmf, data::Array{T,N}) where {T,N} if xdmf.format == "XML" # Path can be whatever as XML format does not store to HDF at all return new_dataitem(xdmf, "/whatever", data) diff --git a/src/preprocess.jl b/src/preprocess.jl index 3890374..d759b9c 100644 --- a/src/preprocess.jl +++ b/src/preprocess.jl @@ -16,7 +16,7 @@ import Base: copy using JuliaFEM -type Mesh +mutable struct Mesh nodes :: Dict{Int, Vector{Float64}} node_sets :: Dict{Symbol, Set{Int}} elements :: Dict{Int, Vector{Int}} @@ -292,13 +292,13 @@ function reorder_element_connectivity!(mesh::Mesh, mapping::Dict{Symbol, Vector{ end end -function JuliaFEM.Problem{P<:FieldProblem}(mesh::Mesh, ::Type{P}, name::AbstractString, dimension::Int) +function JuliaFEM.Problem(mesh::Mesh, ::Type{P}, name::AbstractString, dimension::Int) where P<:FieldProblem problem = Problem(P, name, dimension) problem.elements = create_elements(mesh, name) return problem end -function JuliaFEM.Problem{P<:BoundaryProblem}(mesh::Mesh, ::Type{P}, name, dimension, parent_field_name) +function JuliaFEM.Problem(mesh::Mesh, ::Type{P}, name, dimension, parent_field_name) where P<:BoundaryProblem problem = Problem(P, name, dimension, parent_field_name) problem.elements = create_elements(mesh, name) return problem diff --git a/src/problems_contact.jl b/src/problems_contact.jl index 210ea5c..b38e011 100644 --- a/src/problems_contact.jl +++ b/src/problems_contact.jl @@ -10,7 +10,7 @@ distval 5 means that distance of slave element midpoint and point to project is 5 times larger than length of element """ -type Contact <: BoundaryProblem +mutable struct Contact <: BoundaryProblem dimension :: Int rotate_normals :: Bool finite_sliding :: Bool diff --git a/src/problems_dirichlet.jl b/src/problems_dirichlet.jl index 6cc1331..ecab62a 100644 --- a/src/problems_dirichlet.jl +++ b/src/problems_dirichlet.jl @@ -4,7 +4,7 @@ """ Problem u(X) = u₀ in Γ(d) """ -type Dirichlet <: BoundaryProblem +mutable struct Dirichlet <: BoundaryProblem formulation :: Symbol variational :: Bool dual_basis :: Bool diff --git a/src/problems_elasticity.jl b/src/problems_elasticity.jl index 453c33a..1f8931a 100644 --- a/src/problems_elasticity.jl +++ b/src/problems_elasticity.jl @@ -33,7 +33,7 @@ https://en.wikipedia.org/wiki/Plane_stress https://en.wikipedia.org/wiki/Hooke's_law """ -type Elasticity <: FieldProblem +mutable struct Elasticity <: FieldProblem # these are found from problem.properties for type Problem{Elasticity} formulation :: Symbol finite_strain :: Bool @@ -99,10 +99,10 @@ function initialize_internal_params!(params, ip, type_) #::Type{Val{:type_2d}}) end """ Assemble 3d continuum elements in general solid mechanics problem. """ -function assemble!{El<:Elasticity3DVolumeElements}(assembly::Assembly, - problem::Problem{Elasticity}, - elements::Vector{Element{El}}, - time, ::Type{Val{:continuum}}) +function assemble!(assembly::Assembly, + problem::Problem{Elasticity}, + elements::Vector{Element{El}}, + time, ::Type{Val{:continuum}}) where El<:Elasticity3DVolumeElements props = problem.properties dim = get_unknown_field_dimension(problem) @@ -342,10 +342,10 @@ function assemble!{El<:Elasticity3DVolumeElements}(assembly::Assembly, end """ Elasticity equations, surface traction for continuum formulation. """ -function assemble!{El<:Elasticity3DSurfaceElements}(assembly::Assembly, - problem::Problem{Elasticity}, - elements::Vector{Element{El}}, - time, ::Type{Val{:continuum}}) +function assemble!(assembly::Assembly, + problem::Problem{Elasticity}, + elements::Vector{Element{El}}, + time, ::Type{Val{:continuum}}) where El<:Elasticity3DSurfaceElements props = problem.properties dim = get_unknown_field_dimension(problem) diff --git a/src/problems_elasticity_2d.jl b/src/problems_elasticity_2d.jl index 2be26f9..3e80076 100644 --- a/src/problems_elasticity_2d.jl +++ b/src/problems_elasticity_2d.jl @@ -4,9 +4,9 @@ const Elasticity2DSurfaceElements = Union{Poi1,Seg2,Seg3} const Elasticity2DVolumeElements = Union{Tri3,Tri6,Quad4,Quad8,Quad9} -function assemble!{T}(assembly::Assembly, problem::Problem{Elasticity}, - elements::Union{Vector{Element}, Vector{Element{T}}}, - time, ::Type{Val{:plane_stress}}) +function assemble!(assembly::Assembly, problem::Problem{Elasticity}, + elements::Union{Vector{Element}, Vector{Element{T}}}, + time, ::Type{Val{:plane_stress}}) where T for element in elements gdofs = get_gdofs(problem, element) Km, Kg, f = assemble(problem, element, time, Val{:plane}) @@ -16,9 +16,9 @@ function assemble!{T}(assembly::Assembly, problem::Problem{Elasticity}, end end -function assemble!{T}(assembly::Assembly, problem::Problem{Elasticity}, - elements::Union{Vector{Element}, Vector{Element{T}}}, - time, ::Type{Val{:plane_strain}}) +function assemble!(assembly::Assembly, problem::Problem{Elasticity}, + elements::Union{Vector{Element}, Vector{Element{T}}}, + time, ::Type{Val{:plane_strain}}) where T for element in elements gdofs = get_gdofs(problem, element) Km, Kg, f = assemble(problem, element, time, Val{:plane}) @@ -29,9 +29,9 @@ function assemble!{T}(assembly::Assembly, problem::Problem{Elasticity}, end """ Plane elasticity equations (plane stress, plane strain). """ -function assemble{El<:Elasticity2DVolumeElements}(problem::Problem{Elasticity}, - element::Element{El}, time, - ::Type{Val{:plane}}) +function assemble(problem::Problem{Elasticity}, + element::Element{El}, time, + ::Type{Val{:plane}}) where El<:Elasticity2DVolumeElements props = problem.properties dim = get_unknown_field_dimension(problem) @@ -184,9 +184,9 @@ function assemble{El<:Elasticity2DVolumeElements}(problem::Problem{Elasticity}, return Km, Kg, f end -function assemble{El<:Elasticity2DSurfaceElements}(problem::Problem{Elasticity}, - element::Element{El}, - time, ::Type{Val{:plane}}) +function assemble(problem::Problem{Elasticity}, + element::Element{El}, + time, ::Type{Val{:plane}}) where El<:Elasticity2DSurfaceElements props = problem.properties dim = get_unknown_field_dimension(problem) diff --git a/src/problems_mortar.jl b/src/problems_mortar.jl index 193e9e6..6ec769e 100644 --- a/src/problems_mortar.jl +++ b/src/problems_mortar.jl @@ -32,7 +32,7 @@ split_quadratic_master_elements store_fields not used """ -type Mortar <: BoundaryProblem +mutable struct Mortar <: BoundaryProblem dimension :: Int rotate_normals :: Bool adjust :: Bool diff --git a/src/problems_mortar_3d.jl b/src/problems_mortar_3d.jl index b5dc278..d89d9a8 100644 --- a/src/problems_mortar_3d.jl +++ b/src/problems_mortar_3d.jl @@ -94,7 +94,7 @@ julia> approx_in(q, P) true """ -function approx_in{T}(q::T, P::Vector{T}; rtol=1.0e-4, atol=0.0) +function approx_in(q::T, P::Vector{T}; rtol=1.0e-4, atol=0.0) where T for p in P if isapprox(q, p; rtol=rtol, atol=atol) return true @@ -103,7 +103,7 @@ function approx_in{T}(q::T, P::Vector{T}; rtol=1.0e-4, atol=0.0) return false end -function get_polygon_clip{T}(xs::Vector{T}, xm::Vector{T}, n::T) +function get_polygon_clip(xs::Vector{T}, xm::Vector{T}, n::T) where T # objective: search does line xm1 - xm2 clip xs nm = length(xm) ns = length(xs) @@ -151,9 +151,9 @@ function get_polygon_clip{T}(xs::Vector{T}, xm::Vector{T}, n::T) end """ Project some vertex p to surface of element E using Newton's iterations. """ -function project_vertex_to_surface{E}(p, x0, n0, - element::Element{E}, x, time; - max_iterations=10, iter_tol=1.0e-6) +function project_vertex_to_surface(p, x0, n0, + element::Element{E}, x, time; + max_iterations=10, iter_tol=1.0e-6) where E basis(xi) = get_basis(element, xi, time) function dbasis(xi) return get_dbasis(element, xi, time) @@ -279,7 +279,7 @@ function check_orientation!(P, n) end) end -function convert_to_linear_element{E}(element::Element{E}) +function convert_to_linear_element(element::Element{E}) where E return element end @@ -290,7 +290,7 @@ function convert_to_linear_element(element::Element{Tri6}) return new_element end -function split_quadratic_element{E}(element::Element{E}, time::Float64) +function split_quadratic_element(element::Element{E}, time::Float64) where E return [element] end @@ -360,7 +360,7 @@ References [Popp2013] Popp, Alexander, et al. "Improved robustness and consistency of 3D contact algorithms based on a dual mortar approach." Computer Methods in Applied Mechanics and Engineering 264 (2013): 67-80. """ -function assemble!{E<:Union{Tri3, Quad4}}(problem::Problem{Mortar}, slave_element::Element{E}, time::Real; first_slave_element=false) +function assemble!(problem::Problem{Mortar}, slave_element::Element{E}, time::Real; first_slave_element=false) where E<:Union{Tri3, Quad4} props = problem.properties field_dim = get_unknown_field_dimension(problem) @@ -533,7 +533,7 @@ References [Popp1012] Popp, Alexander, et al. "Dual quadratic mortar finite element methods for 3D finite deformation contact." SIAM Journal on Scientific Computing 34.4 (2012): B421-B446. """ -function assemble!{E<:Union{Tri6}}(problem::Problem{Mortar}, slave_element::Element{E}, time::Real; first_slave_element=false) +function assemble!(problem::Problem{Mortar}, slave_element::Element{E}, time::Real; first_slave_element=false) where E<:Union{Tri6} props = problem.properties field_dim = get_unknown_field_dimension(problem) diff --git a/src/solvers.jl b/src/solvers.jl index 232699f..5c77f3a 100644 --- a/src/solvers.jl +++ b/src/solvers.jl @@ -12,7 +12,7 @@ function Solver{S<:AbstractSolver}(::Type{S}, name="solver", properties...) end =# -function Solver{S<:AbstractSolver}(::Type{S}, problems::Problem...) +function Solver(::Type{S}, problems::Problem...) where S<:AbstractSolver solver = Solver(S, "$(S)Solver") push!(solver.problems, problems...) return solver @@ -471,7 +471,7 @@ function (solver::Solver)(field_name::String, time::Float64) end """ Default update for solver. """ -function update!{S}(solver::Solver{S}, u, la, time) +function update!(solver::Solver{S}, u, la, time) where S #u = solver.u #la = solver.la @@ -536,7 +536,7 @@ end ### Nonlinear quasistatic solver -type Nonlinear <: AbstractSolver +mutable struct Nonlinear <: AbstractSolver time :: Float64 iteration :: Int # iteration counter min_iterations :: Int64 # minimum number of iterations @@ -630,7 +630,7 @@ Main differences in this solver, compared to nonlinear solver are: 2. reassembly of problem is done only if it's manually requested using empty!(problem.assembly) """ -type Linear <: AbstractSolver +mutable struct Linear <: AbstractSolver time :: Float64 end diff --git a/src/solvers_modal.jl b/src/solvers_modal.jl index d1596ce..b465277 100644 --- a/src/solvers_modal.jl +++ b/src/solvers_modal.jl @@ -11,7 +11,7 @@ julia> solver = Solver(Modal) julia> push!(solver, problems...) julia> solver() """ -type Modal <: AbstractSolver +mutable struct Modal <: AbstractSolver time :: Float64 geometric_stiffness :: Bool eigvals :: Vector diff --git a/test/test_potential_energy.jl b/test/test_potential_energy.jl index 3da7117..8da2b19 100644 --- a/test/test_potential_energy.jl +++ b/test/test_potential_energy.jl @@ -4,17 +4,19 @@ using JuliaFEM using JuliaFEM.Testing -abstract HeatProblem <: AbstractProblem +abstract type HeatProblem <: AbstractProblem + +end function HeatProblem(dim::Int=1, elements=[]) return Problem{HeatProblem}(dim, elements) end -function get_unknown_field_name{P<:HeatProblem}(::Type{P}) +function get_unknown_field_name(::Type{P}) where P<:HeatProblem return "temperature" end -function get_unknown_field_type{P<:HeatProblem}(::Type{P}) +function get_unknown_field_type(::Type{P}) where P<:HeatProblem return Float64 end diff --git a/test/test_virtual_work.jl b/test/test_virtual_work.jl index 2996ded..5a44413 100644 --- a/test/test_virtual_work.jl +++ b/test/test_virtual_work.jl @@ -10,11 +10,11 @@ function PlaneStressElasticityProblem(dim::Int=2, elements=[]) return Problem{PlaneStressElasticityProblem}(dim, elements) end -function get_unknown_field_name{P<:PlaneStressElasticityProblem}(::Type{P}) +function get_unknown_field_name(::Type{P}) where P<:PlaneStressElasticityProblem return "displacement" end -function get_unknown_field_type{P<:PlaneStressElasticityProblem}(::Type{P}) +function get_unknown_field_type(::Type{P}) where P<:PlaneStressElasticityProblem return Vector{Float64} end