Skip to content

Commit

Permalink
Fix deprecations (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
femtocleaner[bot] authored and ahojukka5 committed Jul 5, 2018
1 parent 44b89bd commit 0730f64
Show file tree
Hide file tree
Showing 18 changed files with 131 additions and 131 deletions.
12 changes: 6 additions & 6 deletions docs/src/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ E.g. mesh reader or results writer.


```julia
type MeshReader <: AbstractMeshReader
mutable struct MeshReader <: AbstractMeshReader
end

"""
Expand All @@ -20,7 +20,7 @@ end


```julia
type ResultsWriter <: AbstractResultsWriter
mutable struct ResultsWriter <: AbstractResultsWriter
end

"""
Expand All @@ -39,7 +39,7 @@ Starting point is a weak formulation, which is then discretized to elements.


```julia
type Heat <: AbstractProblem
mutable struct Heat <: AbstractProblem
end

"""
Expand All @@ -60,7 +60,7 @@ Aim is to define material response given data.


```julia
type LinearIsotropic <: AbstractMaterial
mutable struct LinearIsotropic <: AbstractMaterial
end

"""
Expand Down Expand Up @@ -96,7 +96,7 @@ end


```julia
type Quad4PointGaussLegendre <: AbstractIntegrationRule
mutable struct Quad4PointGaussLegendre <: AbstractIntegrationRule
end

"""
Expand All @@ -113,7 +113,7 @@ end


```julia
type ImplicitTimeSolver <: AbstractSolver
mutable struct ImplicitTimeSolver <: AbstractSolver
end

"""
Expand Down
2 changes: 1 addition & 1 deletion docs/src/mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ end
Whould work somehow like this:

```julia
type DemoReader <: AbstractMeshReader
mutable struct DemoReader <: AbstractMeshReader
handle :: String
end

Expand Down
8 changes: 4 additions & 4 deletions src/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
abstract type AbstractAnalysis end
abstract type AbstractResultsWriter end

type Analysis{A<:AbstractAnalysis}
mutable struct Analysis{A<:AbstractAnalysis}
name :: String
problems :: Vector{Problem}
fields :: Dict{String, AbstractField}
results_writers :: Vector{AbstractResultsWriter}
properties :: A
end

function Analysis{A<:AbstractAnalysis}(::Type{A}, name::String="$A Analysis")
function Analysis(::Type{A}, name::String="$A Analysis") where A<:AbstractAnalysis
analysis = Analysis{A}(name, [], Dict(), [], A())
return analysis
end
Expand All @@ -25,7 +25,7 @@ function get_problems(analysis::Analysis)
return analysis.problems
end

function add_results_writer!{W<:AbstractResultsWriter}(analysis::Analysis, writer::W)
function add_results_writer!(analysis::Analysis, writer::W) where W<:AbstractResultsWriter
push!(analysis.results_writers, writer)
return nothing
end
Expand All @@ -34,7 +34,7 @@ function get_results_writers(analysis::Analysis)
return analysis.results_writers
end

function run!{A<:AbstractAnalysis}(::Analysis{A})
function run!(::Analysis{A}) where A<:AbstractAnalysis
info("This is a placeholder function for running an analysis $A for a set of problems.")
end

Expand Down
16 changes: 8 additions & 8 deletions src/assembly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ function isapprox(a1::Assembly, a2::Assembly)
return T
end

function assemble_prehook!{T<:Number}(::Problem, ::T) end
function assemble_prehook!(::Problem, ::T) where T<:Number end

function assemble_posthook!{T<:Number}(::Problem, ::T) end
function assemble_posthook!(::Problem, ::T) where T<:Number end

# will be deprecated
function assemble!{P}(::Assembly, ::Problem{P}, ::Element, ::Any)
function assemble!(::Assembly, ::Problem{P}, ::Element, ::Any) where P
warn("One must define assemble! function for problem of type $P. ",
"Not doing anything.")
return nothing
end

# will be deprecated
function assemble!{P}(assembly::Assembly, problem::Problem{P},
elements::Vector{Element}, time)
function assemble!(assembly::Assembly, problem::Problem{P},
elements::Vector{Element}, time) where P
warn("This is default assemble! function. Decreased performance can be ",
"expected without preallocation of memory. One should implement ",
"`assemble_elements!(problem, assembly, elements, time)` function.")
Expand All @@ -41,8 +41,8 @@ Assemble elements for problem.
This should be overridden with own `assemble_elements!`-implementation.
"""
function assemble_elements!{E}(problem::Problem, assembly::Assembly,
elements::Vector{Element{E}}, time)
function assemble_elements!(problem::Problem, assembly::Assembly,
elements::Vector{Element{E}}, time) where E
elements2 = convert(Vector{Element}, elements)
assemble!(assembly, problem, elements2, time)
end
Expand Down Expand Up @@ -107,7 +107,7 @@ function assemble_mass_matrix!(problem::Problem, time::Float64)
return nothing
end

function assemble_mass_matrix!{Basis}(problem::Problem, elements::Vector{Element{Basis}}, time)
function assemble_mass_matrix!(problem::Problem, elements::Vector{Element{Basis}}, time) where Basis
nnodes = length(first(elements))
dim = get_unknown_field_dimension(problem)
M = zeros(nnodes, nnodes)
Expand Down
40 changes: 20 additions & 20 deletions src/elements.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/FEMBase.jl/blob/master/LICENSE

type Element{E<:AbstractBasis}
mutable struct Element{E<:AbstractBasis}
id :: Int
connectivity :: Vector{Int}
integration_points :: Vector{IP}
Expand All @@ -25,7 +25,7 @@ element = Element(Tri3, [89, 43, 12])
```
![img](figs/mesh.png)
"""
function Element{E<:AbstractBasis}(::Type{E}, connectivity::Vector{Int})
function Element(::Type{E}, connectivity::Vector{Int}) where E<:AbstractBasis
return Element{E}(-1, connectivity, [], Dict(), E())
end

Expand All @@ -51,19 +51,19 @@ function getindex(element::Element, field_name::String)
return element.fields[field_name]
end

function setindex!{T<:AbstractField}(element::Element, data::T, field_name)
function setindex!(element::Element, data::T, field_name) where T<:AbstractField
element.fields[field_name] = data
end

function get_element_type{E}(::Element{E})
function get_element_type(::Element{E}) where E
return E
end

function get_element_id{E}(element::Element{E})
function get_element_id(element::Element{E}) where E
return element.id
end

function is_element_type{E}(::Element{E}, element_type)
function is_element_type(::Element{E}, element_type) where E
return E === element_type
end

Expand Down Expand Up @@ -149,14 +149,14 @@ function interpolate(element::Element, field_name::String, time::Float64)
end
end

function get_basis{B}(element::Element{B}, ip, ::Any)
function get_basis(element::Element{B}, ip, ::Any) where B
T = typeof(first(ip))
N = zeros(T, 1, length(element))
eval_basis!(B, N, tuple(ip...))
return N
end

function get_dbasis{B}(element::Element{B}, ip, ::Any)
function get_dbasis(element::Element{B}, ip, ::Any) where B
T = typeof(first(ip))
dN = zeros(T, size(element)...)
eval_dbasis!(B, dN, tuple(ip...))
Expand Down Expand Up @@ -224,18 +224,18 @@ function interpolate(element::Element, field_name, ip, time)
return interpolate_field(element, field, ip, time)
end

function interpolate_field{T<:Union{DCTI,DCTV}}(::Element, field::T, ::Any, time)
function interpolate_field(::Element, field::T, ::Any, time) where T<:Union{DCTI,DCTV}
return interpolate_field(field, time)
end

function interpolate_field{T<:Union{DVTV,DVTI}}(element::Element, field::T, ip, time)
function interpolate_field(element::Element, field::T, ip, time) where T<:Union{DVTV,DVTI}
data = interpolate_field(field, time)
basis = get_basis(element, ip, time)
N = length(basis)
return sum(data[i]*basis[i] for i=1:N)
end

function interpolate_field{T<:Union{DVTVd,DVTId}}(element::Element, field::T, ip, time)
function interpolate_field(element::Element, field::T, ip, time) where T<:Union{DVTVd,DVTId}
data = interpolate_field(field, time)
basis = element(ip, time)
N = length(element)
Expand All @@ -251,17 +251,17 @@ function size(element::Element, dim)
return size(element)[dim]
end

function update!{F<:AbstractField}(::Element, field::F, data)
function update!(::Element, field::F, data) where F<:AbstractField
update!(field, data)
end

function update!{F<:DVTI,T,V}(element::Element, field::F, data_::Dict{T,V})
function update!(element::Element, field::F, data_::Dict{T,V}) where {F<:DVTI,T,V}
data = (collect(data_[i] for i in get_connectivity(element))...)
update!(field, data)
end

function update!{F<:DVTV,T,V}(element::Element, field::F,
data__::Pair{Float64, Dict{T,V}})
function update!(element::Element, field::F,
data__::Pair{Float64, Dict{T,V}}) where {F<:DVTV,T,V}
time_, data_ = data__
data = (collect(data_[i] for i in get_connectivity(element))...)
update!(field, time_ => data)
Expand All @@ -275,7 +275,7 @@ function update!(element::Element, field_name, data)
end
end

function update!{F<:AbstractField}(element::Element, field_name, field_::F)
function update!(element::Element, field_name, field_::F) where F<:AbstractField
element.fields[field_name] = field_
end

Expand All @@ -298,7 +298,7 @@ function haskey(element::Element, field_name)
return haskey(element.fields, field_name)
end

function get_integration_points{E}(element::Element{E})
function get_integration_points(element::Element{E}) where E
# first time initialize default integration points
if length(element.integration_points) == 0
ips = get_integration_points(element.properties)
Expand All @@ -314,7 +314,7 @@ end
""" This is a special case, temporarily change order
of integration scheme mainly for mass matrix.
"""
function get_integration_points{E}(element::Element{E}, change_order::Int)
function get_integration_points(element::Element{E}, change_order::Int) where E
ips = get_integration_points(element.properties, Val{change_order})
if E in (Seg2, Seg3, NSeg)
return [IP(i, w, (xi,)) for (i, (w, xi)) in enumerate(ips)]
Expand All @@ -341,7 +341,7 @@ function get_local_coordinates(element::Element, X::Vector, time::Float64; max_i
end

""" Test is X inside element. """
function inside{E}(element::Element{E}, X, time)
function inside(element::Element{E}, X, time) where E
xi = get_local_coordinates(element, X, time)
return inside(E, xi)
end
Expand All @@ -358,7 +358,7 @@ function (element::Element)(field_name::String, ip, time::Float64)
return interpolate(element, field_name, ip, time)
end

function element_info!{E,T}(bi::BasisInfo{E,T}, element::Element{E}, ip, time)
function element_info!(bi::BasisInfo{E,T}, element::Element{E}, ip, time) where {E,T}
X = interpolate(element, "geometry", time)
eval_basis!(bi, X, ip)
return bi.J, bi.detJ, bi.N, bi.grad
Expand Down
Loading

0 comments on commit 0730f64

Please sign in to comment.