a note on code efficiency

Discussion about coding and new developments
Post Reply
spacedout
Posts: 177
Joined: 30 Mar 2020, 23:27
Antispam: Yes

a note on code efficiency

Post by spacedout »

I am looking at Fig 18.5 in ElmerSolverManual.pdf It strikes me that ElmerSolver will call the solver subroutine every time step for a transient simulation and therefore the same .sif file will be inspected every timestep before the nonlinear iteration loop. Wouldn't it be faster to scan that configuration file only once ? In other words, before the first timestep. Again, bear with me. I am just a neophyte. Please be so kind as to put me back on the right track if I happen to be sailing adrift.
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: a note on code efficiency

Post by raback »

Hi

Sif file is inspected once at the start of the simulation. From the sif file + mesh files the real structures are created.

You do however correctly observe that each module (aka Solver) is really called separately for each timestep. The time spent just for calling is insignificant. What can be questioned whether it makes sense to create the matrices anew every timestep and whether it makes sense to call the user defined functions for each element. Usually in Elmer we make no assumptions of constant coefficients and hence by default everything is computed again. Working with real-world multiphysics cases our philosophy has been that assume nothing. Any coefficient can be constant, dependence table, mathematical MATC/LUA expression or user defined function. This generality has served us well.

In cases where you really have constant matrices it is easy to save them from previous timestep. Many modules have a feature where by request you can skip the reassembly of the matrices

-Peter
spacedout
Posts: 177
Joined: 30 Mar 2020, 23:27
Antispam: Yes

Re: a note on code efficiency

Post by spacedout »

Very well.
I should have known better - that the entire structure was copied from the .sif file to ram memory. And of course the amount of time spent scanning strings from memory pales by comparison with the time spent doing number crunching (floating point arithmetic).
Have a great day
Marc
Post Reply