ElmerGUI flattens geometry, CAD, and other related files

The graphical user interface of Elmer
Post Reply
hazelsct
Posts: 153
Joined: 05 Oct 2009, 17:02
Location: Boston, MA, USA
Contact:

ElmerGUI flattens geometry, CAD, and other related files

Post by hazelsct »

Hi,

I've been noticing that from time to time my geometry, CAD, and other files in my Elmer simulation directory get flattened, i.e. become zero-byte files. I finally got some time last week to track this down, and it looks like it is in ElmerGUI/Application/src/mainwindow.cpp lines 1533-1559:

Code: Select all

  // Avoid copying file(s) into it self:

  if( g_path  != p_path ) {
    [open src and dst, and copy contents from src to dst]
  } else {
    logMessage("Geometry input file(s) not copied");
  }
Trouble is, even when g_path is the same as p_path, the != comparison often returns true, copying the files to themselves. And of course opening dst creates a zero-length file, destroying src. I am not seeing the "not copied" log message. When I insert a logMessage before the conditional to print g_path and p_path, they print identically. And when I put a logMessage in the "true" part of the conditional, it prints, indicating that it enters the copying loop. And it doesn't just do this for the geometry file, but for all files with the same basename, so the original CAD or gmsh .geo file gets flattened and I need to start absolutely from scratch.

Why does Elmer try to copy these files? And if you really want to copy the geometry files, e.g. .stp or .msh, do you really need to copy everything with the same basename, when Elmer can't read .geo or .fcstd etc.? And if you really want to copy all of the files, isn't there a better way, e.g. using a system file copy command which returns an error if the files are the same, instead of reading the contents from one file to the other and flattening them by accident?

This is on Ubuntu 10.04. For my own purposes, I'm commenting this whole section for now.

-Adam
mal
Site Admin
Posts: 54
Joined: 21 Aug 2009, 14:21

Re: ElmerGUI flattens geometry, CAD, and other related files

Post by mal »

Hello Adam,

I have commited some changes, hope it works better now.
hazelsct wrote: Why does Elmer try to copy these files?
The idea is to include all relevant files in the same project directory, including the geometry input file or files.

The geometry input file(s) are needed e.g. for remeshing with modified meshing parameters.
And if you really want to copy the geometry files, e.g. .stp or .msh, do you really need to copy everything with the same basename, when Elmer can't read .geo or .fcstd etc.?
The copying is done for the base name (basename.*) since it is possible that there are several geometry input files.

For example, some of the input formats for Tetgen may require multiple files with the same base and different suffix.
And if you really want to copy all of the files, isn't there a better way, e.g. using a system file copy command which returns an error if the files are the same, instead of reading the contents from one file to the other and flattening them by accident?
That would be possible, and perhaps even better, but relying on system calls would result in non-portable code with several #ifdefs for different operating systems.

Regards,
Mikko
hazelsct
Posts: 153
Joined: 05 Oct 2009, 17:02
Location: Boston, MA, USA
Contact:

Re: ElmerGUI flattens geometry, CAD, and other related files

Post by hazelsct »

Thanks for your answers, I understand the requirements better now. Are there wrappers for system calls in Qt or other portable libraries?

I can't imagine I'm the only one encountering this problem. This will always break when there are two or more paths to a given file or directory, e.g. symlinks/shortcuts. I'm considering disabling it for Debian's packages, because causing data loss is a very serious bug.

-Adam
mal
Site Admin
Posts: 54
Joined: 21 Aug 2009, 14:21

Re: ElmerGUI flattens geometry, CAD, and other related files

Post by mal »

Ok, thanks, perhaps I understand the problem a little better now.

There is now a separate block for Q_OS_LINUX that uses "cp -f" for copying the geometry input files to the project directory.

Is this what you were looking for?

BR,
Mikko
hazelsct
Posts: 153
Joined: 05 Oct 2009, 17:02
Location: Boston, MA, USA
Contact:

Re: ElmerGUI flattens geometry, CAD, and other related files

Post by hazelsct »

Wow, thanks very much Mikko, that's a big change! I'll test it later today.

-Adam
Post Reply