Fix deprecations (#206)

This commit is contained in:
femtocleaner[bot]
2018-07-05 11:21:10 +03:00
committed by Jukka Aho
parent 86fdc59f20
commit a8a3e0b46e
12 changed files with 51 additions and 49 deletions
+3 -3
View File
@@ -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)
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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
+1 -1
View File
@@ -4,7 +4,7 @@
"""
Problem u(X) = u₀ in Γ(d)
"""
type Dirichlet <: BoundaryProblem
mutable struct Dirichlet <: BoundaryProblem
formulation :: Symbol
variational :: Bool
dual_basis :: Bool
+9 -9
View File
@@ -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)
+12 -12
View File
@@ -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)
+1 -1
View File
@@ -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
+9 -9
View File
@@ -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)
+4 -4
View File
@@ -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
+1 -1
View File
@@ -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
+5 -3
View File
@@ -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
+2 -2
View File
@@ -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