LHEEA/meshmagick

Converting a mesh file

Opened this issue · 7 comments

Dear All,

I am using Meshmagick to convert a mesh file (preferably from Salome) into .dat for use with Nemoh and am following the user's guide, but I found the problems below.

This line worked fine.
meshmagick SEAREV.vtp -o SEAREV.mar

And I got the converted file
C:\Windows\System32\meshmagick>meshmagick SEAREV.vtp -o SEAREV.mar

=============================================
meshmagick - version 3.4
Copyright 2014-2023, Ecole Centrale de Nantes / D-ICE Engineering_
=============================================
SEAREV.vtp successfully loaded
Writing SEAREV.mar
WARNING: if you described only one part of the mesh using symmetry for Nemoh, you may manually modify the file header accordingly
-> Done.

=============================================================
Meshmagick - version 3.4
Copyright 2014-2023, Ecole Centrale de Nantes / D-ICE Engineering
Maintainer : Francois Rongere Francois.Rongere@dice-engineering.com
Good Bye!
=============================================================

However, when I ran the following line, error popped up. I completely have no idea about what is going wrong, and I have also tried to convert other types of mesh, but ended in failure with the same error.

meshmagick SEAREV.vtp -ifmt paraview SEAREV.vtp -ofmt nemoh SEAREV.dat

C:\Windows\System32\meshmagick>meshmagick SEAREV.vtp -ifmt paraview SEAREV.vtp -ofmt nemoh SEAREV.dat
usage: meshmagick [-h] [-o OUTFILENAME] [-ifmt INPUT_FORMAT] [-ofmt OUTPUT_FORMAT] [-q] [-i] [--quality] [-t Tx Ty Tz] [-tx Tx]
[-ty Ty] [-tz Tz] [-r Rx Ry Rz] [-rx Rx] [-ry Ry] [-rz Rz] [-s S] [-sx Sx] [-sy Sy] [-sz Sz] [-hn] [-fn] [-hm]
[-p Arg [Arg ...]] [-c [Arg ...]] [-cc CONCATENATE_FILE] [-md [Tol]] [-tq] [-sym [Arg ...]]
[--mirror Arg [Arg ...]] [-pi] [-si] [--rho-medium RHO_MEDIUM] [--list-medium] [--thickness THICKNESS]
[-pn Project Name] [-hs] [-mdisp Disp] [-cog Xg Yg Zg] [-zg Zcog] [-lpp Lpp] [-ap] [-wd Rho] [-g G]
[--hs-report filename] [-lid [Arg ...]] [-mesh_size MESH_SIZE] [-sh] [-v]
infilename
meshmagick: error: unrecognized arguments: SEAREV.vtp SEAREV.dat

To convert .dat mesh file from salome:

meshmagick Mesh.dat -ifmt salome Mesh.dat -ofmt nemoh Mesh_new.dat

C:\Windows\System32\meshmagick>meshmagick Mesh.dat -ifmt salome Mesh.dat -ofmt nemoh Mesh_new.dat
usage: meshmagick [-h] [-o OUTFILENAME] [-ifmt INPUT_FORMAT] [-ofmt OUTPUT_FORMAT] [-q] [-i] [--quality] [-t Tx Ty Tz] [-tx Tx]
[-ty Ty] [-tz Tz] [-r Rx Ry Rz] [-rx Rx] [-ry Ry] [-rz Rz] [-s S] [-sx Sx] [-sy Sy] [-sz Sz] [-hn] [-fn] [-hm]
[-p Arg [Arg ...]] [-c [Arg ...]] [-cc CONCATENATE_FILE] [-md [Tol]] [-tq] [-sym [Arg ...]]
[--mirror Arg [Arg ...]] [-pi] [-si] [--rho-medium RHO_MEDIUM] [--list-medium] [--thickness THICKNESS]
[-pn Project Name] [-hs] [-mdisp Disp] [-cog Xg Yg Zg] [-zg Zcog] [-lpp Lpp] [-ap] [-wd Rho] [-g G]
[--hs-report filename] [-lid [Arg ...]] [-mesh_size MESH_SIZE] [-sh] [-v]
infilename
meshmagick: error: unrecognized arguments: Mesh.dat Mesh_new.dat

