Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gusto/complex_proxy/mixed_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def FunctionSpace(V):

:arg V: the real-valued FunctionSpace.
"""
return fd.FunctionSpace(V.mesh(), FiniteElement(V.ufl_element()))
return fd.FunctionSpace(V.mesh().unique(), FiniteElement(V.ufl_element()))


def DirichletBC(W, V, bc, function_arg=None):
Expand Down
10 changes: 5 additions & 5 deletions gusto/core/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ def __init__(self, mesh, on_sphere=False, rotated_pole=None, radius=None):
self.coords_name = ['lon', 'lat']
else:
self.coords = SpatialCoordinate(mesh)
if mesh.geometric_dimension() == 1:
if mesh.geometric_dimension == 1:
self.coords_name = ['x']
elif mesh.geometric_dimension() == 2 and mesh.extruded:
elif mesh.geometric_dimension == 2 and mesh.extruded:
self.coords_name = ['x', 'z']
elif mesh.geometric_dimension() == 2:
elif mesh.geometric_dimension == 2:
self.coords_name = ['x', 'y']
elif mesh.geometric_dimension() == 3:
elif mesh.geometric_dimension == 3:
self.coords_name = ['x', 'y', 'z']
else:
raise ValueError('Cannot work out coordinates of domain')
Expand Down Expand Up @@ -86,7 +86,7 @@ def register_space(self, domain, space_name):
"""

comm = self.mesh.comm
topological_dimension = self.mesh.topological_dimension()
topological_dimension = self.mesh.topological_dimension

