New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add an unstructured grid #9
Comments
There already exits an implementation of a gmsh reader in the playground: https://github.com/pymor/pymor/blob/master/src/pymor/playground/grids/gmsh.py Maybe you could comment on what is working/missing at some point?, @sdrave |
The idea is to make this implementation actually usable. Main issues:
Currently plans are that @michaellaier will work a bit on this in the not so distant future. |
@michaellaier, in case you haven't started working on it yet: It might also be a good option to use triangle instead of gmsh. There is a nice Python wrapper which also builds triangle itself for you if you run Here is a basic example to get started: import numpy as np
import triangle
import matplotlib
from matplotlib.pyplot import *
angles = np.linspace(0, 1.75*np.pi, 20)
vertices = np.array([np.cos(angles), np.sin(angles)]).T
vertices = np.vstack([vertices, [0., 0.]])
segments = np.array([np.arange(len(vertices)), np.arange(1, len(vertices)+1)]).T
segments[-1, -1] = 0
segment_markers = np.arange(1, len(segments) + 1)
R = triangle.triangulate({'vertices': vertices, 'segments': segments, 'segment_markers': segment_markers}, 'pqa0.01')
segment_coords = R['vertices'][R['segments']]
gca().tripcolor(R['vertices'][:, 0], R['vertices'][:, 1], R['triangles'], facecolors=np.arange(len(R['triangles'])))
cmap = matplotlib.cm.get_cmap()
for l, m in zip(segment_coords, R['segment_markers']):
plot(l[:, 0], l[:, 1], color=cmap(float(m)/len(segments)), linewidth=3)
show() |
There is a problem with passing floats to triangle in the option string, however. If localization support in libc is activated (as it happens when you use matplotlib, but triangle does not activate it!), the float is parsed according to For development, I would simply |
Regarding the implementation of the grid, it would probably wise, to implement a grid satisfying the interface, which uses a vertex array and a triangle array of vertex indices as input. This could be used for gmsh output as well as triangle output. |
No description provided.
The text was updated successfully, but these errors were encountered: