Git Product home page Git Product logo

Comments (7)

nschloe avatar nschloe commented on June 13, 2024

By volume you mean the enclosed volume (3D) or the surface area?

from pygalmesh.

montallban avatar montallban commented on June 13, 2024

@nschloe I mean the enclosed volume (3D).

It would also be useful to know the surface area, I suppose. Any information really, but in particular the 3D volume.

from pygalmesh.

nschloe avatar nschloe commented on June 13, 2024

I'd simply create the tetrahedral volume mesh with pygalmesh and then sum up the volumes of the tetrahedra, perhaps with https://github.com/nschloe/meshplex.

from pygalmesh.

montallban avatar montallban commented on June 13, 2024

Awesome, this seems to be exactly what I am looking for. Excuse me for my ignorance, but could you detail how to "create the tetrahedral volume mesh". I tried the following but I am not sure it is right:

mesh = pygalmesh.generate_mesh(verts[faces])

With faces and verts as above. I am returned with the error:

  File "C:\Users\User\Anaconda3\lib\site-packages\pygalmesh\main.py", line 53, in generate_mesh
    verbose=verbose,
TypeError: _generate_mesh(): incompatible function arguments. The following argument types are supported:
    1. (domain: _pygalmesh.DomainBase, outfile: str, feature_edges: List[List[List[float[3]]]] = [], bounding_sphere_radius: float = 0.0, lloyd: bool = False, odt: bool = False, perturb: bool = True, exude: bool = True, edge_size: float = 0.0, facet_angle: float = 0.0, facet_size: float = 0.0, facet_distance: float = 0.0, cell_radius_edge_ratio: float = 0.0, cell_size: float = 0.0, verbose: bool = True) -> None

Invoked with: array([[[0. , 1. , 1.9],
        [1. , 0. , 1.9],
        [0. , 0. , 1.9]],

       [[0. , 1. , 1.9],
        [1. , 1. , 1.9],
        [1. , 0. , 1.9]],

       [[0. , 1.9, 0. ],
        [1. , 1.9, 1. ],
        [0. , 1.9, 1. ]],

       [[1. , 1.9, 0. ],
        [1. , 1.9, 1. ],
        [0. , 1.9, 0. ]],

       [[0. , 1. , 1.9],
        [0. , 1.9, 1. ],
        [1. , 1. , 1.9]],

       [[1. , 1. , 1.9],
        [0. , 1.9, 1. ],
        [1. , 1.9, 1. ]],

       [[1.9, 1. , 1. ],
        [1.9, 0. , 0. ],
        [1.9, 0. , 1. ]],

       [[1.9, 1. , 0. ],
        [1.9, 0. , 0. ],
        [1.9, 1. , 1. ]],

       [[1. , 1. , 1.9],
        [1.9, 1. , 1. ],
        [1. , 0. , 1.9]],

       [[1. , 0. , 1.9],
        [1.9, 1. , 1. ],
        [1.9, 0. , 1. ]],

       [[1. , 1.9, 0. ],
        [1.9, 1. , 0. ],
        [1. , 1.9, 1. ]],

       [[1. , 1.9, 1. ],
        [1.9, 1. , 0. ],
        [1.9, 1. , 1. ]],

       [[1. , 1.9, 1. ],
        [1.9, 1. , 1. ],
        [1. , 1. , 1.9]]], dtype=float32), 'C:\\Users\\User\\AppData\\Local\\Temp\\tmpjm5w3m1i.mesh'; kwargs: feature_edges=[], bounding_sphere_radius=0.0, lloyd=False, odt=False, perturb=True, exude=True, edge_size=0.0, facet_angle=0.0, facet_size=0.0, facet_distance=0.0, cell_radius_edge_ratio=0.0, cell_size=0.0, verbose=True

from pygalmesh.

nschloe avatar nschloe commented on June 13, 2024

https://github.com/nschloe/pygalmesh#volume-meshes-from-surface-meshes

from pygalmesh.

montallban avatar montallban commented on June 13, 2024

Can you explain to me how to get my surface mesh in the correct form? This is how I am doing it:

from mpl_toolkits.mplot3d.art3d import Poly3DCollection

mesh = Poly3DCollection(verts[faces])
mesh = pygalmesh.generate_volume_mesh_from_surface_mesh(mesh)

returns

Traceback (most recent call last):
  File "c:\Users\User\weather\MS\MS_cubes.py", line 137, in <module>
  File "C:\Users\User\Anaconda3\lib\site-packages\pygalmesh\main.py", line 189, in generate_volume_mesh_from_surface_mesh
    mesh = meshio.read(filename)
  File "C:\Users\User\Anaconda3\lib\site-packages\meshio\_helpers.py", line 55, in read
    path = pathlib.Path(filename)
  File "C:\Users\User\Anaconda3\lib\pathlib.py", line 1003, in __new__
    self = cls._from_parts(args, init=False)
  File "C:\Users\User\Anaconda3\lib\pathlib.py", line 658, in _from_parts
  File "C:\Users\User\Anaconda3\lib\pathlib.py", line 642, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not Poly3DCollection

I have a numpy array which I convert into a mesh using Poly3DCollection. It is not in the '.vtu' format. Is there something I am missing. The tutorial for pygalmesh is not self-explanatory.

from pygalmesh.

montallban avatar montallban commented on June 13, 2024

See here: https://stackoverflow.com/questions/41404096/how-to-draw-a-tetrahedron-mesh-by-matplotlib/48354263#48354263

import meshio
meshio.write('out.vtu', xyz, {'tetra': tets})

from pygalmesh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.