When I ran the first line through Git Bash, there was also an error, though both meshmagick SEAREV.vtp -i and meshmagick SEAREV.vtp --quality worked fine.
$ meshmagick SEAREV.vtp -o SEAREV.mar

=============================================
meshmagick - version 3.4
Copyright 2014-2023, Ecole Centrale de Nantes / D-ICE Engineering
=============================================
SEAREV.vtp successfully loaded
Writing SEAREV.mar
Traceback (most recent call last):
File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python311\Scripts\meshmagick-script.py", line 33, in
sys.exit(load_entry_point('meshmagick', 'console_scripts', 'meshmagick')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\windows\system32\meshmagick\meshmagick_cli.py", line 1021, in main
mmio.write_mesh(args.outfilename, mesh.vertices, mesh.faces, format)
File "c:\windows\system32\meshmagick\meshmagick\mmio.py", line 1124, in write_mesh
writer(filename, vertices, faces)
File "c:\windows\system32\meshmagick\meshmagick\mmio.py", line 1633, in write_MAR
ofile = open(filename, 'w')
^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: 'SEAREV.mar'

Any help would be appreciated. Thanks.

Regards,
Zander

meshmagick SEAREV.vtp -ifmt paraview SEAREV.vtp -ofmt nemoh SEAREV.dat

In your command, the input file SEAREV.vtp is given twice and the output file is not labelled with -o.
What about something like the following (untested)?

meshmagick -ifmt paraview -ofmt nemoh -o SEAREV.mar SEAREV.vtp

All arguments are preceded with a - label except for the input file.

Not sure what is going on with the GitBash issue.

Thank you Mancellin.

It is an example command given in the user's guide. I tested the command you suggested, and it did not work out (OSError: Extension ".paraview" is not known), unfortunately.

I am really confused, other example commands work well, but this one does not.

Indeed. According to the reference list of supported formats, the keyword paraview is not associated with any kind of file. You should either use the keyword vtp instead or trust meshmagick to recognize the .vtp file extension.

This example from the documentation looks wrong to me, but maybe I'm missing something.

Indeed. According to the reference list of supported formats, the keyword paraview is not associated with any kind of file. You should either use the keyword vtp instead or trust meshmagick to recognize the .vtp file extension.

This example from the documentation looks wrong to me, but maybe I'm missing something.

You are right. It did the conversion successfully when I removed the keyword paraview. I used the following command:

meshmagick SEAREV.vtp -ifmt vtp -ofmt nemoh -o SEAREV.dat

I kept nemoh because I would like to have the .dat file of Nemoh format, and it worked (though I am not sure whether the conversion is correct). The strange thing is that it does not work if I replace nemoh with dat (which is the extension of the output file), i.e., meshmagick SEAREV.vtp -ifmt vtp -ofmt dat -o SEAREV.dat.

I kept nemoh because I would like to have the .dat file of Nemoh format, and it worked (though I am not sure whether the conversion is correct). The strange thing is that it does not work if I replace nemoh with dat (which is the extension of the output file), i.e., meshmagick SEAREV.vtp -ifmt vtp -ofmt dat -o SEAREV.dat.

According to the documentation page I linked above, the keyword for Nemoh format is either nemoh or mar, but not dat (although the file has commonly the extension .dat).

dear @mancellin @zanderder
image
image
image
can you help me to check why the file is not work?

@XinmengZeng
In your first example, you give:

  • gmsh as input format (-ifmt flag)
  • nemoh as output format (-ofmt flag)
  • oc4.msh as output file (-o flag)
  • oc4.dat as input file (no flag)

so the code is probably failing because the input file is not in the input format.

In your second example, you give:

  • gmsh as input format (-ifmt flag)
  • oc4.msh as input file (no flag)
  • nemoh as output format (-ofmt flag)
  • oc4.dat as input file (no flag)

so the code is confused because there are two input files.

Your last example looks good to me:

  • oc4.msh as input file (no flag)
  • gmsh as input format (-ifmt flag)
  • nemoh as output format (-ofmt flag)
  • oc4.dat as output file (-o flag)

It is failing because you are missing the gmshparser library that can be installed with pip install gmshparser.

@frongere Should gmshparser be added to setup.py?