String with time dependance

General discussion about Elmer
Post Reply
Posts: 3
Joined: 26 Apr 2023, 17:40
Antispam: Yes

String with time dependance

Post by robelino »

Hi there,

I am currently doing a transient simulation of a glacier with 60 timesteps of 1 year.
I defined the year of reference (1958) and extract the results at different timesteps (1959, 1969, 1980, 1990, 1999, 2017).

Code: Select all

  Coordinate System  =  Cartesian 3D 

! Transient simulation
  Simulation Type = Transient
  Timestepping Method = "bdf"
  BDF Order = 2

  Timestep Intervals(6) = 1 10 11 10 9 18
  Output Intervals(6) = 1 1 1 1 1 1 1
  Timestep Sizes(1) = 1

  Extruded Mesh Levels = Integer 10
  Extruded Mesh Ratio = Real 2.0

  Steady State Max Iterations = 1
  Steady State Min Iterations = 1

  Post File = "#year#.vtu"

  Restart File = "../INIT/OUTPUT/RUN_0_.result"
  Restart Position = 0
  Restart Time = Real 1958
  Restart Before Initial Conditions = Logical True 

  max output level = 4
Now, I want to make a time dependence with the name of my VTU file at each output intervals ("1959.vtu", "1969.vtu", etc...) as well as my netCDF files ("", "", etc...) that I am saving at each output interval.

Code: Select all

Solver 9
  Exec Solver = After Saving

  Equation = SaveGrid
  Procedure = "SaveGridData" "SaveGridData"

  Filename Prefix  = File "Grid_#year#"

 ! Results will be saved only on the top boundary where MaskSurf=Logical True
  Mask Name = String "MaskSurf"

  Check for Duplicates = Logical True

 ! We don't need a z-coordinate
  Suppress Extra Dimension = Logical True

  Single Precision = Logical True

 !Grid definition 
 ! same grid as basal.tif
  Grid Origin At Corner = Logical True
  Min Coordinate 1 = Real 647830.67578125
  Max Coordinate 1 = Real 652120.67578125
  Min Coordinate 2 = Real 7535416.9921875
  Max Coordinate 2 = Real 7537846.9921875

!Number of gridspace (Dim-1)
  Grid nx = Integer 429
  Grid ny = Integer 243

 !Variables to be saved
  Scalar Field 1 = String "surface"
  Scalar Field 2 = String "bed"
  Scalar Field 3 = String "thickness"
  Scalar Field 4 = String "bottom Copt"
  Scalar Field 5 = String "mass balance"

  Vector Field 1 = String "Velocity"
  Vector Field 2 = String "int Velocity"
  Vector Field 3 = String "bottom Velocity"

  NetCDF Format = Logical True
I tried to create a LUA parameter "year" which takes the value of the year, but it didn't works.

Thanks in advance for your help,
Posts: 2419
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: String with time dependance

Post by kevinarden »

not sure if you can put variable names in quotes, quotes usually mean to take it literally

Filename Prefix = File "Grid_#year#"

it would be more like

Filename Prefix = File "Grid"#year#


Filename Prefix = File "Grid" + #year

you need to concatenate strings
Site Admin
Posts: 4855
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland

Re: String with time dependance

Post by raback »


Only "Real" type in the sif file can be a function of things. So this works only when reading in assuming that you have defined a value #year for the LUA variable.

If the year needs to change by time you should do something else. The VTU output has had the keyword

Code: Select all

Fileindex offset = integer 
that can be handy when you want to continue simulation. I just added

Code: Select all

Fileindex step = integer
that could be used if you want numbering separated by other than 1. Its in "devel" branch since few minutes but only applies to VTU output.

You could do the renaming by some script too.

Posts: 431
Joined: 24 Aug 2009, 20:18

Re: String with time dependance

Post by Rich_B »


For testing purposes, the test 'ParticleElstat' uses SaveGridData. If posting the actual subject project isn't practical, then posting a modified version of the above test will be helpful.

Post Reply