Problems when opening old projects with ElmerGUI

The graphical user interface of Elmer
Post Reply
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Problems when opening old projects with ElmerGUI

Post by mzenker »

Hi,

when opening an old project with ElmerGUI (which happens from time to time), I regularly have two problems:

1. The solver-dependent settings are screwed up when the number and/or selection of solvers in the bin/edf directory has changed since the project was saved the last time. As far as I understand, this is due to the respective tabs not having names, but numbers. In the egproject.xml file all the solver relevant stuff is grouped within item tags:

<item index="0" name="" >
...
</item>
<item index="1" name="" >
...
</item>
etc.

Couldn't the name be used to identify the solvers and avoid the mixing up of the entries?

2. The sif file is recreated and overwritten right away at project load without notice. IMHO this should not be the case. For example, if the sif file had been modified manually, or if the solver settings are screwed up as described above, the old sif file would be lost. I would expect that the sif file is saved only if the user tells ElmerGUI to do so.

It would be a good thing if this behaviour could be improved...

Thank you,

Matthias
iczajka
Posts: 26
Joined: 14 Dec 2009, 13:51
Location: Poland/Kraków
Contact:

Re: Problems when opening old projects with ElmerGUI

Post by iczajka »

I has similar problems:
projects made on my work machine (Ubuntu, binary elmer package),
were screwed when I had opened them at home (or laptop) - hand made elmer compilation.

Common problems are: random changes in ,,Procedure'' names for example: instead Heat Solve, there was 'Flow solve' or electricity.

So, in my opinion, usage of ElmerGUI is limited to ,,prototyping'' analysis. After initial stage, only sif modification are allowed.

BR.
Irek
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Problems when opening old projects with ElmerGUI

Post by mzenker »

Hi Irek,

as a workaround, you can take care that the contents of the bin/edf directory is the same for all your Elmer installations. Then your solver settings should not be screwed.
But as I wrote in my initial post, this problem would be worth to be solved in ElmerGUI IMHO.

Matthias
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Problems when opening old projects with ElmerGUI

Post by mzenker »

Hi,

the problem is still there. I have played around a bit with a test project, and found out the following:

The problem seems to be the parsing of the <solverspecificoptions> section in egproject.xml. It is structured as follows:

Code: Select all

<solverspecificoptions>
      <item index="2" id="2" name="Heat Equation">
         <widget type="CheckBox">
            <key>/Result Output/Solver/Single Precision/1</key>
            <value>0</value>
         </widget>
         <widget type="...">
            <key>...</key>
            <value>...</value>
         </widget>
     </item>
   </solverspecificoptions>
The index and id in the item tag seem to refer to the position of the tab of the first solver with changed specific options, the value starting a 0. In the example above, we have the Heat Equation Solver at the 3rd tab, and it has changed options.
There seems to be a key for every item in the "Solver specific options" tab. It seems to be interpreted not by name, but by alphabetic position. This means that the solver specific options are screwed up if the set of solver xml files (loaded at ElmerGUI startup) changes. In the example above, if a solver is inserted before Heat Equation, the Heat Equation solver will get the "specific options" tab of the solver which is now at the 3rd position. If a solver is inserted after Heat Equation, all solver specific options tabs of the solvers after the new solver will be shifted by one position. In both cases, the last solver will have no solver specific options tab.

Interestingly, the other tabs in the "Solver control" dialog opened by "Edit Solver settings" seem not to be affected, so they seem to be parsed correctly, even though the solver parameters have also an index which depends on the solver set. Here ElmerGUI seems to interpret the name, as one would naively expect. Example:

Code: Select all

<solverparameters>
    ........
    <item index="8" name="Static Current Conduction">
    .......
    </item>
    .......
</solverparameters>
apparently yields the correct result even if Static Current Conduction has position 9 in the solver tabs.

Additionally, as already stated in another thread (viewtopic.php?f=4&t=2113), the corresponding tab is doubled when "load project" is executed more than once. ElmerGUIhas to be restarted to reset this behaviour.

