-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding function to recombine mesh for generation of quad elements (#305)
* adding set_recombined_surfaces in geometry.py for generation of quad meshes and adding corresponding test in test_recombine.py. Related to issue #304 * reformatting test_recombine.py to pass ci/lint checks: * adding whitespace around arithmetic operator as indicated by ci/lint tests * using black to reformat * reformatting test_recombine.py
- Loading branch information
1 parent
e5216ff
commit 61882d9
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pygmsh | ||
import numpy as np | ||
|
||
|
||
def test(): | ||
geom = pygmsh.built_in.Geometry() | ||
p0 = geom.add_point((0.0, 0.0, 0.0), lcar=1.0) | ||
p1 = geom.add_point((2.0, 0.0, 0.0), lcar=1.0) | ||
p2 = geom.add_point((0.0, 1.0, 0.0), lcar=1.0) | ||
p3 = geom.add_point((2.0, 1.0, 0.0), lcar=1.0) | ||
l0 = geom.add_line(p0, p1) | ||
l1 = geom.add_line(p1, p3) | ||
l2 = geom.add_line(p3, p2) | ||
l3 = geom.add_line(p2, p0) | ||
ll0 = geom.add_line_loop((l0, l1, l2, l3)) | ||
rs0 = geom.add_surface(ll0) | ||
geom.set_transfinite_lines([l3, l1], 3, progression=1) | ||
geom.set_transfinite_lines([l2, l0], 3, progression=1) | ||
geom.set_transfinite_surface(rs0) | ||
geom.set_recombined_surfaces([rs0]) | ||
|
||
mesh = pygmsh.generate_mesh(geom) | ||
|
||
assert "quad" in mesh.cells.keys() | ||
ref = np.array([[0, 4, 8, 7], [7, 8, 6, 2], [4, 1, 5, 8], [8, 5, 3, 6]]) | ||
assert np.array_equal(ref, mesh.cells["quad"]) | ||
|
||
return mesh | ||
|
||
|
||
if __name__ == "__main__": | ||
import meshio | ||
|
||
meshio.write("rectangle_structured.vtk", test()) |