Skip to content

Commit

Permalink
docs: move example to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl authored and inducer committed Jul 9, 2024
1 parent 53e8a7a commit f18130b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 50 deletions.
77 changes: 28 additions & 49 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -1,47 +1,42 @@
Welcome to MeshPy's documentation!
==================================

.. toctree::
:maxdepth: 2
:hidden:

installation
tri-tet
gmsh
geometry
faq
🚀 Github <https://github.com/inducer/meshpy>
💾 Download Releases <https://pypi.org/project/meshpy>

MeshPy offers quality triangular and tetrahedral mesh generation for Python.
Meshes of this type are chiefly used in finite-element simulation codes, but
also have many other applications ranging from computer graphics to robotics.

In order to generate these 2D and 3D meshes, MeshPy provides Python interfaces
to a few well-regarded mesh generators:

* `Triangle <http://www.cs.cmu.edu/~quake/triangle.html>`_ by J. Shewchuk.
* `TetGen <http://tetgen.berlios.de/>`_ by Hang Si.
* `Gmsh <http://geuz.org/gmsh/>`_ by Christophe Geuzaine and Jean-François Remacle.
* `Triangle <http://www.cs.cmu.edu/~quake/triangle.html>`__ by J. Shewchuk.
* `TetGen <http://tetgen.berlios.de/>`__ by Hang Si.

Triangle and TetGen are included in the package in slightly modified versions. Gmsh
is called as a subprocess.
Triangle and TetGen are included in the package in slightly modified versions.
An interface for `Gmsh <https://gmsh.info/>`__ was also part of MeshPy, but is
now its own package `gmsh_interop <https://github.com/inducer/gmsh_interop>`__.

MeshPy has its own `web page <http://mathema.tician.de/software/meshpy>`_,
where you can find updated software, news, a forum, and documentation.

Show me! I need examples!
-------------------------
This simple code generates a mesh of a "brick"::

from meshpy.tet import MeshInfo, build

mesh_info = MeshInfo()
mesh_info.set_points([
(0,0,0), (2,0,0), (2,2,0), (0,2,0),
(0,0,12), (2,0,12), (2,2,12), (0,2,12),
])
mesh_info.set_facets([
[0,1,2,3],
[4,5,6,7],
[0,4,5,1],
[1,5,6,2],
[2,6,7,3],
[3,7,4,0],
])
mesh = build(mesh_info)
print "Mesh Points:"
for i, p in enumerate(mesh.points):
print i, p
print "Point numbers in tetrahedra:"
for i, t in enumerate(mesh.elements):
print i, t
mesh.write_vtk("test.vtk")

This file is included in the :mod:`meshpy` distribution as
:download:`examples/demo.py <../examples/demo.py>`.

.. literalinclude:: ../examples/demo.py

As a result of this, you will get::

Expand All @@ -67,25 +62,9 @@ As a result of this, you will get::
4 [41, 45, 24, 54]
...

and a file :file:`test.vtk` that you can view with `Paraview <http://paraview.org>`_ or
`Visit <http://www.llnl.gov/VisIt/>`_.

Contents
========

.. toctree::
:maxdepth: 2

installation
tri-tet
gmsh
geometry
faq
🚀 Github <https://github.com/inducer/meshpy>
💾 Download Releases <https://pypi.org/project/meshpy>

MeshPy has its own `web page <http://mathema.tician.de/software/meshpy>`_, where you
can find updated software, news, a forum, and documentation.
and a file :file:`test.vtk` that you can view with
`Paraview <http://paraview.org>`__ or
`Visit <https://visit-dav.github.io/visit-website/>`__.

Indices and tables
==================
Expand Down
5 changes: 4 additions & 1 deletion examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@
[3, 7, 4, 0],
]
)
mesh = build(mesh_info)
mesh = build(mesh_info, max_volume=0.5)

print("Mesh Points:")
for i, p in enumerate(mesh.points):
print(i, p)

print("Point numbers in tetrahedra:")
for i, t in enumerate(mesh.elements):
print(i, t)

mesh.write_vtk("test.vtk")

0 comments on commit f18130b

Please sign in to comment.