It would be very helpful for those users using ElmerGUI to have these "Solver specific options" bugs fixed. Maybe someone from the Elmer team could at least have a quick look to see how much work it would be... ;)

Thank you,

Matthias
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Problems when opening old projects with ElmerGUI

Post by mzenker »

Update:

Apparently in the solverspecificoptions section there is one item created per active solver. Strangely, each item seems to contain entries for all solvers.
So it might be enough to have the solverspecificoptions section parsed similarly to the other section, e.g. solverparameters. Maybe there is just a small bug (which I would be unable to find in a finite time)...

Matthias
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Problems when opening old projects with ElmerGUI

Post by mzenker »

Hi,

as I have just updated my Elmer and want to reuse my projects from the previous version, I have made a script converting ElmerGUI projects so that they can be loaded for a changed solver configuration. The script runs under Scilab, but can be easily converted to Matlab, (g)awk or perl, for example. It reads a file containing the solvers (in ELMERHOME/bin/edf) in the right order and adjusts the index in the solverspecificoptions section of egproject.xml so that they match with the actual order in ElmerGUI.
Firsts test have shown that the script seems to do what it should, and that this way ElmerGUI projects can be converted to be used with a changed solver set in ElmerGUI.

Here is the script:

Code: Select all

function Convert_Elmerproject()

  solver_mat = excel2sci('ElmerGUISolvers.txt')
  
  project_file = tk_getfile('egproject.xml')
  idx = strindex(project_file,'/') 
  if idx ~= [] then
    path = part(project_file,[1:idx($)])
    cd(path)
    project_file = part(project_file,[idx($)+1:length(project_file)])
  else
    path = []
  end
  
  err = unix('rename ' + project_file + ' ' + project_file + '.bak')
  
  if err ~= 0 then
    error('renaming of ' + project_file + ' failed')
  end
    
  fid_old = mopen(project_file + '.bak', 'r')
  fid_new = mopen(project_file, 'w')
  
  tline = mgetl(fid_old, 1)

  while ~meof(fid_old)

    if (strindex(tline, 'item index=') ~= []) & (strindex(tline, 'id=') ~= []) & (strindex(tline, 'name=')) then
      quote_idx = strindex(tline,'""')
      item = part(tline, [quote_idx(1)+1 : quote_idx(2)-1])
      id = part(tline, [quote_idx(3)+1 : quote_idx(4)-1])
      ind = strindex(tline, '<')-1
      solver_name = part(tline, [quote_idx(5)+1 : quote_idx(6)-1])
//      printf('item %s  id %s  name %s\n',item, id, solver_name)
      index_new = -1
      for i = 1:size(solver_mat,1)
        if solver_name == solver_mat(i) then
          index_new = i-1
        end
      end
      if index_new == -1 then
        error('Solver ' + solver_name + ' not found')
      end
      tline = sprintf('%s<item index=""%i"" id=""%i"" name=""%s"">', part(tline,[1:ind]), index_new, index_new, solver_name)
    end
    mfprintf(fid_new, '%s\n', tline)

    tline = mgetl(fid_old, 1)

  end

  mclose(fid_old)
  mclose(fid_new)

endfunction
And here is ElmerGUISolvers.txt (in case of all currently available solver xml files being loaded - has to be adapted to individual configuration):

Code: Select all

Advection Diffusion Equation
Divergence
Elastic Plates
Electrostatics
Flux and Gradient
Free Surface
Heat Equation
Helmholtz Equation
K-Epsilon
Linear elesticity
Mesh Update
Navier-Stokes
Nonlinear elasticity
Poisson-Boltzmann equation
Result Output
Reynolds Equation
Richards Equation
SaveLine
SaveScalars
Static Current Conduction
Vorticity
Maybe this helps someone.

Matthias

EDIT: There was a small bug in the script which is now fixed (Error in case of first solver in the row).
Post Reply