Skip to content

Commit

Permalink
Generalize functions related to extracting vertex information from FE…
Browse files Browse the repository at this point in the history
…niCS (#147)

* Generalize functions related to extracting vertex information from FEniCS

* Changing to iteratable variable range(dims)
  • Loading branch information
IshaanDesai authored Jan 19, 2022
1 parent 1ec2179 commit 67a48b6
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions fenicsprecice/adapter_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,7 @@ def get_fenics_vertices(function_space, coupling_subdomain, dims):
if coupling_subdomain.inside(v.point(), True):
lids.append(v.index())
gids.append(v.global_index())
if dims == 2:
coords.append([v.x(0), v.x(1)])
if dims == 3:
coords.append([v.x(0), v.x(1), v.x(2)])
coords.append([v.x(d) for d in range(dims)])

return np.array(lids), np.array(gids), np.array(coords)

Expand Down Expand Up @@ -280,13 +277,8 @@ def get_owned_vertices(function_space, coupling_subdomain, dims):
# Get coordinates and global IDs of all vertices of the mesh which lie on the coupling boundary.
# These vertices include shared (owned + unowned) and non-shared vertices in a parallel setting
gids, lids, coords = [], [], []
coord = None
for v in coupling_vertices:
if dims == 2:
coord = [v.x(0), v.x(1)]
elif dims == 3:
coord = [v.x(0), v.x(1), v.x(2)]

coord = [v.x(d) for d in range(dims)]
for dof in dofs:
if (dof == coord).all():
gids.append(v.global_index())
Expand Down Expand Up @@ -344,14 +336,9 @@ def get_unowned_vertices(function_space, coupling_subdomain, dims):
# Get coordinates and global IDs of all vertices of the mesh which lie on the coupling boundary.
# These vertices include shared (owned + unowned) and non-shared vertices in a parallel setting
gids = []
coord = None
for v in coupling_verts:
ownership = False
if dims == 2:
coord = [v.x(0), v.x(1)]
elif dims == 3:
coord = [v.x(0), v.x(1), v.x(2)]

coord = [v.x(d) for d in range(dims)]
for dof in dofs:
if (dof == coord).all():
ownership = True
Expand Down

0 comments on commit 67a48b6

Please sign in to comment.