Mesh.create_rectangle in different plane than x,y?

Hello, I’m trying to use 2D solutions as boundary conditions for a 3D problem, but the faces of the 3D boundaries are on different planes than the x-y plane, which FEniCSx’s built-in meshes (i.e, create_rectangle) seem to be stuck to.

That is, imagine a 3D cube, and trying to interpolate a 2D solution onto the “front” face (y-z plane) for one boundary condition, and another 2D solution onto the “top” face (x-y plane).

Is there a way to “rotate” a 2D solution? Or, to have create_rectangle use 3D coordinates?

Thanks!

Guess it may involve two steps:

  1. use fem.locate_dofs_topological to get DOF of your front and top faces of 3D functionspace.
  2. use dof_to_vertex_map or vertex_to_dof_map (for P1 element) to build mapping between your 2D and 3D functionspace according to coordinates, then accomplish it by assigning values like function_slice.x.array[selected_dofs] = function_2d.x.array[reordered_dofs_list].