Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions examples/01_random_field/05_mesh_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@

- `points="points"` will generate a field on the mesh points
- `points="centroids"` will generate a field on the cell centroids

In this example, we will generate a simple mesh with the aid of
`meshzoo <https://github.com/nschloe/meshzoo>`_.
"""

import matplotlib.pyplot as plt
import matplotlib.tri as tri
import meshio
import meshzoo
import numpy as np

import gstools as gs

# generate a triangulated hexagon with meshzoo
points, cells = meshzoo.ngon(6, 4)
# read a triangulated hexagon with meshio
mesh_input = meshio.read("hexagon.mesh")
points = mesh_input.points
cells = mesh_input.cells[0].data
mesh = meshio.Mesh(points, {"triangle": cells})
Copy link
Member

@MuellerSeb MuellerSeb Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the mesh_input already a mesh? Why do we need to extract points and cells to create the mesh again?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Their is a difference in the Mesh instance depending on whether it is read in from the "hexagon.mesh" file or created with meshzoo. The code breaks further down, because the cells are not as expected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I would prefer two files read with numpy (one for points[float], one for cells[int]) because this seems odd.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea, I just implemented that.


###############################################################################
Expand Down
167 changes: 167 additions & 0 deletions examples/01_random_field/hexagon.mesh
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
MeshVersionFormatted 2
Dimension 2

Vertices
61
0.0000000000000000e+00 0.0000000000000000e+00 1
6.1232339957367660e-17 1.0000000000000000e+00 1
-8.6602540378443849e-01 5.0000000000000033e-01 1
-8.6602540378443882e-01 -4.9999999999999972e-01 1
-1.8369701987210297e-16 -1.0000000000000000e+00 1
8.6602540378443837e-01 -5.0000000000000044e-01 1
8.6602540378443904e-01 4.9999999999999928e-01 1
1.5308084989341915e-17 2.5000000000000000e-01 1
3.0616169978683830e-17 5.0000000000000000e-01 1
4.5924254968025742e-17 7.5000000000000000e-01 1
-2.1650635094610957e-01 8.7500000000000011e-01 1
-4.3301270189221919e-01 7.5000000000000022e-01 1
-6.4951905283832889e-01 6.2500000000000022e-01 1
-4.5924254968025742e-17 -2.5000000000000000e-01 1
-9.1848509936051484e-17 -5.0000000000000000e-01 1
-1.3777276490407724e-16 -7.5000000000000000e-01 1
-6.4951905283832911e-01 -6.2499999999999978e-01 1
-4.3301270189221952e-01 -7.4999999999999989e-01 1
-2.1650635094610984e-01 -8.7499999999999989e-01 1
-2.1650635094610970e-01 -1.2499999999999993e-01 1
-4.3301270189221941e-01 -2.4999999999999986e-01 1
-6.4951905283832911e-01 -3.7499999999999978e-01 1
2.1650635094610976e-01 1.2499999999999982e-01 1
4.3301270189221952e-01 2.4999999999999964e-01 1
6.4951905283832922e-01 3.7499999999999944e-01 1
-8.6602540378443860e-01 2.5000000000000028e-01 1
-8.6602540378443860e-01 3.0531133177191805e-16 1
-8.6602540378443871e-01 -2.4999999999999969e-01 1
-2.1650635094610962e-01 1.2500000000000008e-01 1
-4.3301270189221924e-01 2.5000000000000017e-01 1
-6.4951905283832889e-01 3.7500000000000022e-01 1
2.1650635094610945e-01 -8.7500000000000011e-01 1
4.3301270189221908e-01 -7.5000000000000022e-01 1
6.4951905283832878e-01 -6.2500000000000033e-01 1
8.6602540378443860e-01 -2.5000000000000050e-01 1
8.6602540378443871e-01 -5.8286708792820718e-16 1
8.6602540378443882e-01 2.4999999999999933e-01 1
2.1650635094610959e-01 -1.2500000000000011e-01 1
4.3301270189221919e-01 -2.5000000000000022e-01 1
6.4951905283832878e-01 -3.7500000000000033e-01 1
2.1650635094610982e-01 8.7499999999999978e-01 1
4.3301270189221958e-01 7.4999999999999967e-01 1
6.4951905283832922e-01 6.2499999999999944e-01 1
-2.1650635094610959e-01 3.7500000000000011e-01 1
-2.1650635094610959e-01 6.2500000000000011e-01 1
-4.3301270189221924e-01 5.0000000000000022e-01 1
-4.3301270189221930e-01 1.5265566588595902e-16 1
-6.4951905283832900e-01 1.2500000000000022e-01 1
-6.4951905283832900e-01 -1.2499999999999978e-01 1
-2.1650635094610976e-01 -3.7499999999999994e-01 1
-4.3301270189221946e-01 -4.9999999999999989e-01 1
-2.1650635094610979e-01 -6.2499999999999989e-01 1
2.1650635094610954e-01 -3.7500000000000011e-01 1
2.1650635094610951e-01 -6.2500000000000011e-01 1
4.3301270189221913e-01 -5.0000000000000022e-01 1
4.3301270189221935e-01 -2.9143354396410359e-16 1
6.4951905283832900e-01 -1.2500000000000039e-01 1
6.4951905283832911e-01 1.2499999999999953e-01 1
2.1650635094610979e-01 3.7499999999999983e-01 1
4.3301270189221952e-01 4.9999999999999967e-01 1
2.1650635094610979e-01 6.2499999999999978e-01 1

Triangles
96
1 8 29 1
8 9 44 1
9 10 45 1
10 2 11 1
8 44 29 1
9 45 44 1
10 11 45 1
29 44 30 1
44 45 46 1
45 11 12 1
44 46 30 1
45 12 46 1
30 46 31 1
46 12 13 1
46 13 31 1
31 13 3 1
1 29 20 1
29 30 47 1
30 31 48 1
31 3 26 1
29 47 20 1
30 48 47 1
31 26 48 1
20 47 21 1
47 48 49 1
48 26 27 1
47 49 21 1
48 27 49 1
21 49 22 1
49 27 28 1
49 28 22 1
22 28 4 1
1 20 14 1
20 21 50 1
21 22 51 1
22 4 17 1
20 50 14 1
21 51 50 1
22 17 51 1
14 50 15 1
50 51 52 1
51 17 18 1
50 52 15 1
51 18 52 1
15 52 16 1
52 18 19 1
52 19 16 1
16 19 5 1
1 14 38 1
14 15 53 1
15 16 54 1
16 5 32 1
14 53 38 1
15 54 53 1
16 32 54 1
38 53 39 1
53 54 55 1
54 32 33 1
53 55 39 1
54 33 55 1
39 55 40 1
55 33 34 1
55 34 40 1
40 34 6 1
1 38 23 1
38 39 56 1
39 40 57 1
40 6 35 1
38 56 23 1
39 57 56 1
40 35 57 1
23 56 24 1
56 57 58 1
57 35 36 1
56 58 24 1
57 36 58 1
24 58 25 1
58 36 37 1
58 37 25 1
25 37 7 1
1 23 8 1
23 24 59 1
24 25 60 1
25 7 43 1
23 59 8 1
24 60 59 1
25 43 60 1
8 59 9 1
59 60 61 1
60 43 42 1
59 61 9 1
60 42 61 1
9 61 10 1
61 42 41 1
61 41 10 1
10 41 2 1

End
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ dependencies = [
doc = [
"myst_parser",
"matplotlib>=3.7",
"meshzoo>=0.7",
"numpydoc>=1.1",
"pykrige>=1.5,<2",
"pyvista>=0.40",
Expand All @@ -71,7 +70,7 @@ plotting = [
"matplotlib>=3.7",
"pyvista>=0.40",
]
rust = ["gstools_core>=1.0.0"]
rust = ["gstools_core>=1.1.0"]
test = ["pytest-cov>=3"]
lint = [
"black>=24",
Expand Down
Loading