Skip to content

Commit

Permalink
get value_shape and value_size from function space instead of ufl_ele…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
tommbendall committed Nov 18, 2024
1 parent cdd2982 commit 769ea54
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gusto/core/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def register_space(self, domain, space_name):
space = domain.spaces(space_name)

# Use the appropriate scalar function space if the space is vector
if np.prod(space.ufl_element().value_shape) > 1:
if np.prod(space.value_shape) > 1:
# TODO: get scalar space, and only compute coordinates if necessary
logger.warning(f'Space {space_name} has more than one dimension, '
+ 'and coordinates used for netCDF output have not '
Expand Down
8 changes: 4 additions & 4 deletions gusto/recovery/recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,20 +332,20 @@ def find_eff_coords(V0):
vec_DG1 = VectorFunctionSpace(mesh, DG1_element)
x = SpatialCoordinate(mesh)

if isinstance(V0.ufl_element(), VectorElement) or V0.ufl_element().value_size > 1:
if isinstance(V0.ufl_element(), VectorElement) or V0.value_size > 1:
eff_coords_list = []
V0_coords_list = []

# treat this separately for each component
for i in range(V0.ufl_element().value_size):
for i in range(V0.value_size):
# fill an d-dimensional list with i-th coordinate
x_list = [x[i] for j in range(V0.ufl_element().value_size)]
x_list = [x[i] for j in range(V0.value_size)]

# the i-th element in V0_coords_list is a vector with all components the i-th coord
ith_V0_coords = Function(V0).project(as_vector(x_list))
V0_coords_list.append(ith_V0_coords)

for i in range(V0.ufl_element().value_size):
for i in range(V0.value_size):
# slice through V0_coords_list to obtain the coords of the DOFs for that component
x_list = [V0_coords[i] for V0_coords in V0_coords_list]

Expand Down
2 changes: 1 addition & 1 deletion gusto/solvers/preconditioners.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def initialize(self, pc):
for i, Vi in enumerate(V):

# Vector-valued spaces will have a non-empty value_shape
if Vi.ufl_element().value_shape:
if Vi.value_shape:
self.vidx = i
else:
self.pidx = i
Expand Down

0 comments on commit 769ea54

Please sign in to comment.