forked from NGSolve/netgen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10a9dec
commit 2763285
Showing
2 changed files
with
48 additions
and
38 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 |
---|---|---|
@@ -1,50 +1,37 @@ | ||
from ngsolve import * | ||
|
||
from random import random, seed | ||
ngsglobals.msg_level = 0 | ||
from ngsolve import Draw, Mesh | ||
|
||
import netgen | ||
from pyngcore import * | ||
from netgen.geom2d import * | ||
|
||
seed(4) | ||
|
||
def GenerateMesh(): | ||
|
||
g = CSG2d() | ||
g1 = CSG2d() | ||
outer = Rectangle(0, 1, 0, 1,"outer","outer") | ||
inner = Solid2d() | ||
g = CSG2d() | ||
outer = Rectangle((0, 0), (1, 1), "outer","outer") | ||
inner = Solid2d() | ||
|
||
for i in range(30): | ||
cx = random() | ||
cy = random() | ||
r = 0.03+0.05*random() | ||
print("Add Circle", i, cx, cy, r, flush = True) | ||
circle = Circle(cx, cy, r, "circle"+str(i), "circle"+str(i)) | ||
g1.Add(circle) | ||
inner += circle | ||
outer -= circle | ||
for i in range(30): | ||
cx = random() | ||
cy = random() | ||
r = 0.03+0.05*random() | ||
print("Add Circle", i, cx, cy, r, flush = True) | ||
circle = Circle((cx, cy), r, "circle"+str(i), "circle"+str(i)) | ||
inner += circle | ||
outer -= circle | ||
|
||
|
||
g.Add(inner) | ||
g.Add(outer) | ||
geo = g.GenerateSplineGeometry() | ||
Draw(geo) | ||
g.Add(inner) | ||
g.Add(outer) | ||
geo = g.GenerateSplineGeometry() | ||
|
||
# draw this geometry for checking ff the final mesh/geometry is correct | ||
# g1.Add(outer) | ||
# geo1 = g1.GenerateSplineGeometry() | ||
# Draw(geo1) | ||
m = geo.GenerateMesh(maxh=0.1) | ||
|
||
print('generate mesh') | ||
m = geo.GenerateMesh(maxh=0.1) | ||
try: | ||
from ngsolve import Draw, Mesh | ||
Draw(geo) | ||
mesh = Mesh(m) | ||
mesh.Curve(3) | ||
Draw(mesh) | ||
|
||
return mesh | ||
|
||
from ngsolve import Draw | ||
with PajeTrace(): | ||
mesh = GenerateMesh() | ||
except: | ||
pass |