if space_name in self.chi_coords.keys():
logger.warning(f'Coords for {space_name} space have already been computed')
Expand Down
14 changes: 7 additions & 7 deletions gusto/core/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ def __init__(self, mesh, dt, family, degree=None,
# WARNING: if we ever wanted to run on other domains (e.g. circle, disk
# or torus) then the identification of domains would no longer be unique
if hasattr(mesh, "_base_mesh") and hasattr(mesh._base_mesh, 'geometric_dimension'):
self.on_sphere = (mesh._base_mesh.geometric_dimension() == 3 and mesh._base_mesh.topological_dimension() == 2)
self.on_sphere = (mesh._base_mesh.geometric_dimension == 3 and mesh._base_mesh.topological_dimension == 2)
else:
self.on_sphere = (mesh.geometric_dimension() == 3 and mesh.topological_dimension() == 2)
self.on_sphere = (mesh.geometric_dimension == 3 and mesh.topological_dimension == 2)

# build the vertical normal and define perp for 2d geometries
dim = mesh.topological_dimension()
dim = mesh.topological_dimension
if self.on_sphere:
x = SpatialCoordinate(mesh)
R = sqrt(inner(x, x))
Expand Down Expand Up @@ -223,13 +223,13 @@ def construct_domain_metadata(mesh, coords, on_sphere):
metadata['domain_type'] = 'extruded_spherical_shell'
elif on_sphere:
metadata['domain_type'] = 'spherical_shell'
elif mesh.geometric_dimension() == 1 and mesh.topological_dimension() == 1:
elif mesh.geometric_dimension == 1 and mesh.topological_dimension == 1:
metadata['domain_type'] = 'interval'
elif mesh.geometric_dimension() == 2 and mesh.topological_dimension() == 2 and mesh.extruded:
elif mesh.geometric_dimension == 2 and mesh.topological_dimension == 2 and mesh.extruded:
metadata['domain_type'] = 'vertical_slice'
elif mesh.geometric_dimension() == 2 and mesh.topological_dimension() == 2:
elif mesh.geometric_dimension == 2 and mesh.topological_dimension == 2:
metadata['domain_type'] = 'plane'
elif mesh.geometric_dimension() == 3 and mesh.topological_dimension() == 3 and mesh.extruded:
elif mesh.geometric_dimension == 3 and mesh.topological_dimension == 3 and mesh.extruded:
metadata['domain_type'] = 'extruded_plane'
else:
raise ValueError('Unable to determine domain type')
Expand Down
10 changes: 5 additions & 5 deletions gusto/core/function_spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ def build_dg1_equispaced(self):
"""

if self.extruded_mesh:
cell = self.mesh._base_mesh.ufl_cell().cellname()
cell = self.mesh._base_mesh.ufl_cell().cellname
hori_elt = FiniteElement('DG', cell, 1, variant='equispaced')
vert_elt = FiniteElement('DG', interval, 1, variant='equispaced')
V_elt = TensorProductElement(hori_elt, vert_elt)
continuity = {'horizontal': False, 'vertical': False}
else:
cell = self.mesh.ufl_cell().cellname()
cell = self.mesh.ufl_cell().cellname
V_elt = FiniteElement('DG', cell, 1, variant='equispaced')
continuity = False

Expand Down Expand Up @@ -285,9 +285,9 @@ def build_base_spaces(self, family, horizontal_degree, vertical_degree=None):
"""

if self.extruded_mesh:
cell = self.mesh._base_mesh.ufl_cell().cellname()
cell = self.mesh._base_mesh.ufl_cell().cellname
else:
cell = self.mesh.ufl_cell().cellname()
cell = self.mesh.ufl_cell().cellname

hdiv_family = hcurl_hdiv_dict[family]
hcurl_family = hdiv_hcurl_dict[family]
Expand Down Expand Up @@ -359,7 +359,7 @@ def build_compatible_spaces(self):

return Vcg, Vcurl, Vu, Vdg, Vth

elif self.mesh.topological_dimension() > 1:
elif self.mesh.topological_dimension > 1:
# 2D: two de Rham complexes (hcurl or hdiv) with 3 spaces
# 3D: one de Rham complexes with 4 spaces
# either way, build all spaces
Expand Down
4 changes: 2 additions & 2 deletions gusto/core/meshes.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,12 @@ def get_flat_latlon_mesh(mesh):
coords_fs = coords_orig.function_space()

if coords_fs.extruded:
cell = mesh._base_mesh.ufl_cell().cellname()
cell = mesh._base_mesh.ufl_cell().cellname
DG1_hori_elt = FiniteElement("DG", cell, 1, variant="equispaced")
DG1_vert_elt = FiniteElement("DG", interval, 1, variant="equispaced")
DG1_elt = TensorProductElement(DG1_hori_elt, DG1_vert_elt)
else:
cell = mesh.ufl_cell().cellname()
cell = mesh.ufl_cell().cellname
DG1_elt = FiniteElement("DG", cell, 1, variant="equispaced")
vec_DG1 = VectorFunctionSpace(mesh, DG1_elt)
coords_dg = Function(vec_DG1).interpolate(coords_orig)
Expand Down
2 changes: 1 addition & 1 deletion gusto/diagnostics/compressible_euler_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def setup(self, domain, state_fields):
gradu = state_fields("u_gradient")

denom = 0.
z_dim = domain.mesh.geometric_dimension() - 1
z_dim = domain.mesh.geometric_dimension - 1
u_dim = state_fields("u").ufl_shape[0]
for i in range(u_dim-1):
denom += gradu[i, z_dim]**2
Expand Down
14 changes: 7 additions & 7 deletions gusto/diagnostics/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def setup(self, domain, state_fields):
"""
f = state_fields(self.fname)

mesh_dim = domain.mesh.geometric_dimension()
mesh_dim = domain.mesh.geometric_dimension
try:
field_dim = state_fields(self.fname).ufl_shape[0]
except IndexError:
Expand Down Expand Up @@ -602,7 +602,7 @@ def setup(self, domain, state_fields):
domain (:class:`Domain`): the model's domain object.
state_fields (:class:`StateFields`): the model's field container.
"""
dim = domain.mesh.topological_dimension()
dim = domain.mesh.topological_dimension
e_x = as_vector([Constant(1.0)]+[Constant(0.0)]*(dim-1))
super().setup(domain, state_fields, e_x)

Expand All @@ -624,7 +624,7 @@ def setup(self, domain, state_fields):
"""
assert domain.metadata['domain_type'] not in ['interval', 'vertical_slice'], \
f'Y-component diagnostic cannot be used with domain {domain.metadata["domain_type"]}'
dim = domain.mesh.topological_dimension()
dim = domain.mesh.topological_dimension
e_y = as_vector([Constant(0.0), Constant(1.0)]+[Constant(0.0)]*(dim-2))
super().setup(domain, state_fields, e_y)

Expand All @@ -646,7 +646,7 @@ def setup(self, domain, state_fields):
"""
assert domain.metadata['domain_type'] not in ['interval', 'plane'], \
f'Z-component diagnostic cannot be used with domain {domain.metadata["domain_type"]}'
dim = domain.mesh.topological_dimension()
dim = domain.mesh.topological_dimension
e_x = as_vector([Constant(0.0)]*(dim-1)+[Constant(1.0)])
super().setup(domain, state_fields, e_x)

Expand Down Expand Up @@ -682,7 +682,7 @@ def _check_args(self, domain, field):
"""

# check geometric dimension is 3D
if domain.mesh.geometric_dimension() != 3:
if domain.mesh.geometric_dimension != 3:
raise ValueError('Spherical components only work when the geometric dimension is 3!')

if np.prod(field.ufl_shape) != 3:
Expand Down Expand Up @@ -1043,7 +1043,7 @@ def setup(self, domain, state_fields):
horiz_degree = m_X_horiz.degree() + rho_d_horiz.degree()
vert_degree = m_X_vert.degree() + rho_d_vert.degree()

cell = domain.mesh._base_mesh.ufl_cell().cellname()
cell = domain.mesh._base_mesh.ufl_cell().cellname
horiz_elt = FiniteElement('DG', cell, horiz_degree)
vert_elt = FiniteElement('DG', cell, vert_degree)
elt = TensorProductElement(horiz_elt, vert_elt)
Expand All @@ -1052,7 +1052,7 @@ def setup(self, domain, state_fields):
rho_d_degree = rho_d_space.ufl_element().degree()
degree = m_X_degree + rho_d_degree

cell = domain.mesh.ufl_cell().cellname()
cell = domain.mesh.ufl_cell().cellname
elt = FiniteElement('DG', cell, degree)

tracer_density_space = FunctionSpace(domain.mesh, elt, name='tracer_density_space')
Expand Down
2 changes: 1 addition & 1 deletion gusto/equations/common_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def advection_equation_circulation_form(domain, test, q, ubar):
class:`LabelledForm`: a labelled transport form.
"""

if domain.mesh.topological_dimension() == 3:
if domain.mesh.topological_dimension == 3:
L = inner(test, cross(curl(q), ubar))*dx

else:
Expand Down
12 changes: 6 additions & 6 deletions gusto/recovery/recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ def __init__(self, x_inout, method=BoundaryMethod.extruded, eff_coords=None):
elif self.method == BoundaryMethod.taylor:
# Create DG1 space ----------------------------------------------- #
if V_inout.extruded:
cell = mesh._base_mesh.ufl_cell().cellname()
cell = mesh._base_mesh.ufl_cell().cellname
DG1_hori_elt = FiniteElement("DG", cell, 1, variant="equispaced")
DG1_vert_elt = FiniteElement("DG", interval, 1, variant="equispaced")
DG1_element = TensorProductElement(DG1_hori_elt, DG1_vert_elt)
else:
cell = mesh.ufl_cell().cellname()
cell = mesh.ufl_cell().cellname
DG1_element = FiniteElement("DG", cell, 1, variant="equispaced")

vec_DG1 = VectorFunctionSpace(mesh, DG1_element)
Expand Down Expand Up @@ -323,12 +323,12 @@ def find_eff_coords(V0):

mesh = V0.mesh()
if V0.extruded:
cell = mesh._base_mesh.ufl_cell().cellname()
cell = mesh._base_mesh.ufl_cell().cellname
DG1_hori_elt = FiniteElement("DG", cell, 1, variant="equispaced")
DG1_vert_elt = FiniteElement("DG", interval, 1, variant="equispaced")
DG1_element = TensorProductElement(DG1_hori_elt, DG1_vert_elt)
else:
cell = mesh.ufl_cell().cellname()
cell = mesh.ufl_cell().cellname
DG1_element = FiniteElement("DG", cell, 1, variant="equispaced")

vec_CG1 = VectorFunctionSpace(mesh, "CG", 1)
Expand Down Expand Up @@ -397,12 +397,12 @@ def correct_eff_coords(eff_coords):
vec_CG1 = VectorFunctionSpace(mesh, "CG", 1)

if vec_CG1.extruded:
cell = mesh._base_mesh.ufl_cell().cellname()
cell = mesh._base_mesh.ufl_cell().cellname
DG1_hori_elt = FiniteElement("DG", cell, 1, variant="equispaced")
DG1_vert_elt = FiniteElement("DG", interval, 1, variant="equispaced")
DG1_element = TensorProductElement(DG1_hori_elt, DG1_vert_elt)
else:
cell = mesh.ufl_cell().cellname()
cell = mesh.ufl_cell().cellname
DG1_element = FiniteElement("DG", cell, 1, variant="equispaced")

vec_DG1 = VectorFunctionSpace(mesh, DG1_element)
Expand Down
2 changes: 1 addition & 1 deletion gusto/recovery/recovery_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def __init__(self, DG1):
DG1 (:class:`FunctionSpace`): The equispaced DG1 function space.
"""
shapes = {"nDOFs": DG1.finat_element.space_dimension(),
"dim": DG1.mesh().topological_dimension()}
"dim": DG1.mesh().topological_dimension}

# EFF_COORDS are the effective coordinates
# ACT_COORDS are the actual coordinates
Expand Down
4 changes: 2 additions & 2 deletions gusto/recovery/recovery_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, domain, boundary_method=None, use_vector_spaces=False):
theta_boundary_method = boundary_method['theta']
else:
theta_boundary_method = None
cell = mesh._base_mesh.ufl_cell().cellname()
cell = mesh._base_mesh.ufl_cell().cellname
DG_hori_ele = FiniteElement('DG', cell, 1, variant='equispaced')
DG_vert_ele = FiniteElement('DG', interval, (domain.vertical_degree + 1), variant='equispaced')
CG_hori_ele = FiniteElement('CG', cell, 1)
Expand All @@ -66,7 +66,7 @@ def __init__(self, domain, boundary_method=None, use_vector_spaces=False):
recovered_space=VCG_theta,
boundary_method=theta_boundary_method)
else:
cell = self.mesh.ufl_cell().cellname()
cell = self.mesh.ufl_cell().cellname

# ----------------------------------------------------------------------
# Building the DG options
Expand Down
8 changes: 4 additions & 4 deletions gusto/spatial_methods/augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(
sign_u = 0.5*(sign(dot(u, n)) + 1)
upw = lambda f: (sign_u('+')*f('+') + sign_u('-')*f('-'))

if domain.mesh.topological_dimension() == 2:
if domain.mesh.topological_dimension == 2:
mix_test = test_F - domain.perp(grad(test_Z))
F_cross_u = Z*domain.perp(u)
elif domain.mesh.topological_dimension == 3:
Expand Down Expand Up @@ -151,14 +151,14 @@ def __init__(
DG0 = FunctionSpace(domain.mesh, 'DG', 0)
ones = Function(DG0).interpolate(Constant(1.0))
area = assemble(ones*dx)
mean_dx = (area/DG0.dof_count)**(1/domain.mesh.geometric_dimension())
mean_dx = (area/DG0.dof_count)**(1/domain.mesh.geometric_dimension)

# Divide by approximately (1 + c)
tau /= (1.0 + sqrt(dot(u, u))*domain.dt/Constant(mean_dx))

dxqp = dx(degree=3)

if domain.mesh.topological_dimension() == 2:
if domain.mesh.topological_dimension == 2:
time_deriv_form -= inner(mix_test, tau*Z*domain.perp(u)/domain.dt)*dxqp
transport_form -= inner(
mix_test, tau*domain.perp(u)*domain.divperp(Z*domain.perp(u))
Expand All @@ -168,7 +168,7 @@ def __init__(
mix_test,
tau*domain.perp(u)*domain.divperp(u_dot_nabla_F)
)*dxqp
elif domain.mesh.topological_dimension() == 3:
elif domain.mesh.topological_dimension == 3:
time_deriv_form -= inner(mix_test, tau*cross(Z, u)/domain.dt)*dxqp
transport_form -= inner(
mix_test, tau*cross(curl(Z*u), u)
Expand Down
4 changes: 2 additions & 2 deletions gusto/spatial_methods/diffusion_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def __init__(self, equation, variable, diffusion_parameters):

super().__init__(equation, variable)

if equation.domain.mesh.topological_dimension() == 1:
if equation.domain.mesh.topological_dimension == 1:
self.form = interior_penalty_diffusion_form_1d(
equation.domain, self.test, self.field, diffusion_parameters)
else:
Expand All @@ -157,7 +157,7 @@ def __init__(self, equation, variable, diffusion_parameters):

super().__init__(equation, variable)

if equation.domain.mesh.topological_dimension() == 1:
if equation.domain.mesh.topological_dimension == 1:
kappa = diffusion_parameters.kappa
self.form = diffusion(kappa * self.test.dx(0) * self.field.dx(0) * dx)
else:
Expand Down
6 changes: 3 additions & 3 deletions gusto/spatial_methods/limiters.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ def __init__(self, space, subspace=None):

# Create equispaced DG1 space needed for limiting
if space.extruded:
cell = mesh._base_mesh.ufl_cell().cellname()
cell = mesh._base_mesh.ufl_cell().cellname
DG1_hori_elt = FiniteElement("DG", cell, 1, variant="equispaced")
DG1_vert_elt = FiniteElement("DG", interval, 1, variant="equispaced")
DG1_element = TensorProductElement(DG1_hori_elt, DG1_vert_elt)
else:
cell = mesh.ufl_cell().cellname()
cell = mesh.ufl_cell().cellname
DG1_element = FiniteElement("DG", cell, 1, variant="equispaced")

DG1_equispaced = FunctionSpace(mesh, DG1_element)
Expand Down Expand Up @@ -123,7 +123,7 @@ def __init__(self, space):
self.Vt_brok = FunctionSpace(mesh, BrokenElement(space.ufl_element()))

# Create equispaced DG1 space needed for limiting
cell = mesh._base_mesh.ufl_cell().cellname()
cell = mesh._base_mesh.ufl_cell().cellname
DG1_hori_elt = FiniteElement("DG", cell, 1, variant="equispaced")
DG1_vert_elt = FiniteElement("DG", interval, 1, variant="equispaced")
CG2_vert_elt = FiniteElement("CG", interval, 2)
Expand Down
6 changes: 3 additions & 3 deletions gusto/spatial_methods/transport_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def __init__(self, equation, variable, ibp=IntegrateByParts.ONCE,
# Determine appropriate form to use
# -------------------------------------------------------------------- #
# first check for 1d mesh and scalar velocity space
if equation.domain.mesh.topological_dimension() == 1 and len(equation.domain.spaces("HDiv").shape) == 0:
if equation.domain.mesh.topological_dimension == 1 and len(equation.domain.spaces("HDiv").shape) == 0:
assert not vector_manifold_correction
if self.transport_equation_type == TransportEquationType.advective:
form = upwind_advection_form_1d(
Expand Down Expand Up @@ -350,7 +350,7 @@ def __init__(self, equation, variable, ibp=IntegrateByParts.ONCE,
# Determine appropriate form to use
# -------------------------------------------------------------------- #
# first check for 1d mesh and scalar velocity space
if equation.domain.mesh.topological_dimension() == 1 and len(equation.domain.spaces("HDiv").shape) == 0:
if equation.domain.mesh.topological_dimension == 1 and len(equation.domain.spaces("HDiv").shape) == 0:
assert not vector_manifold_correction
raise ValueError('You cannot do horizontal and vertical splitting in 1D')
else:
Expand Down Expand Up @@ -831,7 +831,7 @@ def upwind_circulation_form(domain, test, q, ibp=IntegrateByParts.ONCE):
n = FacetNormal(domain.mesh)
Upwind = 0.5*(sign(dot(ubar, n))+1)

if domain.mesh.topological_dimension() == 3:
if domain.mesh.topological_dimension == 3:

if ibp != IntegrateByParts.ONCE:
raise NotImplementedError
Expand Down
2 changes: 1 addition & 1 deletion gusto/time_discretisation/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def setup(self, field_name):
# -------------------------------------------------------------------- #

# construct tau, if it is not specified
dim = domain.mesh.topological_dimension()
dim = domain.mesh.topological_dimension
if self.options.tau is not None:
# if tau is provided, check that is has the right size
self.tau = self.options.tau
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/transport/test_dg_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_dg_transport_scalar(tmpdir, geometry, equation_form, tracer_setup):
def test_dg_transport_vector(tmpdir, geometry, equation_form, tracer_setup):
setup = tracer_setup(tmpdir, geometry)
domain = setup.domain
gdim = domain.mesh.geometric_dimension()
gdim = domain.mesh.geometric_dimension
f_init = as_vector([setup.f_init]*gdim)
V = VectorFunctionSpace(domain.mesh, "DG", 1)
if equation_form == "advective":
Expand Down
Loading