Comments (4)
@ryancoe Good idea, the python workflow I use to get around this issue is below. The 'body' object is a Capytaine Floating Body, though of course these parameters could be input however required. For reference, my entire Capytaine workflow can be found in the WEC-Sim repo here.
I'll work on a PR to implement this in meshmagick and resolve this and issue #7 simultaneously.
import meshmagick.mesh as mmm
import meshmagick.hydrostatics as mmhs
# use meshmagick to compute hydrostatic stiffness matrix
# NOTE: meshmagick currently has issue if a body is completely submerged (e.g. OSWEC base)
# See issues #7, #19 on meshmagick GitHub page.
# use try-except statement to catch this error and use alternate function for cb/vo
body_mesh = mmm.Mesh(body.mesh.vertices, body.mesh.faces, name=body.mesh.name)
try:
body_hs = mmhs.Hydrostatics(working_mesh=body_mesh,
cog=body.center_of_mass,
rho_water=1023.0,
grav=9.81)
vo = body_hs.displacement_volume
cb = body_hs.buoyancy_center
khs = body_hs.hydrostatic_stiffness_matrix
except:
# Exception if body is fully submerged.
# if fully submerged:
# stiffness is 0 as small displacements do not change the displaced volume or hydrostatic force
# displaced volume is the total mesh volume
# center of buoyancy is equal to the center of gravity of the mesh with a constant density
vo = body_mesh.volume
khs = np.zeros((3,3))
inertia = body_mesh.eval_plain_mesh_inertias()
cb = inertia.gravity_center
from meshmagick.
@akeeste - Not sure if you already solved this, but I recently stumbled across a workable solution using the methods in meshmagick
that generate RigidBodyInertia
objects. For example, you can use the eval_plain_mesh_inertias
method as follows.
Line 1965 in 0d214f9
from meshmagick.mmio import load_mesh
from meshmagick.mesh import Mesh
import pygmsh
import pytest
r = 1
geom = pygmsh.opencascade.Geometry()
sphere = geom.add_ball([0,0,-1], r)
mshArgs = ['-clscale', str(0.25),
'-clcurv', str(360/50)]
fbname = 'mmtest'
_ = pygmsh.generate_mesh(geom,
dim=2,
extra_gmsh_arguments=mshArgs,
remove_lower_dim_cells=True,
geo_filename=fbname + '.geo',
msh_filename=fbname + '.stl',
mesh_file_type="stl")
mesh = Mesh(*load_mesh(fbname + '.stl', 'stl'))
inertia = mesh.eval_plain_mesh_inertias()
cob = inertia.gravity_center
assert pytest.approx(-1, rel=1e-4) == cob[2]
from meshmagick.
@ryancoe Thanks for pointing this out! I hadn't found a solution for this yet, this is very helpful. Now in the instance where the body is fully submerged, I can catch the hydrostatics error and just use the mesh to get the cb.
from meshmagick.
@akeeste - Happy to help. Would you mind posting an example of your workflow here? Or (even better) submit a PR that would make this seamless?
from meshmagick.
Related Issues (20)
- mistake in the cog calculation with shell inertia HOT 10
- Test is failling on master branch HOT 2
- NaN normals when writing mesh object to stl file HOT 3
- Converting - extension "dat" not found HOT 2
- Issue writing .DAT file (Diodore). HOT 1
- How to install for Python 3.7? HOT 1
- Python 3 implmentation and documentation HOT 2
- Getting Python error when calling meshmagick.hydrostatics.Hidrostatics() HOT 2
- Impossible to use CLI HOT 8
- ModuleNotFoundError: No module named 'meshmagick_cli' HOT 11
- conda/pip installation issues HOT 6
- Meshmagick not running with Anaconda HOT 2
- Meshmagick Hydrostatic Issue HOT 2
- load_GDF ValueError HOT 1
- Converting a mesh file HOT 7
- ModuleNotFoundError: No module named 'gmshparser' HOT 1
- Hydrostatic computations for submerged body
- Stiffness matrix and translation HOT 4
- gmsh v4 HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meshmagick.