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

Closed
sdrave opened this Issue Apr 8, 2013 · 5 comments

Comments

Projects
None yet
2 participants
@sdrave
Member

sdrave commented Apr 8, 2013

No description provided.

@sdrave sdrave added this to the 0.4 milestone Jun 17, 2015

@ftalbrecht

This comment has been minimized.

Member

ftalbrecht commented Jun 19, 2015

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

@sdrave

This comment has been minimized.

Member

sdrave commented Jun 27, 2015

The idea is to make this implementation actually usable. Main issues:

  1. The code hasn't been tested for quite a while.
  2. I believe there were some performance issues.
  3. We need a standardized way to obtain a BoundaryInfo from the gmsh data as well.
  4. Nice to have: Implement a domain discretizer which creates gmsh input files from DomainDescriptions (also add a PolygonalDomain, or something like that), runs gmsh and then loads the output into pyMOR.

Currently plans are that @michaellaier will work a bit on this in the not so distant future.

@sdrave

This comment has been minimized.

Member

sdrave commented Sep 4, 2015

@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 pip install triangle.

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()

figure_1

@sdrave

This comment has been minimized.

Member

sdrave commented Sep 4, 2015

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 LC_NUMERIC. So if LC_NUMERIC=de, you would have to write 0,1 instead of 0.1. The wrong format will crash trianagle (and thus the whole process), since atof will incorrectly parse the string as 0.

For development, I would simply unset LC_NUMERIC, and worry about this issue later.

@sdrave

This comment has been minimized.

Member

sdrave commented Sep 4, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment