victorsndvg / FEconv

Program feconv is an utility to convert between several mesh and FE field formats, like ANSYS mesh files (.msh), MD Nastran input files (.bdf), I-Deas Universal (.unv), VTK files (.vtk), etc. If you use a Modulef format to store an intermediate mesh (.mfm). It can transform the FE type of a mesh composed of trangles or tetrahedra, to Lagrange P1 or P2, Raviart-Thomas (face) or Whitney (edge) finite elements. It also uses third-party code to perform bandwidth optimization (CutlHill-McKee optimization).
GNU General Public License v3.0
96 stars 26 forks source link

Ansys mesh examples file give segfault #12

Open mattfil opened 10 months ago

mattfil commented 10 months ago

Thank you for the nice library. I am in Windows with Msys2, with mingw64 terminal. The version of the gcc toolchain is the 13.2.0 https://packages.msys2.org/base/mingw-w64-gcc. I compiled feconv through the command: mingw32-make.exe -f Makefile.gfortran.linux and the compilation seems ok. I've tryed some of the examples in the folder and the conversion works, but it seems for all the cases where the input file is an Ansys .msh the conversion fails with a segfault. For example:

$ ./feconv examples/ansys_mesh.msh output.unv Space dimension: 3 Reading zone 1: Vertex Reading zone 2: Triangle, Lagrange P1 Reading zone 3: Tetrahedron, Lagrange P1

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:

0 0x99d01d81

1 0x99cf4f03

2 0x99cd25a1

3 0x2f6db247

4 0x3191441e

5 0x3188e465

6 0x3191340d

7 0x99badd4a

8 0x99bb2e79

9 0x99c017cc

10 0x99c023c7

11 0x99c4c480

12 0x99ab7fdc

13 0x99ab8021

14 0x99ab12ed

15 0x99ab1405

16 0x2fc1257c

17 0x318caa57

18 0xffffffff

Any clue why this happen?

Thank you, Mattia

fran-pena commented 10 months ago

Sorry, we have not tested FEconv with mingw-w64 in Windows, we just use MinGW (https://osdn.net/projects/mingw/).

Best, Fran

AlirezaNewTwen commented 10 months ago

Dear Fran,

I am currently using Ubuntu 22.04.2 LTS, and I have successfully compiled the code without any issues. However, when attempting to run the provided example "./feconv examples/ansys_mesh.msh output.unv," I encountered an error. It's worth noting that the tool works well with other file formats, and this issue seems specific to Ansys .msh files.

Details:

The error manifests with a segmentation fault. I appreciate any guidance on resolving this issue or insights into potential compatibility problems with Ansys .msh files.

Thank you,

fran-pena commented 10 months ago

@mattfil I have installed mingw-w64 in Windows and I can reproduce your error. I will study why it happens.

By the way, I have installed mingw-w64 thru a MSYS2 installation, so I have to execute commands in a MSYS2 UCRT64 Shell, not a Windows Command (CMD), so I choose Makefile.gfortran.linux to compila. Do you know a way to install mingw-w64 in Windows and use it from a CMD?

mattfil commented 10 months ago

@fran-pena , I am not sure this can be done, what you can do is to use a CMD to open msys2 shells... btw, from backtrace the segfault seem to be in module_utils_msh.f90 routine "nodes_not_in_cell", but I guess you have already found that.

fran-pena commented 10 months ago

@AlirezaNewTwen Unfortunately, I do not have your Linux platform. What I have is:

CentOS Linux release 8.5.2111 (Core) GNU Fortran (GCC) 7.3.0 GNU Make 3.82

The command './feconv examples/ansys_mesh.msh o.unv' gives a correct output: Space dimension: 3 Reading zone 1: Vertex Reading zone 2: Triangle, Lagrange P1 Reading zone 3: Tetrahedron, Lagrange P1

I will study the problem for MinGW first.

Best, Fran

AlirezaNewTwen commented 10 months ago

Thank you for your answer, this is what I received with the same command:

Program received signal SIGSEGV, Segmentation fault. 0x00000000004fa2f4 in __module_utils_msh_fcnv_MOD_nodes_not_in_cell () (gdb) bt

0 0x00000000004fa2f4 in __module_utils_msh_fcnv_MOD_nodes_not_in_cell ()

1 0x00000000004fefd5 in __module_utils_msh_fcnv_MOD_build_cells ()

2 0x000000000054d65d in __module_manage_msh_fcnv_MOD_read_msh ()

3 0x000000000054e268 in __module_msh_fcnv_MOD_load_msh ()

4 0x0000000000598a6b in __module_feconv_MOD_convert ()

5 0x000000000040a7c7 in MAIN__ ()

best

fran-pena commented 10 months ago

@mattfil and @AlirezaNewTwen I just have updated master branch. Please, check in your platforms whether or not this update fixes your problem.

mattfil commented 10 months ago

Ok now the example projects seem to work. I still see an issue with an Ansys msh file that you can find attached when I try to convert it to vtu. In particular something happens at line 442 in module_vtu.f90 when i=1 and j=3:
temp(:,:) = reshape(pc%el(j)%mm-1, [1, pc%el(j)%nel*lnv]) where an array of size 3,8000 is being reshaped onto an array with size 1,31440, leading to a segfault. try.zip