3
3
"""
4
4
5
5
import splinepy as spp
6
- import splinepy .io . gismo as gismo
6
+ from splinepy .io import gismo
7
7
8
8
EPS = 1e-8
9
9
10
10
# Create multipatch geometry
11
11
arc_inner = spp .NURBS (
12
- degrees = [1 ,2 ],
13
- knot_vectors = [
14
- [0.0 , 0.0 , 1.0 , 1.0 ],
15
- [0.0 , 0.0 , 0.0 , 1.0 , 1.0 , 1.0 ]
16
- ],
12
+ degrees = [1 , 2 ],
13
+ knot_vectors = [[0.0 , 0.0 , 1.0 , 1.0 ], [0.0 , 0.0 , 0.0 , 1.0 , 1.0 , 1.0 ]],
17
14
control_points = [
18
15
[1.0 , 0.0 ],
19
16
[2.0 , 0.0 ],
20
17
[1.0 , 1.0 ],
21
18
[2.0 , 2.0 ],
22
19
[0.0 , 1.0 ],
23
- [0.0 , 2.0 ]
20
+ [0.0 , 2.0 ],
24
21
],
25
- weights = [1.0 , 1.0 , 0.707106781186548 , 0.707106781186548 , 1.0 , 1.0 ]
22
+ weights = [1.0 , 1.0 , 0.707106781186548 , 0.707106781186548 , 1.0 , 1.0 ],
26
23
)
27
24
28
25
arc_outer = arc_inner .copy ()
32
29
[2.0 , 2.0 ],
33
30
[3.0 , 3.0 ],
34
31
[0.0 , 2.0 ],
35
- [0.0 , 3.0 ]
32
+ [0.0 , 3.0 ],
36
33
]
37
34
38
- multipatch = spp .Multipatch (
39
- splines = [arc_inner , arc_outer ]
40
- )
35
+ multipatch = spp .Multipatch (splines = [arc_inner , arc_outer ])
41
36
multipatch .determine_interfaces ()
42
37
38
+
43
39
# Identifies the patches' boundaries which correspond to the Dirichlet BCs
44
40
def dirichlet_identifier (points ):
45
- return (points [:,1 ] < EPS ) | ((points [:,0 ] < EPS ) & (points [:,1 ] > 2 - EPS ))
41
+ return (points [:, 1 ] < EPS ) | (
42
+ (points [:, 0 ] < EPS ) & (points [:, 1 ] > 2 - EPS )
43
+ )
44
+
46
45
47
46
# Set Dirichlet boundaries to "BID2", Neumann BCs correspond to "BID1"
48
47
multipatch .boundary_from_function (dirichlet_identifier , boundary_id = 2 )
@@ -52,15 +51,15 @@ def dirichlet_identifier(points):
52
51
dim = 2 ,
53
52
function_id = 1 ,
54
53
function_string = "2*pi^2*sin(pi*x)*sin(pi*y)" ,
55
- comment = "Right-hand side function"
54
+ comment = "Right-hand side function" ,
56
55
)
57
56
58
57
# Create function block for manufactured solution
59
58
manufactured_solution = gismo .create_function_block (
60
59
dim = 2 ,
61
60
function_id = 3 ,
62
61
function_string = "sin(pi*x) * sin(pi*y)" ,
63
- comment = "The manufactured exact solution (for reference)"
62
+ comment = "The manufactured exact solution (for reference)" ,
64
63
)
65
64
66
65
# Create block for boundary conditions
@@ -70,35 +69,42 @@ def dirichlet_identifier(points):
70
69
function_list = [
71
70
"sin(pi*x) * sin(pi*y)" ,
72
71
("pi*cos(pi*x) * sin(pi*y)" , "pi*sin(pi*x) * cos(pi*y)" ),
73
- "0"
74
- ],
75
- bc_list = [
76
- ("BID2" , "Dirichlet" , 0 ),
77
- ("BID1" , "Neumann" , 1 )
72
+ "0" ,
78
73
],
74
+ bc_list = [("BID2" , "Dirichlet" , 0 ), ("BID1" , "Neumann" , 1 )],
79
75
unknown_id = 0 ,
80
76
multipatch_id = 0 ,
81
- comment = "The boundary conditions (multipatch=number of patches)"
77
+ comment = "The boundary conditions (multipatch=number of patches)" ,
82
78
)
83
79
84
80
# Create dictionary for assembly options
85
81
assembly_options = gismo .create_assembly_options_block (
86
- options_id = 4 ,
87
- comment = "Assembler options"
82
+ options_id = 4 , comment = "Assembler options"
88
83
)
89
84
90
85
# Visualize geometry and BCs
91
86
boundary_names = ["Neumann boundary" , "Dirichlet boundary" ]
92
87
spp .show (
93
88
["Multipatch" , multipatch ],
94
- * [[f"BID{ i + 1 } : { boundary_names [i ]} " , multipatch .boundary_multipatch (i + 1 )] for i in range (len (multipatch .boundaries ))],
95
- control_points = False
89
+ * [
90
+ [
91
+ f"BID{ i + 1 } : { boundary_names [i ]} " ,
92
+ multipatch .boundary_multipatch (i + 1 ),
93
+ ]
94
+ for i in range (len (multipatch .boundaries ))
95
+ ],
96
+ control_points = False ,
96
97
)
97
98
98
99
# Export to xml-file
99
100
gismo .export (
100
101
fname = "poisson2d_bvp_recreation.xml" ,
101
102
multipatch = multipatch ,
102
103
indent = True ,
103
- options = [rhs , boundary_conditions , manufactured_solution , assembly_options ]
104
- )
104
+ options = [
105
+ rhs ,
106
+ boundary_conditions ,
107
+ manufactured_solution ,
108
+ assembly_options ,
109
+ ],
110
+ )
0 commit comments