File: csg2d.py

package info (click to toggle)
netgen 6.2.2501%2Bdfsg1-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,980 kB
  • sloc: cpp: 165,197; tcl: 6,310; python: 2,804; sh: 522; makefile: 87
file content (37 lines) | stat: -rw-r--r-- 681 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from random import random, seed
from ngsolve import Draw, Mesh

import netgen
from pyngcore import *
from netgen.geom2d import *

seed(4)

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))
    inner += circle
    outer -= circle


g.Add(inner)
g.Add(outer)
geo = g.GenerateSplineGeometry()

m = geo.GenerateMesh(maxh=0.1)

try:
    from ngsolve import Draw, Mesh
    Draw(geo)
    mesh = Mesh(m)
    mesh.Curve(3)
    Draw(mesh)
except:
    pass