FreeFem / FreeFem-sources

FreeFEM source code
https://freefem.org/
Other
755 stars 188 forks source link

savemesh not working for 3D, script execution (.edp file) aborted on savemesh #239

Open newcode3000 opened 1 year ago

newcode3000 commented 1 year ago

I use the FreeFEM++ version with install file name: FreeFem++-4.11-win64-petsctest.exe My system is: Windows 10 Pro with AMD Ryzen 9, 64 GB RAM.

It seems that savemesh is generally not working for me with 3D meshes (2D seems to work). E.g. I have the following script (.edp file):

verbosity = 999999;

load "msh3"

int[int] l6 = [37, 42, 45, 40, 25, 57];
int r11 = 11;
mesh3 Th = cube(2, 2, 2, label=l6, flags=3, region=r11);
savemesh(Th, "E:/test.mesh");

cout << "****************************************************\n";
cout << "******** Reached the command after savemesh ********\n";
cout << "****************************************************\n";

When executing savemesh with a 3D mesh, a file with 0 bytes (empty) is created, but the execution of the script is aborted (commands after the savemesh() are not executed). The full output for this example script is here: output.txt

The last lines of the output is the following:

B 44 ###  item(k,i)=  17 23 26 a=  17 23 26
B 45 ###  item(k,i)=  17 25 26 a=  17 25 26
B 46 ###  item(k,i)=  22 25 26 a=  22 25 26
B 47 ###  item(k,i)=  16 17 25 a=  16 17 25
  -- BuildAdj:0x244af8a8830 nb Elememt 48 nb vertices 27
             : nb adj  = 120 on border 48 nea = 4 nva = 3 nb no manifold border 0

    ~HashTable:   Cas moyen : 2.11667
 number of real boundary element 48
  GTree: box: 0 0 0 1 1 1 -0.5 -0.5 -0.5 1.5 1.5 1.5 nbv : 27
MaxISize 1073741824
  -- End of read: mesure = 1 border mesure 6
      timers Mesh3 :0 0 0 0 0
 cube timers 0.003 0.001   Mesh3  0
StackOfPtr2Free: clean 0x244af886bd0 
SaveMesh3 E:/test.mesh 0x244af8a8830

You can see that the cout << "**** Reached the command after savemesh ****\n"; is not called. Maybe some runtime exception is thrown.

I try the same script, but with the savemesh() commented out:

verbosity = 999999;

load "msh3"

int[int] l6 = [37, 42, 45, 40, 25, 57];
int r11 = 11;
mesh3 Th = cube(2, 2, 2, label=l6, flags=3, region=r11);
//savemesh(Th, "E:/test.mesh");

cout << "****************************************************\n";
cout << "******** Reached the command after savemesh ********\n";
cout << "****************************************************\n";

I call it from a Windows command line. Some error is printed out in the command line window rather than in the file output2.txt:

E:\>test.edp > output2.txt

E:\>terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

The output (file output2.txt) is here: output2.txt

The last lines in output2.txt are:

B 44 ###  item(k,i)=  17 23 26 a=  17 23 26
B 45 ###  item(k,i)=  17 25 26 a=  17 25 26
B 46 ###  item(k,i)=  22 25 26 a=  22 25 26
B 47 ###  item(k,i)=  16 17 25 a=  16 17 25
  -- BuildAdj:0x1d7f67c97f0 nb Elememt 48 nb vertices 27
             : nb adj  = 120 on border 48 nea = 4 nva = 3 nb no manifold border 0

    ~HashTable:   Cas moyen : 2.11667
 number of real boundary element 48
  GTree: box: 0 0 0 1 1 1 -0.5 -0.5 -0.5 1.5 1.5 1.5 nbv : 27
MaxISize 1073741824
  -- End of read: mesure = 1 border mesure 6
      timers Mesh3 :0 0.001 0 0 0
 cube timers 0.003 0   Mesh3  0.001
StackOfPtr2Free: clean 0x1d7f67a6770 
****************************************************
StackOfPtr2Free: clean 0x1d7f67a67b0 
******** Reached the command after savemesh ********
StackOfPtr2Free: clean 0x1d7f67a6c10 
****************************************************
StackOfPtr2Free: clean 0x1d7f67a6c50 
 ListOfInst::atclose()  7 2 // 2
 eval vectorOfInst 0 2
destroy mesh30x1d7f67c97f0 destroy meshS 0
times: compile 0.005s, execution 0.004s,  mpirank:0
 ######## We forget of deleting   8 Nb pointer,   0Bytes  ,  mpirank 0, memory leak =0
 CodeAlloc : nb ptr  3784,  size :510760 mpirank: 0
Ok: Normal End
 try getConsole E:\test.edp

This looks better (possibly only a memory leak, but no serious exception). The cout << "**** Reached the command after savemesh ****\n"; is called.

Has anybody suggestions ?