diff --git a/README.md b/README.md index a209e0d..84383df 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ begin function FEMBasis.get_reference_element_coordinates(::Type{Tet10}) return ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0), (0.5, 0.0, 0.0), (0.5, 0.5, 0.0), (0.0, 0.5, 0.0), (0.0, 0.0, 0.5), (0.5, 0.0, 0.5), (0.0, 0.5, 0.5)) end - function FEMBasis.eval_basis!{T}(::Type{Tet10}, N::Matrix{T}, xi::Tuple{T, T, T}) + function FEMBasis.eval_basis!(::Type{Tet10}, N::Matrix{T}, xi::Tuple{T, T, T}) where T (u, v, w) = xi begin N[1] = 1.0 + -3.0u + -3.0v + -3.0w + 4.0 * (u * v) + 4.0 * (v * w) + 4.0 * (w * u) + 2.0 * u ^ 2 + 2.0 * v ^ 2 + 2.0 * w ^ 2 @@ -60,7 +60,7 @@ begin end return N end - function FEMBasis.eval_dbasis!{T}(::Type{Tet10}, dN::Matrix{T}, xi::Tuple{T, T, T}) + function FEMBasis.eval_dbasis!(::Type{Tet10}, dN::Matrix{T}, xi::Tuple{T, T, T}) where T (u, v, w) = xi begin dN[1, 1] = -3.0 + 4.0v + 4.0w + 2.0 * (2u) diff --git a/src/create_basis.jl b/src/create_basis.jl index a9d6781..0ce35f4 100644 --- a/src/create_basis.jl +++ b/src/create_basis.jl @@ -101,7 +101,7 @@ function calculate_interpolation_polynomial_derivatives(basis, dim) return equations end -function create_basis{nbasis,dim}(name::Symbol, description::String, X::NTuple{nbasis, NTuple{dim, Float64}}, basis, dbasis) +function create_basis(name::Symbol, description::String, X::NTuple{nbasis, NTuple{dim, Float64}}, basis, dbasis) where {nbasis,dim} Q = Expr(:block) for i=1:nbasis @@ -125,7 +125,7 @@ function create_basis{nbasis,dim}(name::Symbol, description::String, X::NTuple{n end code = quote - type $name <: FEMBasis.AbstractBasis + mutable struct $name <: FEMBasis.AbstractBasis end function Base.size(::Type{$name}) @@ -145,13 +145,13 @@ function create_basis{nbasis,dim}(name::Symbol, description::String, X::NTuple{n return $X end - function FEMBasis.eval_basis!{T}(::Type{$name}, N::Matrix{T}, xi) + function FEMBasis.eval_basis!(::Type{$name}, N::Matrix{T}, xi) where T $unpack $Q return N end - function FEMBasis.eval_dbasis!{T}(::Type{$name}, dN::Matrix{T}, xi) + function FEMBasis.eval_dbasis!(::Type{$name}, dN::Matrix{T}, xi) where T $unpack $V return dN @@ -161,24 +161,24 @@ function create_basis{nbasis,dim}(name::Symbol, description::String, X::NTuple{n return code end -function create_basis{nbasis,dim}(name::Symbol, description::String, X::NTuple{nbasis, NTuple{dim, Float64}}, p::Expr) +function create_basis(name::Symbol, description::String, X::NTuple{nbasis, NTuple{dim, Float64}}, p::Expr) where {nbasis,dim} A = calculate_basis_coefficients(p, X) basis = calculate_interpolation_polynomials(p, A) dbasis = calculate_interpolation_polynomial_derivatives(basis, dim) return create_basis(name, description, X, basis, dbasis) end -function create_basis{nbasis,dim}(name::Symbol, description::String, X::NTuple{nbasis, NTuple{dim, Float64}}, p::String) +function create_basis(name::Symbol, description::String, X::NTuple{nbasis, NTuple{dim, Float64}}, p::String) where {nbasis,dim} create_basis(name, description, X, parse(p)) end -function create_basis{nbasis,dim}(name::Symbol, description::String, X::NTuple{nbasis, NTuple{dim, Float64}}, basis_::NTuple{nbasis, String}) +function create_basis(name::Symbol, description::String, X::NTuple{nbasis, NTuple{dim, Float64}}, basis_::NTuple{nbasis, String}) where {nbasis,dim} basis = [parse(b) for b in basis_] dbasis = calculate_interpolation_polynomial_derivatives(basis, dim) return create_basis(name, description, X, basis, dbasis) end -function create_basis{nbasis,dim}(name::Symbol, description::String, X::NTuple{nbasis, NTuple{dim, Float64}}, basis::NTuple{nbasis, Expr}) +function create_basis(name::Symbol, description::String, X::NTuple{nbasis, NTuple{dim, Float64}}, basis::NTuple{nbasis, Expr}) where {nbasis,dim} dbasis = calculate_interpolation_polynomial_derivatives(basis, dim) return create_basis(name, description, X, basis, dbasis) end diff --git a/src/math.jl b/src/math.jl index 9413494..30122e7 100644 --- a/src/math.jl +++ b/src/math.jl @@ -3,19 +3,19 @@ import Base: length, size -function length{T<:AbstractBasis}(B::T) +function length(B::T) where T<:AbstractBasis return length(T) end -function size{T<:AbstractBasis}(B::T) +function size(B::T) where T<:AbstractBasis return size(T) end -function eval_basis!{T<:AbstractBasis}(B::T, N, xi) +function eval_basis!(B::T, N, xi) where T<:AbstractBasis return eval_basis!(T, N, xi) end -function eval_dbasis!{T<:AbstractBasis}(B::T, dN, xi) +function eval_dbasis!(B::T, dN, xi) where T<:AbstractBasis return eval_dbasis!(T, dN, xi) end @@ -145,7 +145,7 @@ end """ Data type for fast FEM. """ -type BasisInfo{B<:AbstractBasis,T} +mutable struct BasisInfo{B<:AbstractBasis,T} N::Matrix{T} dN::Matrix{T} grad::Matrix{T} @@ -154,11 +154,11 @@ type BasisInfo{B<:AbstractBasis,T} detJ::T end -function length{T<:AbstractBasis}(B::BasisInfo{T}) +function length(B::BasisInfo{T}) where T<:AbstractBasis return length(T) end -function size{T<:AbstractBasis}(B::BasisInfo{T}) +function size(B::BasisInfo{T}) where T<:AbstractBasis return size(T) end @@ -178,7 +178,7 @@ FEMBasis.BasisInfo{FEMBasis.Tri3,Float64}([0.0 0.0 0.0], [0.0 0.0 0.0; 0.0 0.0 0 ``` """ -function BasisInfo{B<:AbstractBasis}(::Type{B}, T=Float64) +function BasisInfo(::Type{B}, T=Float64) where B<:AbstractBasis dim, nbasis = size(B) N = zeros(T, 1, nbasis) dN = zeros(T, dim, nbasis) @@ -207,7 +207,7 @@ FEMBasis.BasisInfo{FEMBasis.Quad4,Float64}([0.25 0.25 0.25 0.25], [-0.25 0.25 0. ``` """ -function eval_basis!{B}(bi::BasisInfo{B}, X, xi) +function eval_basis!(bi::BasisInfo{B}, X, xi) where B # evaluate basis and derivatives eval_basis!(B, bi.N, xi) @@ -303,7 +303,7 @@ grad!(B, gradu, u) 1.0 2.0 ``` """ -function grad!{B}(bi::BasisInfo{B}, gradu, u) +function grad!(bi::BasisInfo{B}, gradu, u) where B dim, nbasis = size(B) fill!(gradu, 0.0) for i=1:dim diff --git a/src/nurbs_segment.jl b/src/nurbs_segment.jl index 66b7843..d5d186c 100644 --- a/src/nurbs_segment.jl +++ b/src/nurbs_segment.jl @@ -2,7 +2,7 @@ # License is MIT: see https://github.com/JuliaFEM/FEMBasis.jl/blob/master/LICENSE """ NURBS segment. """ -type NSeg <: AbstractBasis +mutable struct NSeg <: AbstractBasis order :: Int knots :: Vector{Float64} weights :: Vector{Float64} diff --git a/src/nurbs_solid.jl b/src/nurbs_solid.jl index ab9f80b..3f97d46 100644 --- a/src/nurbs_solid.jl +++ b/src/nurbs_solid.jl @@ -1,7 +1,7 @@ # This file is a part of JuliaFEM. # License is MIT: see https://github.com/JuliaFEM/FEMBasis.jl/blob/master/LICENSE -type NSolid <: AbstractBasis +mutable struct NSolid <: AbstractBasis order_u :: Int order_v :: Int order_w :: Int diff --git a/src/nurbs_surface.jl b/src/nurbs_surface.jl index 9c0e124..e631ccd 100644 --- a/src/nurbs_surface.jl +++ b/src/nurbs_surface.jl @@ -1,7 +1,7 @@ # This file is a part of JuliaFEM. # License is MIT: see https://github.com/JuliaFEM/FEMBasis.jl/blob/master/LICENSE -type NSurf <: AbstractBasis +mutable struct NSurf <: AbstractBasis order_u :: Int order_v :: Int knots_u :: Vector{Float64}