Closed rafaqz closed 3 years ago
Ok. I'm going to change nstep
accordingly in my PR.
The link between type of element within grid and type of nstep
wasn't obvious. I understand the multiplication of Float32
with Float64
would result in Float64
so you have to make sure nstep
is also Float32
.
Would it be simpler for the user to set something like: eltype(grid)(rule.nstep)
?
Here are the check I've done to understand:
julia> a = Float32(4)
4.0f0
julia> b = Float64(4)
4.0
julia> typeof(a*b)
Float64
julia> typeof(a*eltype(a)(b))
Float32
@virgile-baudrot exactly - you would end up with Float64
.
The problem is its calculated in precalcrule
for multiple rules using the same method, and we don't really know what grid it will be used with at that point.
I was trying to avoid every rule that uses nsteps
having to do that eltype(a)(rule.nsteps)
conversion. But maybe that method is actually cleaner as the responsibility is on the package, not the user.
This actually can't work, because the grids can be other types:
eltype(grid)(rule.nstep)
So I think I'm back to the original idea now.
Description
This PR makes some small changes to growth
nsteps
precalculation. The main reason was that it was not type-stable inFloat32
because there was no way of setting the type ofnsteps
. Now instead of being able to set nsteps at all, (which doesn't make sense, it's precalculated for every frame)) you can use the keywordnsteps_type
to set the type toFloat32
if you need the performance.Also renamed the
precalc_timestep
method toprecalc_nsteps
, asnsteps
is precalculated, and thetimestep
is fixed.It shouldn't be breaking syntax as no constructors should have been setting
nsteps
before anyway, as it did nothing.Changes:
Checklist:
For bugfixes
For new
Rule
s/test/newrulename.jl