Skip to content

Commit

Permalink
Losen type definitions Int64 -> Int
Browse files Browse the repository at this point in the history
Losen type definitions to make code work on 32-bit devices also. In
general, in function definitions we should use either Int which is
typealias to Int32 or Int64 depending machine architecture, or abstract
type Integer.
  • Loading branch information
ahojukka5 committed Apr 8, 2019
1 parent d010f5a commit 92268ef
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/elements_lagrange.jl
Expand Up @@ -19,7 +19,7 @@ function get_integration_order(::Poi1)
return 1
end

function get_integration_points(::Poi1, ::Int64)
function get_integration_points(::Poi1, ::Int)
return [ (1.0, (0.0, )) ]
end

Expand Down
22 changes: 11 additions & 11 deletions src/fields.jl
Expand Up @@ -28,7 +28,7 @@ function ==(x::F, y::F) where F<:AbstractField
return ==(x.data, y.data)
end

function getindex(f::F, i::Int64) where F<:AbstractField
function getindex(f::F, i::Int) where F<:AbstractField
return getindex(f.data, i)
end

Expand Down Expand Up @@ -59,7 +59,7 @@ mutable struct DCTI{T} <: AbstractField
data :: T
end

function getindex(field::DCTI, ::Int64)
function getindex(field::DCTI, ::Int)
return field.data
end

Expand Down Expand Up @@ -212,10 +212,10 @@ end
Discrete, variable, time invariant dictionary field.
"""
mutable struct DVTId{T} <: AbstractField
data :: Dict{Int64, T}
data :: Dict{Int, T}
end

function update_field!(field::DVTId{T}, data::Dict{Int64, T}) where T
function update_field!(field::DVTId{T}, data::Dict{Int, T}) where T
merge!(field.data, data)
end

Expand All @@ -225,10 +225,10 @@ end
Discrete, variable, time variant dictionary field.
"""
mutable struct DVTVd{T} <: AbstractField
data :: Vector{Pair{Float64,Dict{Int64,T}}}
data :: Vector{Pair{Float64,Dict{Int,T}}}
end

function DVTVd(data::Pair{Float64,Dict{Int64,T}}...) where T
function DVTVd(data::Pair{Float64,Dict{Int,T}}...) where T
return DVTVd(collect(data))
end

Expand All @@ -254,7 +254,7 @@ function interpolate_field(field::DVTVd{T}, time) where T
end
end

function update_field!(f::DVTVd, data::Pair{Float64,Dict{Int64,T}}) where T
function update_field!(f::DVTVd, data::Pair{Float64,Dict{Int,T}}) where T
if isapprox(last(f.data).first, data.first)
f.data[end] = data
else
Expand Down Expand Up @@ -286,19 +286,19 @@ function new_field(data::Function)
return CVTV(data)
end

function new_field(data::Pair{Int64, T}...) where T
function new_field(data::Pair{Int, T}...) where T
return DVTId(Dict(data))
end

function new_field(data::Pair{Float64, NTuple{N, Pair{Int64, T}}}...) where {N,T}
function new_field(data::Pair{Float64, NTuple{N, Pair{Int, T}}}...) where {N,T}
return DVTVd(collect(t => Dict(d) for (t, d) in data))
end

function new_field(data::Dict{Int64,T}) where T
function new_field(data::Dict{Int,T}) where T
return DVTId(data)
end

function new_field(data::Pair{Float64, Dict{Int64, T}}...) where T
function new_field(data::Pair{Float64, Dict{Int, T}}...) where T
return DVTVd(collect(data))
end

Expand Down
8 changes: 4 additions & 4 deletions src/problems.jl
Expand Up @@ -36,7 +36,7 @@ mutable struct Assembly
la_prev :: Vector{Float64} # previous solution vector u
la_norm_change :: Real # change of norm in la

removed_dofs :: Vector{Int64} # manually remove dofs from assembly
removed_dofs :: Vector{Int} # manually remove dofs from assembly
end

function Assembly()
Expand Down Expand Up @@ -95,7 +95,7 @@ mutable struct Problem{P<:AbstractProblem}
dimension :: Int # degrees of freedom per node
parent_field_name :: AbstractString # (optional) name of the parent field e.g. "displacement"
elements :: Vector{Element}
dofmap :: Dict{Element, Vector{Int64}} # connects the element local dofs to the global dofs
dofmap :: Dict{Element, Vector{Int}} # connects the element local dofs to the global dofs
assembly :: Assembly
fields :: Dict{String, AbstractField}
postprocess_fields :: Vector{String}
Expand Down Expand Up @@ -123,7 +123,7 @@ problem2 = Problem(Heat, "test problem 2", 1)
```
"""
function Problem(::Type{P}, name::AbstractString, dimension::Int64) where P<:FieldProblem
function Problem(::Type{P}, name::AbstractString, dimension::Int) where P<:FieldProblem
parent_field_name = "none"
elements = []
dofmap = Dict()
Expand Down Expand Up @@ -418,7 +418,7 @@ function (problem::Problem)(field_name::String, time::Float64)
#if haskey(problem, field_name)
# return problem[field_name](time)
#end
f = Dict{Int64, Any}()
f = Dict{Int, Any}()
for element in get_elements(problem)
haskey(element, field_name) || continue
for (c, v) in zip(get_connectivity(element), element(field_name, time))
Expand Down
6 changes: 3 additions & 3 deletions src/test.jl
Expand Up @@ -107,7 +107,7 @@ function FEMBase.assemble_elements!(problem::Problem{Dirichlet},
name = get_parent_field_name(problem)
dim = get_unknown_field_dimension(problem)

data = Dict{Int64,Float64}()
data = Dict{Int,Float64}()
for element in elements
for i=1:dim
haskey(element, "$name $i") || continue
Expand Down Expand Up @@ -215,8 +215,8 @@ function read_mtx(data::IO; dim=0)
end
end
seekstart(data)
I = Int64[]
J = Int64[]
I = Int[]
J = Int[]
V = Float64[]
for ln in eachline(data)
i,idof,j,jdof,value = map(Meta.parse, split(ln, ','))
Expand Down
4 changes: 2 additions & 2 deletions test/test_elements.jl
Expand Up @@ -113,7 +113,7 @@ end

@testset "inside of linear element" begin
el = Element(Quad4, [1, 2, 3, 4])
X = Dict{Int64, Vector{Float64}}(
X = Dict(
1 => [0.0, 0.0],
2 => [1.0, 0.0],
3 => [1.0, 1.0],
Expand All @@ -129,7 +129,7 @@ end

@testset "inside of quadratic element" begin
el = Element(Tri6, [1, 2, 3, 4, 5, 6])
X = Dict{Int64, Vector{Float64}}(
X = Dict(
1 => [0.0, 0.0],
2 => [1.0, 0.0],
3 => [0.0, 1.0],
Expand Down
6 changes: 3 additions & 3 deletions test/test_elements_2.jl
Expand Up @@ -7,7 +7,7 @@ using Test

@testset "inverse isoparametric mapping" begin
el = Element(Quad4, [1, 2, 3, 4])
X = Dict{Int64, Vector{Float64}}(
X = Dict(
1 => [0.0, 0.0],
2 => [1.0, 0.0],
3 => [1.0, 1.0],
Expand All @@ -23,7 +23,7 @@ end

@testset "inside of linear element" begin
el = Element(Quad4, [1, 2, 3, 4])
X = Dict{Int64, Vector{Float64}}(
X = Dict(
1 => [0.0, 0.0],
2 => [1.0, 0.0],
3 => [1.0, 1.0],
Expand All @@ -39,7 +39,7 @@ end

@testset "inside of quadratic element" begin
el = Element(Tri6, [1, 2, 3, 4, 5, 6])
X = Dict{Int64, Vector{Float64}}(
X = Dict(
1 => [0.0, 0.0],
2 => [1.0, 0.0],
3 => [0.0, 1.0],
Expand Down
2 changes: 1 addition & 1 deletion test/test_problems.jl
Expand Up @@ -198,7 +198,7 @@ function assemble_elements!(problem::Problem{DirBC},
name = get_parent_field_name(problem)
dim = get_unknown_field_dimension(problem)

data = Dict{Int64,Float64}()
data = Dict{Int,Float64}()
for element in elements
for i=1:dim
haskey(element, "$name $dim") || continue
Expand Down
2 changes: 1 addition & 1 deletion test/test_solvers.jl
Expand Up @@ -5,7 +5,7 @@ using FEMBase, Test, SparseArrays
import FEMBase: solve!, can_solve

mutable struct LSSolver1 <: AbstractLinearSystemSolver
a :: Int64
a :: Int
end

mutable struct LSSolver2 <: AbstractLinearSystemSolver
Expand Down

0 comments on commit 92268ef

Please sign in to comment.