Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
meshmode
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
Ellis Hoag
meshmode
Commits
9995589b
Commit
9995589b
authored
10 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Improve IO user interface around force_ambient_dim
parent
5f33af50
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
meshmode/mesh/io.py
+22
-7
22 additions, 7 deletions
meshmode/mesh/io.py
with
22 additions
and
7 deletions
meshmode/mesh/io.py
+
22
−
7
View file @
9995589b
...
...
@@ -162,27 +162,27 @@ class GmshMeshReceiver(GmshMeshReceiverBase):
# }}}
def
read_gmsh
(
filename
,
force_ambient_dim
ension
=
None
):
def
read_gmsh
(
filename
,
force_ambient_dim
=
None
):
"""
Read a gmsh mesh file from *filename* and return a
:class:`meshmode.mesh.Mesh`.
:arg force_
dimension
: if not None, truncate point coordinates to
:arg force_
ambient_dim
: if not None, truncate point coordinates to
this many dimensions.
"""
from
meshpy.gmsh_reader
import
read_gmsh
recv
=
GmshMeshReceiver
()
read_gmsh
(
recv
,
filename
,
force_dimension
=
force_ambient_dim
ension
)
read_gmsh
(
recv
,
filename
,
force_dimension
=
force_ambient_dim
)
return
recv
.
get_mesh
()
def
generate_gmsh
(
source
,
dimensions
,
order
=
None
,
other_options
=
[],
extension
=
"
geo
"
,
gmsh_executable
=
"
gmsh
"
,
force_ambient_dim
ension
=
None
):
extension
=
"
geo
"
,
gmsh_executable
=
"
gmsh
"
,
force_ambient_dim
=
None
):
"""
Run :cmd:`gmsh` on the input given by *source*, and return a
:class:`meshmode.mesh.Mesh` based on the result.
:arg source: an instance of either :class:`FileSource` or
:class:`LiteralSource`
:arg force_ambient_dim
ension
: if not None, truncate point coordinates to
:arg force_ambient_dim: if not None, truncate point coordinates to
this many dimensions.
"""
recv
=
GmshMeshReceiver
()
...
...
@@ -193,6 +193,21 @@ def generate_gmsh(source, dimensions, order=None, other_options=[],
other_options
=
other_options
,
extension
=
extension
,
gmsh_executable
=
gmsh_executable
)
as
runner
:
parse_gmsh
(
recv
,
runner
.
output_file
,
force_dimension
=
force_ambient_dim
ension
)
force_dimension
=
force_ambient_dim
)
return
recv
.
get_mesh
()
mesh
=
recv
.
get_mesh
()
if
force_ambient_dim
is
None
:
AXIS_NAMES
=
"
xyz
"
dim
=
mesh
.
vertices
.
shape
[
0
]
for
idim
in
range
(
dim
):
if
(
mesh
.
vertices
[
idim
]
==
0
).
all
():
from
warnings
import
warn
warn
(
"
all vertices
'
%s coordinate is zero--perhaps you want to pass
"
"
force_ambient_dim=%d (pass any fixed value to
"
"
force_ambient_dim to silence this warning)
"
%
(
AXIS_NAMES
[
idim
],
idim
))
break
return
mesh
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