Giter Site home page Giter Site logo

bwoodsend / meshzoo-archive Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 26 KB

A backup of the last GPL3 release of https://github.com/nschloe/meshzoo. For academic purposes only, given that the tests are gone

License: GNU General Public License v3.0

Python 100.00%

meshzoo-archive's Introduction

meshzoo

PyPi Version PyPI pyversions GitHub stars PyPi downloads

Discord

gh-actions codecov LGTM Code style: black

When generating meshes for FEM/FVM computations, sometimes your geometry is so simple that you don't need a complex mesh generator (like pygmsh, MeshPy, mshr, pygalmesh, dmsh), but something simple and fast that makes use of the structure of the domain. Enter meshzoo.

Examples

Triangle

import meshzoo

bary, cells = meshzoo.triangle(8)

# corners = numpy.array(
#     [
#         [0.0, -0.5 * numpy.sqrt(3.0), +0.5 * numpy.sqrt(3.0)],
#         [1.0, -0.5, -0.5],
#     ]
# )
# points = numpy.dot(corners, bary).T

# Process the mesh, e.g., write it to a file using meshio
# meshio.write_points_cells("triangle.vtk", points, {"triangle": cells})

Rectangle

import meshzoo

points, cells = meshzoo.rectangle_tri(
    (0.0, 0.0),
    (1.0, 1.0),
    n=11,  # or (11, 11)
    variant="zigzag",  # or "up", "down", "center"
)

points, cells = meshzoo.rectangle_quad((0.0, 0.0), (1.0, 1.0), n=11)

Regular polygon

meshzoo.ngon(4, 8) meshzoo.ngon(6, 8) meshzoo.ngon(9, 8)
import meshzoo

points, cells = meshzoo.ngon(5, 11)

Disk

meshzoo.disk(4, 8) meshzoo.disk(6, 8) meshzoo.disk(9, 8)

The disk meshes are inflations of regular polygons.

import meshzoo

points, cells = meshzoo.disk(6, 11)

points, cells = meshzoo.disk_quad(10)

Möbius strip

import meshzoo

points, cells = meshzoo.moebius(num_twists=1, nl=60, nw=11)

Sphere (surface)

import meshzoo

points, cells = meshzoo.uv_sphere(num_points_per_circle=20, num_circles=10, radius=1.0)
points, tri, quad = meshzoo.geo_sphere(
    num_points_per_circle=20, num_circles=10, radius=1.0
)

Spheres can also be generated by refining the faces of platonic solids and then "inflating" them. meshzoo implements a few of them. The sphere generated from the icosahedron has the highest-quality (most equilateral) triangles.

All cells are oriented such that its normal points outwards.

meshzoo.tetra_sphere(10) meshzoo.octa_sphere(10) meshzoo.icosa_sphere(10)

Ball (solid)

import meshzoo

points, cells = meshzoo.ball_tetra(10)
points, cells = meshzoo.ball_hexa(10)

Tube

import meshzoo

points, cells = meshzoo.tube(length=1.0, radius=1.0, n=30)

Cube

import meshzoo

points, cells = meshzoo.cube_tetra((0.0, 0.0, 0.0), (1.0, 1.0, 1.0), n=11)
points, cells = meshzoo.cube_hexa((0.0, 0.0, 0.0), (1.0, 1.0, 1.0), n=11)

Extra, extra

In addition to this, the examples/ directory contains a couple of instructive examples for other mesh generators.

Installation

meshzoo is available from the Python Package Index, so simply do

pip install meshzoo

to install.

Testing

To run the meshzoo unit tests, check out this repository and run

pytest

License

meshzoo is published under the MIT license.

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.