Skip to content

Commit

Permalink
Merge branch 'master' of ssh://github.com/inducer/meshpy
Browse files Browse the repository at this point in the history
Conflicts:
	meshpy/gmsh_reader.py
  • Loading branch information
inducer committed May 27, 2014
2 parents 047bf07 + 9d0adc6 commit 4a5865f
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions meshpy/gmsh_reader.py
Expand Up @@ -46,6 +46,11 @@
.. autoclass:: GmshMeshReceiverBase
Receiver example implementation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: GmshMeshReceiverNumPy
Reader
------
Expand Down Expand Up @@ -328,6 +333,68 @@ def finalize_tags(self):
# }}}


# {{{ receiver example

class GmshMeshReceiverNumPy(GmshMeshReceiverBase):
"""GmshReceiver that emulates the semantics of
:class:`meshpy.triangle.MeshInfo` and :class:`meshpy.tet.MeshInfo` by using
similar fields, but instead of loading data into ForeignArrays, load into
NumPy arrays. Since this class is not wrapping any libraries in other
languages -- the Gmsh data is obtained via parsing text -- use :mod:`numpy`
arrays as the base array data structure for convenience.
.. versionadded:: 2014.1
"""

# Use data fields similar to meshpy.triangle.MeshInfo and meshpy.tet.MeshInfo
points = None
elements = None
element_types = None
element_markers = None
tags = None

# Gmsh has no explicit concept of facets or faces; certain faces are a type
# of element. Consequently, there are no face markers, but elements can be
# grouped together in physical groups that serve as markers.

def set_up_nodes(self, count):
# Preallocate array of nodes within list; treat None as sentinel value.
# Preallocation not done for performance, but to assign values at indices
# in random order.
self.points = [None] * count

def add_node(self, node_nr, point):
self.points[node_nr] = point

def finalize_nodes(self):
pass

def set_up_elements(self, count):
# Preallocation of arrays for assignment elements in random order.
self.elements = [None] * count
self.element_types = [None] * count
self.element_markers = [None] * count
self.tags = []

def add_element(self, element_nr, element_type, vertex_nrs,
lexicographic_nodes, tag_numbers):
self.elements[element_nr] = vertex_nrs
self.element_types[element_nr] = element_type
self.element_markers[element_nr] = tag_numbers
# TODO: Add lexicographic node information

def finalize_elements(self):
pass

def add_tag(self, name, index, dimension):
self.tags.append((name, index, dimension))

def finalize_tags(self):
pass

# }}}


# {{{ file reader

class GmshFileFormatError(RuntimeError):
Expand Down

0 comments on commit 4a5865f

Please sign in to comment.