JuliaFEM / FEMBasis.jl

FEMBasis contains interpolation routines for finite element function spaces. Given ansatz and coordinates of domain, shape functions are calculated symbolically in a very general way to get efficient code. Shape functions can also be given directly and in that case partial derivatives are calculated automatically.
https://juliafem.github.io/FEMBasis.jl/latest
MIT License
14 stars 12 forks source link

Perhaps stop punning on Base functions? #26

Open KristofferC opened 6 years ago

KristofferC commented 6 years ago

FEMBasis does some "puns" on Base functions, for example:

        function Base.size(::Type{$name})
            return ($D, $N)
        end

        function Base.size(::Type{$name}, j::Int)
            j == 1 && return $D
            j == 2 && return $N
        end

        function Base.length(::Type{$name})
            return $N
        end

length is typically defined for collections (or at least when the instance of the type is a collection). AbstractBasis is not iterable and it probably shouldn't be. Instead of defining these functions I think they should have their own names ndim, nbasis. Overloading Base functions are typically meant so you can write generic code but there is no way to write generic code with puns like this.

KristofferC commented 6 years ago

Another thing is that length(...) is usually the same as prod(size(...)) which this breaks.

TeroFrondelius commented 6 years ago

Ok. This needs to change. Do you have a proposal or an idea how to change?

ahojukka5 commented 6 years ago

Yes, we could do this somehow differently. This convention originates from the need to know proper dimensions of workspace when evaluating e.g. basis functions.