lheea / meshmagick Goto Github PK
View Code? Open in Web Editor NEWA command line tool and a python package to manipulate hydrodynamics meshes
License: GNU General Public License v3.0
A command line tool and a python package to manipulate hydrodynamics meshes
License: GNU General Public License v3.0
On the current master branch (tag 1.0.5), meshmagick/tests/test_IO.py
is failing in load_DAT
.
It was successful in the previous tagged version 1.0.4.
This issue relates exactly to #7 . I am having the same issue and would like to work around it. I am also using fully submerged body and have dug into the error a bit. When the hydrostatics class is initialized, it splits the full mesh into the lower portion and the 'clipped mesh' (crown mesh) that represents the portion of the body above the water. The crown mesh is initialized as empty with no vertices / faces, and they are added in mesh_clipper._clip_crown_by_plane(). If the mesh is fully submerged, no vertices/faces end up being added and meshmagick attempts to create a meshmagick.Mesh() with no vertices/faces. This ultimately fails with an assert error. Can meshmagick catch this error and avoid creating a clipped mesh altogether? then it can return 0 stiffness and the rest of the desired properties from the Hydrostatics module.
I am currently interested in the displaced volume, center of buoyancy, and hydrostatic stiffness. When calling meshmagick.Hydrostatics, I can catch this error and assume that the stiffness is zero for a submerged body. The displaced volume can be calculated with the meshmagick.mesh.Mesh.volume module. However there seems to be no way to get the center of buoyancy outside of the Hydrostatics module. Can I calculate this with another meshmagick function?
File "C:\Users\akeeste\Anaconda3\envs\py37\lib\site-packages\meshmagick\hydrostatics.py", line 165, in init
self._update_hydrostatic_properties()
File "C:\Users\akeeste\Anaconda3\envs\py37\lib\site-packages\meshmagick\hydrostatics.py", line 564, in _update_hydrostatic_properties
clipper = MeshClipper(self.mesh, assert_closed_boundaries=True, verbose=False)
File "C:\Users\akeeste\Anaconda3\envs\py37\lib\site-packages\meshmagick\mesh_clipper.py", line 37, in init
self._update()
File "C:\Users\akeeste\Anaconda3\envs\py37\lib\site-packages\meshmagick\mesh_clipper.py", line 114, in _update
self._clip()
File "C:\Users\akeeste\Anaconda3\envs\py37\lib\site-packages\meshmagick\mesh_clipper.py", line 751, in _clip
self._clip_crown_by_plane()
File "C:\Users\akeeste\Anaconda3\envs\py37\lib\site-packages\meshmagick\mesh_clipper.py", line 665, in _clip_crown_by_plane
clipped_crown_mesh = Mesh(vertices, crown_faces)
File "C:\Users\akeeste\Anaconda3\envs\py37\lib\site-packages\meshmagick\mesh.py", line 409, in init
assert np.array(faces).shape[1] == 4
IndexError: tuple index out of range
It seems that meshmagick cannot read .msh
files created with with the latest version of gmsh (4.*). I'm aware that you can use gmsh's command line option -format msh22
to output a v2.2 .msh
file, but I haven't found a way to do this from the gmsh Python API. It would be great to be able to use gmsh and meshmagick python APIs together, but I'm not sure how to do this with the current version incongruence. Any thoughts?
Hi, first I want to say thank you to the developer and contributors of this software/package, I was just looking for a way for computing hydrostatics from Python and finally found it! ๐
Well, I just executed some of the example lines from cli mentioned in the documentation and all worked fine.
But then I moved to the Python package, but I am facing some trouble here. I tried with both python2.7
and python3.8
using a fresh virtualenv
/venv
, installing it by running
pip install https://github.com/LHEEA/meshmagick/archive/master.zip
.
from meshmagick import mmio, hydrostatics
mesh = mmio.load_VTP("./meshmagick/tests/data/SEAREV.vtp")
hydrostatics.Hydrostatics(mesh)
and got:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "meshmagick/hydrostatics.py", line 143, in __init__
self.backup['init_mesh'] = working_mesh.copy()
AttributeError: 'tuple' object has no attribute 'copy'
Let me know If you need more information or some help, I am a developer too and I am open to contribute to open source projects ๐
Thank you!
When trying to read in a gdf file into the program using meshmagic.mmio.load_GDF
, I am getting the following error:
Traceback (most recent call last):
File "C:\code\testbed\wamit_capytaine_compare.py", line 83, in <module>
mesh_vertices, mesh_faces = mmio.load_GDF(gdf_file)
File "C:\Users\mcdevin\Miniconda3\envs\OWENS\lib\site-packages\meshmagick\mmio.py", line 785, in load_GDF
vertices[iv, :] = np.array(ifile.readline().split())[:3]
ValueError: could not broadcast input array from shape (0,) into shape (3,)
I checked the GDF file in question and it appears to be properly formatted.
C:\Users\User\Geometry>meshmagick H1.stl -hs
=============================================
meshmagick - version 3.0
Copyright 2014-2021, Ecole Centrale de Nantes / D-ICE Engineering
=============================================
H1.stl successfully loaded
>>>> Performing hydrostatic computation on the current hull configuration considered at equilibrium
Traceback (most recent call last):
File "C:\Users\User\anaconda3\Scripts\meshmagick-script.py", line 33, in <module>
sys.exit(load_entry_point('meshmagick', 'console_scripts', 'meshmagick')())
File "c:\program files\meshmagick3\meshmagick_cli.py", line 1196, in main
raise RuntimeError("zcog should at least be given for correct stiffness values computations")
RuntimeError: zcog should at least be given for correct stiffness values computations
At that moment, the matrix is only expressed at the mesh's origin.
We should add a class for this matrix in hydrostatics module. This class has to be quite similar to that used for 3D rotational inertia matrix. For the moment, we do not need to deal with matrix symmetry.
A command line option should be added to meshmagick.py
Hi, I am getting this error when I am trying to run the code "meshmagick".
`Microsoft Windows [Version 10.0.19042.631]
(c) 2020 Microsoft Corporation. All rights reserved.
C:\Windows\system32>meshmagick
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python38\Scripts\meshmagick-script.py", line 11, in
load_entry_point('meshmagick==2.1.1', 'console_scripts', 'meshmagick')()
File "c:\users\User\appdata\local\programs\python\python38\lib\site-packages\pkg_resources_init_.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "c:\users\User\appdata\local\programs\python\python38\lib\site-packages\pkg_resources_init_.py", line 2852, in load_entry_point
return ep.load()
File "c:\users\User\appdata\local\programs\python\python38\lib\site-packages\pkg_resources_init_.py", line 2443, in load
return self.resolve()
File "c:\users\User\appdata\local\programs\python\python38\lib\site-packages\pkg_resources_init_.py", line 2449, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
ModuleNotFoundError: No module named 'meshmagick_cli'
`
Hello,
I get NaN values when writing mesh to stl file. The python mesh object does not have nan values but when saved to stl, NaN values appear in normals.
Best regards,
Ahmed
The center of gravity calculation with the shell inertia option gives different value compared to the one calculated with a commercial 3D software, such as Onshape.
For example, when I use 0.023 shell thickness on Onsape, I obtain a value of -2.31 zG.
but with meshmagick the value is -0.013.
Decreasing the value of the thickness in meshmagick, gives unreasonable values for the center of gravity as can you see in the screenshot below. The maximum height of the object is around 20meters. So a value of 295m for zG is unreasonable.
Useful for clipping operations with projection as well as nonlinear hydrodynamics
After following the recommended installation method:
> conda install -c frongere meshmagick
Importing the mesh module results in the following error:
> import meshmagick.mesh as mmm
> ...
> ModuleNotFoundError: No module named 'vtkCommonCorePython'
Some colleagues have also reported that pip install meshmagick
is returning "No matching distribution found"
Hence, it seems like the meshmagick versions available via conda/pip are not up to date.
The current installation approach we are working with is:
> git clone https://github.com/LHEEA/meshmagick
> cd meshmagick
Then, if you intend to modify the source code:
> python setup.py develop
if not:
> pip install -e .
After installing Meshmagick using setup.py
with option --prefix ~/.local
, any call to Meshmagick in CLI fails with the following error:
Traceback (most recent call last):
File "/home/user_name/.local/bin/meshmagick", line 11, in <module>
load_entry_point('meshmagick==2.1.1', 'console_scripts', 'meshmagick')()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2793, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2411, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2417, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
ModuleNotFoundError: No module named 'meshmagick_cli'
OS: Debian 10 (Buster)
Python: 3.7.3
Hi
I have an issue that Meshmagick is no longer working with Anaconda. The following message appears when i try to run "--show" command. Any solution?
(base) C:\Users\User\Desktop\Simulations\Cube1>meshmagick Cube.stl --show
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\meshmagick-script.py", line 33, in <module>
sys.exit(load_entry_point('meshmagick', 'console_scripts', 'meshmagick')())
File "C:\ProgramData\Anaconda3\Scripts\meshmagick-script.py", line 22, in importlib_load_entry_point
for entry_point in distribution(dist_name).entry_points
File "C:\ProgramData\Anaconda3\lib\importlib\metadata.py", line 504, in distribution
return Distribution.from_name(distribution_name)
File "C:\ProgramData\Anaconda3\lib\importlib\metadata.py", line 177, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: meshmagick
Also, i would like to know if there is any way that i can run Meshmagick using CMD, as i used to do in older versions of Meshmagick (<2.1)
Thank you.
I'm not actually sure if this is a bug or a feature that I don't understand:
from meshmagick.mmio import load_mesh
from meshmagick.mesh import Mesh
from meshmagick.hydrostatics import Hydrostatics
reference_mesh = Mesh(*load_mesh("SEAREV.hst", 'hst'))
for shift in range(0, 100, 20):
shifted_mesh = reference_mesh.copy()
shifted_mesh.translate_x(shift)
print shift
print Hydrostatics(shifted_mesh, cog=(shift, 0, 0)).hs_data['stiffness_matrix'][2, 2]
print Hydrostatics(shifted_mesh, cog=(shift, 0, 0)).hs_data['Iyy']
The inertia matrix is invariant when the body is translated in the x
direction.
I would have expected the same to be true for the stiffness matrix.
Are the rotation dofs defined around the same axis in both cases ?
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 [email protected]
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
The computation of the hydrostatic coefficients fails (without any clear error message) for fully submerged bodies.
$ meshmagick meshmagick/tests/data/submarine.wrl -tz -50 -hs
=============================================
meshmagick - version 1.0.6
Copyright 2014-2018, Ecole Centrale de Nantes
=============================================
meshmagick/tests/data/submarine.wrl successfully loaded
OPERATION: Translation by -50.000000 along Z
-> Done.
Traceback (most recent call last):
File "/opt/miniconda3/envs/meshm/bin/meshmagick", line 6, in <module>
sys.exit(meshmagick.main())
File "/opt/miniconda3/envs/meshm/lib/python2.7/site-packages/meshmagick/__init__.py", line 5, in main
mm.main()
File "/opt/miniconda3/envs/meshm/lib/python2.7/site-packages/meshmagick/meshmagick.py", line 1147, in main
hs_solver = hs.Hydrostatics(mesh, rho_water=rho_water, grav=grav, verbose=verbose)
File "/opt/miniconda3/envs/meshm/lib/python2.7/site-packages/meshmagick/hydrostatics.py", line 165, in __init__
self._update_hydrostatic_properties()
File "/opt/miniconda3/envs/meshm/lib/python2.7/site-packages/meshmagick/hydrostatics.py", line 564, in _update_hydrostatic_properties
clipper = MeshClipper(self.mesh, assert_closed_boundaries=True, verbose=False)
File "/opt/miniconda3/envs/meshm/lib/python2.7/site-packages/meshmagick/mesh_clipper.py", line 37, in __init__
self._update()
File "/opt/miniconda3/envs/meshm/lib/python2.7/site-packages/meshmagick/mesh_clipper.py", line 114, in _update
self._clip()
File "/opt/miniconda3/envs/meshm/lib/python2.7/site-packages/meshmagick/mesh_clipper.py", line 750, in _clip
self._clip_crown_by_plane()
File "/opt/miniconda3/envs/meshm/lib/python2.7/site-packages/meshmagick/mesh_clipper.py", line 664, in _clip_crown_by_plane
clipped_crown_mesh = Mesh(vertices, crown_faces)
File "/opt/miniconda3/envs/meshm/lib/python2.7/site-packages/meshmagick/mesh.py", line 409, in __init__
assert np.array(faces).shape[1] == 4
IndexError: tuple index out of range
Attempting to convert .stl to .dat using the command line, mesh reads in fine, but throws the error
OSError: Extension "dat" is not known.
Looking to use this to then implement with NEMOH.
Unsure if this is user error.
Help appreciated
The 'Command Line Interface Reference Guide' indicates that Meshmagick is able to write .DAT files. It seems that this is unfortunately impossible. The error message is the following:
OSError: Extension ".dat" is not known
I installed meshmagick the other day by issuing the following command
conda install -c frongere meshmagick
I'm able to run meshmagick from the terminal command line (e.g. meshmagick my_mesh.stl --show
) and import in python 3.7 (e.g. import meshmagick
) without any trouble, however I'm not sure how to work with meshmagick in python. Right now I execute things like
os.system('meshmagick my_mesh.stl --show')
and it works as intended, but it's obviously not running explicitly in python. When I execute meshmagick.__version__
it returns '1.0.5' which from the README should be something like '2.0'?
I'm confused on what versions are available and where. Is the installation method above suppose to install the latest version (just installed the other day)? Is any documentation on how to use meshmagic explicitly in python (not via terminal command line)?
Hello all,
In python, I used the following to read a gmsh .msh file:
from meshmagick import mmio mmio.load_MSH('../Mesh/test.MSH')
The following error appeared:
Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.3\plugins\python-ce\helpers\pydev\pydevconsole.py", line 364, in runcode coro = func() ^^^^^^ File "<input>", line 1, in <module> File "c:\users\acerisier\documents\nemoh\meshmagick\meshmagick\mmio.py", line 949, in load_MSH return load_MSH41(filename) ^^^^^^^^^^^^^^^^^^^^ File "c:\users\acerisier\documents\nemoh\meshmagick\meshmagick\mmio.py", line 883, in load_MSH41 import gmshparser File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.3\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'gmshparser'
Can someone help please?
Hello everyone,
I'm currently using Meshmagick for my project, and I'm looking to calculate hydrostatic stiffness, inertia, center of gravity, center of buoyancy, and displaced volume of bodies. I would like to generate the KH.dat and Hydrostatic.dat files containing this crucial information. However, I'm unsure about the procedure for performing these calculations with Meshmagick.
Could someone please explain how to use Meshmagick to generate these files? If possible, could you provide examples or detailed instructions on how to obtain this data from Meshmagick?
Thank you in advance for your valuable assistance!
Best regards,
Hi,
I see now that Meshmagick now runs under Python 3.7 (from the project main page: <<< INFORMATION : From version 2.0, Meshmagick runs under Python 3.7 !! Many thanks to Matthieu Ancellin for the port to Python 3 !! :) >>>). However, when I try to install using
conda install -c frongere meshmagick
I receive an error:
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- meshmagick -> python=2.7
Your python: python=3.7
Is there another way I should be installing Meshmagick for use with Python 3.7?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.