Skip to content

Commit

Permalink
Merge pull request #173 from nschloe/clarify-license
Browse files Browse the repository at this point in the history
Clarify license
  • Loading branch information
nschloe committed Mar 2, 2022
2 parents 494b003 + 760b64f commit 80a4c26
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -5,7 +5,7 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 21.10b0
rev: 22.1.0
hooks:
- id: black
language_version: python3
Expand Down
25 changes: 12 additions & 13 deletions README.md
Expand Up @@ -116,17 +116,14 @@ import numpy as np
import meshplex

# Generate tetrahedron
points = (
np.array(
[
[1.0, 0.0, -1.0 / np.sqrt(8)],
[-0.5, +np.sqrt(3.0) / 2.0, -1.0 / np.sqrt(8)],
[-0.5, -np.sqrt(3.0) / 2.0, -1.0 / np.sqrt(8)],
[0.0, 0.0, np.sqrt(2.0) - 1.0 / np.sqrt(8)],
]
)
/ np.sqrt(3.0)
)
points = np.array(
[
[1.0, 0.0, -1.0 / np.sqrt(8)],
[-0.5, +np.sqrt(3.0) / 2.0, -1.0 / np.sqrt(8)],
[-0.5, -np.sqrt(3.0) / 2.0, -1.0 / np.sqrt(8)],
[0.0, 0.0, np.sqrt(2.0) - 1.0 / np.sqrt(8)],
]
) / np.sqrt(3.0)
cells = [[0, 1, 2, 3]]

# Create mesh object
Expand Down Expand Up @@ -159,5 +156,7 @@ to install.

### License

