Skip to content

Commit 5341048

Browse files
akarve1507jorgensd
andauthored
Update chapter2/monolithic_navierstokes_crp0.py
Co-authored-by: Jørgen Schartum Dokken <dokken92@gmail.com>
1 parent 7a18b68 commit 5341048

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

chapter2/monolithic_navierstokes_crp0.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,19 @@ def parse_args():
5555
top_facets = mesh.locate_entities_boundary(domain, fdim, lambda x: np.isclose(x[1], args.Ly))
5656

5757
# Tag: 1=left, 2=right, 3=bottom, 4=top
58-
facet_indices = np.concatenate([left_facets, right_facets, bottom_facets, top_facets]).astype(np.int32)
59-
facet_tags = np.concatenate([
60-
np.full_like(left_facets, 1, dtype=np.int32),
61-
np.full_like(right_facets, 2, dtype=np.int32),
62-
np.full_like(bottom_facets, 3, dtype=np.int32),
63-
np.full_like(top_facets, 4, dtype=np.int32),
64-
])
65-
66-
# Create facet meshtags
67-
if facet_indices.size == 0:
68-
ft = mesh.meshtags(domain, fdim, np.array([], dtype=np.int32), np.array([], dtype=np.int32))
69-
else:
70-
order = np.argsort(facet_indices)
71-
ft = mesh.meshtags(domain, fdim, facet_indices[order], facet_tags[order])
58+
num_facets_local = (
59+
domain.topology.index_map(fdim).size_local
60+
+ domain.topology.index_map(fdim).num_ghosts
61+
)
62+
facet_markers = np.full(num_facets_local, 0, dtype=np.int32)
63+
facet_markers[left_facets] = 1
64+
facet_markers[right_facets] = 2
65+
facet_markers[bottom_facets] = 3
66+
facet_markers[top_facets] = 4
67+
facet_indices = np.flatnonzero(facet_markers)
68+
69+
ft = mesh.meshtags(domain, fdim, facet_indices, facet_markers[facet_indices])
70+
7271

7372
dx = ufl.Measure("dx", domain=domain)
7473
ds = ufl.Measure("ds", domain=domain, subdomain_data=ft)

0 commit comments

Comments
 (0)