├── CHANGELOG.md └── README.md /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [0.16.3] - 2021-07-13 9 | 10 | ### Changed 11 | 12 | - Fixed computation of `genus` and `euler_characteristic` 13 | 14 | ## [0.16.0] - 2021-04-15 15 | 16 | ### Changed 17 | 18 | - `mesh.cells` is now a function; e.g., `mesh.cells["points"]` is now 19 | `mesh.cells("points")` 20 | - `mesh.idx_hierarchy` is deprecated in favor of `mesh.idx[-1]` (the new `idx` list 21 | contains more index magic) 22 | 23 | ## [0.14.0] - 2020-11-05 24 | 25 | ### Changed 26 | 27 | - `node_coords` is now `points` 28 | - `mesh_tri`: fixed inconsistent state after setting the points 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | meshplex 3 |

Fast tools for simplex meshes.

4 |

5 | 6 | [![PyPi Version](https://img.shields.io/pypi/v/meshplex.svg?style=flat-square)](https://pypi.org/project/meshplex/) 7 | [![PyPI pyversions](https://img.shields.io/pypi/pyversions/meshplex.svg?style=flat-square)](https://pypi.org/project/meshplex/) 8 | [![GitHub stars](https://img.shields.io/github/stars/nschloe/meshplex.svg?style=flat-square&logo=github&label=Stars&logoColor=white)](https://github.com/nschloe/meshplex) 9 | [![PyPi downloads](https://img.shields.io/pypi/dm/meshplex.svg?style=flat-square)](https://pypistats.org/packages/meshplex) 10 | 11 | [![Discord](https://img.shields.io/static/v1?logo=discord&label=chat&message=on%20discord&color=7289da&style=flat-square)](https://discord.gg/hnTJ5MRX2Y) 12 | 13 | Compute all sorts of interesting points, areas, and volumes in simplex 14 | (triangle, tetrahedral, n-simplex) meshes of any dimension, with a focus on 15 | efficiency. Useful in many contexts, e.g., finite-element and finite-volume 16 | computations. 17 | 18 | ### Installation 19 | 20 | Install meshplex [from PyPI](https://pypi.org/project/meshplex/) with 21 | 22 | ``` 23 | pip install meshplex 24 | ``` 25 | 26 | For full usage of meshplex, you require a license. Licenses for personal and 27 | academic use can be purchased 28 | [here](https://buy.stripe.com/5kA3eV8t8af83iE9AE). For more info, see 29 | [here](https://github.com/meshpro). 30 | 31 | ### Quickstart 32 | 33 | meshplex can compute the following data: 34 | 35 | ```python 36 | import meshplex 37 | 38 | # create a simple Mesh instance 39 | points = [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]] 40 | cells = [[0, 1, 2]] 41 | mesh = meshplex.Mesh(points, cells) 42 | # or read it from a file 43 | # mesh = meshplex.read("pacman.vtk") 44 | 45 | # triangle volumes, heights 46 | print(mesh.cell_volumes) 47 | print(mesh.signed_cell_volumes) 48 | print(mesh.cell_heights) 49 | 50 | # circumcenters, centroids, incenters 51 | print(mesh.cell_circumcenters) 52 | print(mesh.cell_centroids) 53 | print(mesh.cell_incenters) 54 | 55 | # circumradius, inradius, cell quality 56 | print(mesh.cell_circumradius) 57 | print(mesh.cell_inradius) 58 | print(mesh.q_radius_ratio) # d * inradius / circumradius (min 0, max 1) 59 | 60 | # control volumes, centroids 61 | print(mesh.control_volumes) 62 | print(mesh.control_volume_centroids) 63 | 64 | # covolume/edge length ratios 65 | print(mesh.ce_ratios) 66 | 67 | # count Delaunay violations 68 | print(mesh.num_delaunay_violations) 69 | 70 | # get all boundary angles in radians 71 | print(mesh.outside_boundary_angles_radians) 72 | 73 | # removes some cells 74 | mesh.remove_cells([0]) 75 | ``` 76 | 77 | For triangular meshes (`MeshTri`), meshplex also has some mesh manipulation routines: 78 | 79 | 80 | 81 | ```python 82 | mesh.show() # show the mesh 83 | mesh.angles # compute angles 84 | mesh.flip_until_delaunay() # flips edges until the mesh is Delaunay 85 | ``` 86 | 87 | For a documentation of all classes and functions, see 88 | [readthedocs](https://meshplex.readthedocs.io/). 89 | 90 | (For mesh creation, check out 91 | [this list](https://github.com/nschloe/awesome-scientific-computing#meshing)). 92 | 93 | ### Plotting 94 | 95 | #### Triangles 96 | 97 | 98 | 99 | 100 | 101 | ```python 102 | import meshplex 103 | 104 | mesh = meshplex.read("pacman.vtk") 105 | mesh.show( 106 | # show_coedges=True, 107 | # control_volume_centroid_color=None, 108 | # mesh_color="k", 109 | # nondelaunay_edge_color=None, 110 | # boundary_edge_color=None, 111 | # comesh_color=(0.8, 0.8, 0.8), 112 | show_axes=False, 113 | ) 114 | ``` 115 | 116 | #### Tetrahedra 117 | 118 | 119 | 120 | 121 | 122 | ```python 123 | import numpy as np 124 | import meshplex 125 | 126 | # Generate tetrahedron 127 | points = np.array( 128 | [ 129 | [1.0, 0.0, -1.0 / np.sqrt(8)], 130 | [-0.5, +np.sqrt(3.0) / 2.0, -1.0 / np.sqrt(8)], 131 | [-0.5, -np.sqrt(3.0) / 2.0, -1.0 / np.sqrt(8)], 132 | [0.0, 0.0, np.sqrt(2.0) - 1.0 / np.sqrt(8)], 133 | ] 134 | ) / np.sqrt(3.0) 135 | cells = [[0, 1, 2, 3]] 136 | 137 | # Create mesh object 138 | mesh = meshplex.MeshTetra(points, cells) 139 | 140 | # Plot cell 0 with control volume boundaries 141 | mesh.show_cell( 142 | 0, 143 | # barycenter_rgba=(1, 0, 0, 1.0), 144 | # circumcenter_rgba=(0.1, 0.1, 0.1, 1.0), 145 | # circumsphere_rgba=(0, 1, 0, 1.0), 146 | # incenter_rgba=(1, 0, 1, 1.0), 147 | # insphere_rgba=(1, 0, 1, 1.0), 148 | # face_circumcenter_rgba=(0, 0, 1, 1.0), 149 | control_volume_boundaries_rgba=(1.0, 0.0, 0.0, 1.0), 150 | line_width=3.0, 151 | ) 152 | ``` 153 | --------------------------------------------------------------------------------