Skip to content

Commit ffcc725

Browse files
authored
Remove gdim from element input and update FunctionSpace C++ API (#105)
* Fixes related to FEniCS/basix#772 #702 * More gdims to remove
1 parent afa9fd5 commit ffcc725

8 files changed

+14
-13
lines changed

cpp/PeriodicConstraint.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ dolfinx_mpc::mpc_data<T> _create_periodic_condition(
6464
parents_glob[i] = parents_glob[i] * bs + parent_rems[i];
6565
return parents_glob;
6666
};
67-
if (const std::size_t value_size
68-
= V.element()->value_size() / V.element()->block_size();
67+
if (const std::size_t value_size = V.value_size() / V.element()->block_size();
6968
value_size > 1)
7069
throw std::runtime_error(
7170
"Periodic conditions for vector valued spaces are not "

cpp/mpc_helpers.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ create_extended_functionspace(const dolfinx::fem::FunctionSpace<U>& V,
233233
old_dofmap.element_dof_layout(), new_index_map, old_dofmap.bs(),
234234
std::move(flattened_dofmap), old_dofmap.bs());
235235

236-
return dolfinx::fem::FunctionSpace(V.mesh(), element, new_dofmap);
236+
return dolfinx::fem::FunctionSpace(
237+
V.mesh(), element, new_dofmap,
238+
dolfinx::fem::compute_value_shape(element, V.mesh()->topology()->dim(),
239+
V.mesh()->geometry().dim()));
237240
}
238241

239242
} // namespace dolfinx_mpc

cpp/utils.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ evaluate_basis_functions(const dolfinx::fem::FunctionSpace<U>& V,
10181018

10191019
assert(basis_shape[2]
10201020
== std::size_t(element->space_dimension() / bs_element));
1021-
assert(basis_shape[3] == std::size_t(element->value_size() / bs_element));
1021+
assert(basis_shape[3] == std::size_t(V.value_size() / bs_element));
10221022
std::array<std::size_t, 3> reference_shape
10231023
= {basis_shape[1], basis_shape[2], basis_shape[3]};
10241024
std::vector<U> output_basis(std::reduce(

python/benchmarks/bench_contact_3D.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def over_plane(p0, p1, p2):
9292
# Concatenate points and cells
9393
points = np.vstack([mesh0.geometry.x, mesh1.geometry.x])
9494
cells = np.vstack([cells0, cells1])
95-
domain = Mesh(element("Lagrange", ct.name, 1, shape=(points.shape[1],), gdim=points.shape[1]))
95+
domain = Mesh(element("Lagrange", ct.name, 1, shape=(points.shape[1],)))
9696
# Rotate mesh
9797
points = np.dot(r_matrix, points.T).T.astype(default_real_type)
9898

python/demos/create_and_export_mesh.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def over_line(p0, p1):
394394
cells1 += mesh0.geometry.x.shape[0]
395395

396396
cells = np.vstack([cells0, cells1])
397-
domain = ufl.Mesh(element("Lagrange", ct.name, 1, shape=(points.shape[1],), gdim=points.shape[1]))
397+
domain = ufl.Mesh(element("Lagrange", ct.name, 1, shape=(points.shape[1],)))
398398
mesh = _mesh.create_mesh(MPI.COMM_SELF, cells, points, domain)
399399
tdim = mesh.topology.dim
400400
fdim = tdim - 1
@@ -514,7 +514,7 @@ def over_plane(p0, p1, p2):
514514
cells1 += mesh0.geometry.x.shape[0]
515515

516516
cells = np.vstack([cells0, cells1])
517-
domain = ufl.Mesh(element("Lagrange", ct.name, 1, shape=(points.shape[1],), gdim=points.shape[1]))
517+
domain = ufl.Mesh(element("Lagrange", ct.name, 1, shape=(points.shape[1],)))
518518
mesh = _mesh.create_mesh(MPI.COMM_SELF, cells, points, domain)
519519
tdim = mesh.topology.dim
520520
fdim = tdim - 1

python/demos/demo_elasticity_disconnect.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@ def sigma(v):
201201
# Write solution to file
202202
V_out = functionspace(mesh, basix.ufl.element("Lagrange", mesh.topology.cell_name(),
203203
mesh.geometry.cmap.degree,
204-
lagrange_variant=basix.LagrangeVariant(mesh.geometry.cmap.variant),
205-
gdim=mesh.geometry.dim, shape=(V.dofmap.bs,)))
204+
lagrange_variant=basix.LagrangeVariant(mesh.geometry.cmap.variant), shape=(V.dofmap.bs,)))
206205
u_out = Function(V_out)
207206
u_out.interpolate(u_h)
208207
u_out.name = "uh"

python/demos/demo_stokes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ def create_mesh_gmsh(L: int = 2, H: int = 1, res: float = 0.1, theta: float = np
123123
# The next step is the create the function spaces for the fluid velocit and pressure.
124124
# We will use a mixed-formulation, and we use `basix.ufl` to create the Taylor-Hood finite element pair
125125

126-
P2 = basix.ufl.element("Lagrange", mesh.topology.cell_name(), 2, gdim=mesh.geometry.dim, shape=(mesh.geometry.dim, ))
127-
P1 = basix.ufl.element("Lagrange", mesh.topology.cell_name(), 1, gdim=mesh.geometry.dim)
126+
P2 = basix.ufl.element("Lagrange", mesh.topology.cell_name(), 2, shape=(mesh.geometry.dim, ))
127+
P1 = basix.ufl.element("Lagrange", mesh.topology.cell_name(), 1)
128128

129129
TH = basix.ufl.mixed_element([P2, P1])
130130
W = fem.functionspace(mesh, TH)

python/dolfinx_mpc/multipointconstraint.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def create_slip_constraint(self, space: _fem.FunctionSpace, facet_marker: Tuple[
249249
cellname = mesh.ufl_cell().cellname()
250250
Ve = basix.ufl.element(basix.ElementFamily.P, cellname , 2, shape=(mesh.geometry.dim,))
251251
Qe = basix.ufl.element(basix.ElementFamily.P, cellname , 1)
252-
me = basix.ufl.mixed_element([Ve, Qe], gdim=mesh.geometry.dim)
252+
me = basix.ufl.mixed_element([Ve, Qe])
253253
W = dolfinx.fem.functionspace(mesh, me)
254254
mpc = MultiPointConstraint(W)
255255
n_space, _ = W.sub(0).collapse()
@@ -265,7 +265,7 @@ def create_slip_constraint(self, space: _fem.FunctionSpace, facet_marker: Tuple[
265265
cellname = mesh.ufl_cell().cellname()
266266
Ve = basix.ufl.element(basix.ElementFamily.P, cellname , 2, shape=(mesh.geometry.dim,))
267267
Qe = basix.ufl.element(basix.ElementFamily.P, cellname , 1)
268-
me = basix.ufl.mixed_element([Ve, Qe], gdim=mesh.geometry.dim)
268+
me = basix.ufl.mixed_element([Ve, Qe])
269269
W = dolfinx.fem.functionspace(mesh, me)
270270
mpc = MultiPointConstraint(W)
271271
n_space, _ = W.sub(0).collapse()

0 commit comments

Comments
 (0)