Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
meshpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Klöckner
meshpy
Commits
4a5865fc
Commit
4a5865fc
authored
10 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
ssh://github.com/inducer/meshpy
Conflicts: meshpy/gmsh_reader.py
parents
047bf078
9d0adc67
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
meshpy/gmsh_reader.py
+67
-0
67 additions, 0 deletions
meshpy/gmsh_reader.py
with
67 additions
and
0 deletions
meshpy/gmsh_reader.py
+
67
−
0
View file @
4a5865fc
...
...
@@ -46,6 +46,11 @@ Receiver interface
.. autoclass:: GmshMeshReceiverBase
Receiver example implementation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: GmshMeshReceiverNumPy
Reader
------
...
...
@@ -328,6 +333,68 @@ class GmshMeshReceiverBase(object):
# }}}
# {{{ 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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment