Skip to content

Commit

Permalink
Tweak box-in-box example to be less crashy
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Nov 26, 2014
1 parent fa8ef2d commit b2fb52f
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions examples/box-in-box.py
@@ -1,47 +1,41 @@
def main():
import numpy
from math import pi, cos, sin
from meshpy.tet import MeshInfo, build
from meshpy.geometry import GeometryBuilder, Marker, make_box

geob = GeometryBuilder()

box_marker = Marker.FIRST_USER_MARKER
extent_small = 0.1*numpy.ones(3, dtype=numpy.float64)
extent_small = 0.3*numpy.ones(3, dtype=numpy.float64)
points, facets, _, _ = \
make_box(-extent_small, extent_small)

geob.add_geometry(points, facets, facet_markers=box_marker)

# make small "separator box" for region attribute
geob.wrap_in_box(0.3)

points, facets, _, facet_markers = \
make_box(numpy.array([-1,-1,-1]), numpy.array([1,1,5]))
make_box(numpy.array([-1, -1, -1]), numpy.array([1, 1, 5]))

geob.add_geometry(points, facets, facet_markers=facet_markers)

mesh_info = MeshInfo()
geob.set(mesh_info)
mesh_info.set_holes([(0,0,0)])
#mesh_info.set_holes([(0, 0, 0)])

# region attributes
mesh_info.regions.resize(1)
mesh_info.regions[0] = (
# point in region
list(extent_small*2) + [
# region number
1,
# max volume in region
0.0001])

mesh = build(mesh_info, max_volume=0.02, volume_constraints=True, attributes=True)
[0, 0, 0] + [
# region number
1,
# max volume in region
0.001])

mesh = build(mesh_info, max_volume=0.06,
volume_constraints=True, attributes=True)
print ("%d elements" % len(mesh.elements))
mesh.write_vtk("box-in-box.vtk")




if __name__ == "__main__":
main()

0 comments on commit b2fb52f

Please sign in to comment.