Skip to content

Commit

Permalink
Merge pull request #97 from nschloe/even-more-tests
Browse files Browse the repository at this point in the history
Even more tests
  • Loading branch information
nschloe committed Dec 8, 2020
2 parents 05bdb80 + 5c4de04 commit ed0bb81
Show file tree
Hide file tree
Showing 15 changed files with 600 additions and 347 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
ignore = E203, E266, E501, W503
ignore = E203, E266, E501, W503, C901
max-line-length = 80
max-complexity = 18
select = B,C,E,F,W,T4,B9
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ jobs:
- uses: actions/checkout@v2
with:
lfs: true
- name: Install system requirements
run: |
sudo apt-get update
sudo apt-get install -y python3-vtk7
- name: Test with tox
run: |
pip install tox
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ meshplex is used in [optimesh](https://github.com/nschloe/optimesh) and

### Quickstart

For triangular and tetrahedral meshes, meshplex can compute the following data:
```python
import numpy
import meshplex
Expand Down Expand Up @@ -62,9 +63,15 @@ mesh.flip_until_delaunay()
# show the mesh
mesh.show()
```
For triangular meshes, meshplex also has some mesh manipulation routines:
<!--exdown-skip-->
```python
mesh.flip_until_delaunay() # flips edges until the mesh is Delaunay
mesh.remove_cells([0, 2, ...]) # removes some cells
```

meshplex works much the same way with tetrahedral meshes. For a documentation of all
classes and functions, see [readthedocs](https://meshplex.readthedocs.io/).
For a documentation of all classes and functions, see
[readthedocs](https://meshplex.readthedocs.io/).

(For mesh creation, check out
[this list](https://github.com/nschloe/awesome-scientific-computing#meshing)).
Expand Down
18 changes: 10 additions & 8 deletions meshplex/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ def compute_triangle_circumcenters(X, ei_dot_ei, ei_dot_ej):
# coordinates are (see
# <https://en.wikipedia.org/wiki/Trilinear_coordinates#Between_Cartesian_and_trilinear_coordinates>)
#
# C = sum_i ||e_i|| * cos(alpha_i)/beta * P_i
# C = sum_i ||e_i|| * cos(alpha_i) / beta * P_i
#
# with
#
# beta = sum ||e_i||*cos(alpha_i)
# beta = sum ||e_i|| * cos(alpha_i)
#
# Incidentally, the cosines are
#
Expand All @@ -163,20 +163,22 @@ def compute_triangle_circumcenters(X, ei_dot_ei, ei_dot_ej):
# + ... P1
# + ... P2.
#
alpha = ei_dot_ei * ei_dot_ej
alpha_sum = alpha[0] + alpha[1] + alpha[2]
beta = alpha / alpha_sum[None]
a = X * beta[..., None]
cc = a[0] + a[1] + a[2]

# An even nicer formula is given on
# <https://en.wikipedia.org/wiki/Circumscribed_circle#Barycentric_coordinates>: The
# barycentric coordinates of the circumcenter are
#
# a^2 (b^2 + c^2 - a^2) : b^2 (c^2 + a^2 - b^2) : c^2 (a^2 + b^2 - c^2).
#
# This is only using the squared edge lengths, too!
# TODO make this happen, perhaps with something like
# ei_dot_ei * (numpy.sum(ei_dot_ei, axis=0) - 2 * ei_dot_ei)
#
alpha = ei_dot_ei * ei_dot_ej
alpha_sum = alpha[0] + alpha[1] + alpha[2]
beta = alpha / alpha_sum[None]
a = X * beta[..., None]
cc = a[0] + a[1] + a[2]

# alpha = numpy.array([
# ei_dot_ei[0] * (ei_dot_ei[1] + ei_dot_ei[2] - ei_dot_ei[0]),
# ei_dot_ei[1] * (ei_dot_ei[2] + ei_dot_ei[0] - ei_dot_ei[1]),
Expand Down

0 comments on commit ed0bb81

Please sign in to comment.