I'd like to use a user functions (either fortran or lua) to define the "Timestep sizes" and "Timestep intervals" arrays based on the the values of M, N, and there respective timesteps (say M_dt and N_dt, respectively). The variables M, N, M_dt and N_dt are all subject to change. I'd actually like to do some kind of grid-search across these to determine the most appropriate for my application. That's why I'd like to use a user function to define the corresponding arrays in a programmatic way.
I'm aware of the distinction between "Timestep sizes" and "Timestep size", the latter accepting a time dependent function. That doesn't really seem like what I need; apriori I know the arrays based on the parameter values I just need a function to create the array. More importantly; I later use "Exec Interval" and "Timestep Scale" keywords to execute solvers at different intervals, where the exec intervals themselves change with the different timesteps (M_dt v.s. N_dt). The "Timestep Scale" will also change based timestep, so this also will need an array or function.
I've started with a fortran function to attempt this with;
Code: Select all
Simulation
Coordinate System = "Cartesian 2D"
Simulation Type = "Transient"
Timestepping Method = "BDF"
BDF order = 2
Steady State Min Iterations = 1
Steady State Max Iterations = 10
Timestep Sizes(20) = Variable #gravity
real Procedure "../../bin/SlipCoefficent" "get_timestep_sizes"
Timestep Intervals(20) = Variable #gravity
integer Procedure "../../bin/SlipCoefficent" "get_timestep_intervals"
Code: Select all
LoadInputFile: Number of BCs: 4
LoadInputFile: Number of Body Forces: 2
LoadInputFile: Number of Initial Conditions: 2
LoadInputFile: Number of Materials: 2
LoadInputFile: Number of Equations: 2
LoadInputFile: Number of Solvers: 12
LoadInputFile: Number of Bodies: 2
At line 183 of file SlipCoefficent.f90
Fortran runtime error: Attempting to allocate already allocated variable 'timestep_intervals'
Error termination. Backtrace:
#0 0x7f6e84297d21 in ???
#1 0x7f6e84298869 in ???
#2 0x7f6e84298ee6 in ???
#3 0x7f6e8063a5df in get_timestep_intervals_
at /home/glacier/shared_directory/Thesis/thermal-structure/src/elmer_src/SlipCoefficent.f90:183
#4 0x7f6e845b2750 in __lists_MOD_listgetintegerarray
at /home/glacier/elmerice/fem/src/Lists.F90:3165
#5 0x7f6e84a29716 in initializeintervals
at /home/glacier/elmerice/fem/src/ElmerSolver.F90:675
#6 0x7f6e84a35e07 in elmersolver_
at /home/glacier/elmerice/fem/src/ElmerSolver.F90:468
#7 0x556e137a43cd in solver
at /home/glacier/elmerice/fem/src/Solver.F90:57
#8 0x556e137a413e in main
at /home/glacier/elmerice/fem/src/Solver.F90:34
Is something along the lines of what I'd like possible? Do the arrays need to be assigned to variables somewhere before, say in the preamble or constants section? If so, is that possible with a fortran user function? I'd ideally use fortran for this, since I'd like to read the parameters of M, N, M_dt and N_dt from the constants section, which doesn't seem to be a functionality available from lua.
Hopefully this is clear. Thanks for your time. I'd be happy to share anything that'd be useful for figuring this out.