This software is published under the [GPLv3
license](https://www.gnu.org/licenses/gpl-3.0.en.html).
This software is available under the [GPLv3
license](https://www.gnu.org/licenses/gpl-3.0.en.html) as well as a commercial
license. If you'd like to use this software commercially, please contact the
author.
2 changes: 1 addition & 1 deletion src/meshplex/__about__.py
@@ -1 +1 @@
__version__ = "0.17.0"
__version__ = "0.17.1"
4 changes: 2 additions & 2 deletions src/meshplex/_mesh_tetra.py
Expand Up @@ -79,7 +79,7 @@ def q_min_sin_dihedral_angles(self):
cos_alpha += [(fa[2] ** 2 + fa[3] ** 2 - H2) / (2 * fa[2] * fa[3])]

cos_alpha = np.array(cos_alpha).T
sin_alpha = np.sqrt(1 - cos_alpha ** 2)
sin_alpha = np.sqrt(1 - cos_alpha**2)

m = np.min(sin_alpha, axis=1) / (np.sqrt(2) * 2 / 3)
return m
Expand All @@ -95,7 +95,7 @@ def q_vol_rms_edgelength3(self):
(el2[0][0] + el2[1][0] + el2[2][0] + el2[0][2] + el2[1][1] + el2[0][1]) / 6
)
alpha = np.sqrt(2) / 12 # normalization factor
return self.cell_volumes / rms ** 3 / alpha
return self.cell_volumes / rms**3 / alpha

def show(self):
from matplotlib import pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion src/meshplex/_mesh_tri.py
Expand Up @@ -202,7 +202,7 @@ def compute_ncurl(self, vector_field):
#
# curl = z * sum_edge_dot_A * 0.5 / |A|^2.
#
curl = z * (0.5 * sum_edge_dot_A / self.cell_volumes ** 2)[..., None]
curl = z * (0.5 * sum_edge_dot_A / self.cell_volumes**2)[..., None]
return curl

def show_vertex(self, *args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers.py
Expand Up @@ -25,7 +25,7 @@ def run(mesh, volume, convol_norms, ce_ratio_norms, cellvol_norms, tol=1.0e-12):
# self.assertAlmostEqual(volume, total_ce_ratio, delta=tol * volume)
# ```
# Check ce_ratio norms.
alpha2 = fsum((mesh.ce_ratios ** 2).flat)
alpha2 = fsum((mesh.ce_ratios**2).flat)
alpha_inf = max(abs(mesh.ce_ratios).flat)
assert is_near_equal(ce_ratio_norms, [alpha2, alpha_inf], tol), [alpha2, alpha_inf]

Expand Down
22 changes: 11 additions & 11 deletions tests/mesh_tri/test_mesh_tri.py
Expand Up @@ -212,7 +212,7 @@ def test_regular_tri2(a):
assert is_near_equal(mesh.ce_ratios, [val, val, val], tol)

# control volumes
vol = np.sqrt(3.0) / 4 * a ** 2
vol = np.sqrt(3.0) / 4 * a**2
assert is_near_equal(mesh.control_volumes, [vol / 3.0, vol / 3.0, vol / 3.0], tol)

# cell volumes
Expand Down Expand Up @@ -300,17 +300,17 @@ def test_degenerate_small0b(h):
tol = 1.0e-14

# edge lengths
el = np.sqrt(0.5 ** 2 + h ** 2)
el = np.sqrt(0.5**2 + h**2)
assert is_near_equal(mesh.edge_lengths.T, [el, el, 1.0], tol)

# ce_ratios
ce0 = 0.5 / h * (h ** 2 - 0.25)
ce0 = 0.5 / h * (h**2 - 0.25)
ce12 = 0.25 / h
assert is_near_equal(mesh.ce_ratios.T, [ce12, ce12, ce0], tol)

# control volumes
cv12 = 0.25 * (1.0 ** 2 * ce0 + (0.25 + h ** 2) * ce12)
cv0 = 0.5 * (0.25 + h ** 2) * ce12
cv12 = 0.25 * (1.0**2 * ce0 + (0.25 + h**2) * ce12)
cv0 = 0.5 * (0.25 + h**2) * ce12
assert is_near_equal(mesh.control_volumes, [cv12, cv12, cv0], tol)

# cell volumes
Expand Down Expand Up @@ -374,8 +374,8 @@ def test_degenerate_small1(h, a):
tol = 1.0e-12

# edge lengths
el0 = np.sqrt((1.0 - a) ** 2 + h ** 2)
el1 = np.sqrt(a ** 2 + h ** 2)
el0 = np.sqrt((1.0 - a) ** 2 + h**2)
el1 = np.sqrt(a**2 + h**2)
el2 = 1.0
assert is_near_equal(mesh.edge_lengths.T, [[el0, el1, el2]], tol)

Expand Down Expand Up @@ -648,18 +648,18 @@ def test_flat_boundary():
mesh = meshplex.MeshTri(X, cells)

# Inspect the covolumes in left cell.
edge_length = np.sqrt(x ** 2 + y ** 2)
edge_length = np.sqrt(x**2 + y**2)
ref = np.array([edge_length, edge_length, 1.0])
assert np.all(np.abs(mesh.edge_lengths[:, 3] - ref) < 1.0e-12)
#
alpha = 0.5 / x * y * np.sqrt(y ** 2 + x ** 2)
beta = 0.5 / x * (x ** 2 - y ** 2)
alpha = 0.5 / x * y * np.sqrt(y**2 + x**2)
beta = 0.5 / x * (x**2 - y**2)
ref = [alpha, alpha, beta]
covolumes = mesh.ce_ratios[:, 3] * mesh.edge_lengths[:, 3]
assert np.all(np.abs(covolumes - ref) < 1.0e-12)

#
beta = np.sqrt(alpha ** 2 + 0.2 ** 2 + 0.25 ** 2)
beta = np.sqrt(alpha**2 + 0.2**2 + 0.25**2)
control_volume_corners = np.array(
[
mesh.cell_circumcenters[0][:2],
Expand Down
6 changes: 3 additions & 3 deletions tests/performance.py
Expand Up @@ -19,8 +19,8 @@ def setup(n):
# Compute the number of interior points such that all triangles can be somewhat
# equilateral.
edge_length = 2 * np.pi * radius / n
domain_area = np.pi - n * (radius ** 2 / 2 * (edge_length - np.sin(edge_length)))
cell_area = np.sqrt(3) / 4 * edge_length ** 2
domain_area = np.pi - n * (radius**2 / 2 * (edge_length - np.sin(edge_length)))
cell_area = np.sqrt(3) / 4 * edge_length**2
target_num_cells = domain_area / cell_area
# Euler:
# 2 * num_points - num_boundary_edges - 2 = num_cells
Expand Down Expand Up @@ -76,7 +76,7 @@ def flip_new(data):
perfplot.show(
setup=setup,
kernels=[flip_old, flip_new],
n_range=[2 ** k for k in range(5, 13)],
n_range=[2**k for k in range(5, 13)],
equality_check=None,
# set target time to 0 to avoid more than one repetition
target_time_per_measurement=0.0,
Expand Down
29 changes: 13 additions & 16 deletions tests/test_mesh_tetra.py
Expand Up @@ -60,7 +60,7 @@ def test_regular_tet0(a):
)

# cell volumes
vol = a ** 3 / 6.0 / np.sqrt(2)
vol = a**3 / 6.0 / np.sqrt(2)
assert is_near_equal(mesh.cell_volumes, [vol], tol)

# control volumes
Expand Down Expand Up @@ -161,12 +161,12 @@ def test_unit_tetrahedron_geometric(a):
assert is_near_equal(mesh.ce_ratios, ref, tol)

# cell volumes
assert is_near_equal(mesh.cell_volumes, [a ** 3 / 6.0], tol)
assert is_near_equal(mesh.cell_volumes, [a**3 / 6.0], tol)

# control volumes
assert is_near_equal(
mesh.control_volumes,
[a ** 3 / 8.0, a ** 3 / 72.0, a ** 3 / 72.0, a ** 3 / 72.0],
[a**3 / 8.0, a**3 / 72.0, a**3 / 72.0, a**3 / 72.0],
tol,
)

Expand Down Expand Up @@ -216,12 +216,12 @@ def test_regular_tet1_geometric_order():
assert is_near_equal(mesh.ce_ratios, ref, tol)

# cell volumes
assert is_near_equal(mesh.cell_volumes, [a ** 3 / 6.0], tol)
assert is_near_equal(mesh.cell_volumes, [a**3 / 6.0], tol)

# control volumes
assert is_near_equal(
mesh.control_volumes,
[a ** 3 / 72.0, a ** 3 / 8.0, a ** 3 / 72.0, a ** 3 / 72.0],
[a**3 / 72.0, a**3 / 8.0, a**3 / 72.0, a**3 / 72.0],
tol,
)

Expand Down Expand Up @@ -449,17 +449,14 @@ def test_toy_geometric():
def test_show_cell(render=False):
pytest.importorskip("vtk")

points = (
np.array(
[
[1.0, 0.0, -1.0 / np.sqrt(8)],
[-0.5, +np.sqrt(3.0) / 2.0, -1.0 / np.sqrt(8)],
[-0.5, -np.sqrt(3.0) / 2.0, -1.0 / np.sqrt(8)],
[0.0, 0.0, np.sqrt(2.0) - 1.0 / np.sqrt(8)],
]
)
/ np.sqrt(3.0)
)
points = np.array(
[
[1.0, 0.0, -1.0 / np.sqrt(8)],
[-0.5, +np.sqrt(3.0) / 2.0, -1.0 / np.sqrt(8)],
[-0.5, -np.sqrt(3.0) / 2.0, -1.0 / np.sqrt(8)],
[0.0, 0.0, np.sqrt(2.0) - 1.0 / np.sqrt(8)],
]
) / np.sqrt(3.0)

# points = np.array(
# [
Expand Down

0 comments on commit 80a4c26

Please sign in to comment.