Skip to content

Commit c3d92ab

Browse files
pre-commit-ci[bot]j042
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent f53b9d6 commit c3d92ab

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

examples/export_gismo.py

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,23 @@
33
"""
44

55
import splinepy as spp
6-
import splinepy.io.gismo as gismo
6+
from splinepy.io import gismo
77

88
EPS = 1e-8
99

1010
# Create multipatch geometry
1111
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]],
1714
control_points=[
1815
[1.0, 0.0],
1916
[2.0, 0.0],
2017
[1.0, 1.0],
2118
[2.0, 2.0],
2219
[0.0, 1.0],
23-
[0.0, 2.0]
20+
[0.0, 2.0],
2421
],
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],
2623
)
2724

2825
arc_outer = arc_inner.copy()
@@ -32,17 +29,19 @@
3229
[2.0, 2.0],
3330
[3.0, 3.0],
3431
[0.0, 2.0],
35-
[0.0, 3.0]
32+
[0.0, 3.0],
3633
]
3734

38-
multipatch = spp.Multipatch(
39-
splines=[arc_inner, arc_outer]
40-
)
35+
multipatch = spp.Multipatch(splines=[arc_inner, arc_outer])
4136
multipatch.determine_interfaces()
4237

38+
4339
# Identifies the patches' boundaries which correspond to the Dirichlet BCs
4440
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+
4645

4746
# Set Dirichlet boundaries to "BID2", Neumann BCs correspond to "BID1"
4847
multipatch.boundary_from_function(dirichlet_identifier, boundary_id=2)
@@ -52,15 +51,15 @@ def dirichlet_identifier(points):
5251
dim=2,
5352
function_id=1,
5453
function_string="2*pi^2*sin(pi*x)*sin(pi*y)",
55-
comment="Right-hand side function"
54+
comment="Right-hand side function",
5655
)
5756

5857
# Create function block for manufactured solution
5958
manufactured_solution = gismo.create_function_block(
6059
dim=2,
6160
function_id=3,
6261
function_string="sin(pi*x) * sin(pi*y)",
63-
comment="The manufactured exact solution (for reference)"
62+
comment="The manufactured exact solution (for reference)",
6463
)
6564

6665
# Create block for boundary conditions
@@ -70,35 +69,42 @@ def dirichlet_identifier(points):
7069
function_list=[
7170
"sin(pi*x) * sin(pi*y)",
7271
("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",
7873
],
74+
bc_list=[("BID2", "Dirichlet", 0), ("BID1", "Neumann", 1)],
7975
unknown_id=0,
8076
multipatch_id=0,
81-
comment="The boundary conditions (multipatch=number of patches)"
77+
comment="The boundary conditions (multipatch=number of patches)",
8278
)
8379

8480
# Create dictionary for assembly options
8581
assembly_options = gismo.create_assembly_options_block(
86-
options_id=4,
87-
comment="Assembler options"
82+
options_id=4, comment="Assembler options"
8883
)
8984

9085
# Visualize geometry and BCs
9186
boundary_names = ["Neumann boundary", "Dirichlet boundary"]
9287
spp.show(
9388
["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,
9697
)
9798

9899
# Export to xml-file
99100
gismo.export(
100101
fname="poisson2d_bvp_recreation.xml",
101102
multipatch=multipatch,
102103
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

Comments
 (0)