Actually I found I could modify the geometry of the mesh with:
mesh_1d = dolfinx.mesh.create_interval(MPI.COMM_WORLD, 10, [0, 1])
mesh_1d.geometry.x[:, 1] = mesh_1d.geometry.x[:, 0]
mesh_1d.geometry.x[:, 0] = 2
mesh_1d.geometry.x
array([[2. , 0. , 0. ],
[2. , 0.1, 0. ],
[2. , 0.2, 0. ],
[2. , 0.3, 0. ],
[2. , 0.4, 0. ],
[2. , 0.5, 0. ],
[2. , 0.6, 0. ],
[2. , 0.7, 0. ],
[2. , 0.8, 0. ],
[2. , 0.9, 0. ],
[2. , 1. , 0. ]])
But then when naively using the Function
from the 2D mesh in the 1D problem, I get:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[32], line 27
22 p0 = 133.3 # Pa
23 bcs_pressure = [
24 dolfinx.fem.dirichletbc(dolfinx.fem.Constant(mesh_1d, p0), dofs_bot, V_p),
25 ]
---> 27 problem = NonlinearProblem(F_pressure, p, bcs=bcs_pressure)
28 solver = NewtonSolver(MPI.COMM_WORLD, problem)
30 # solver.rtol = 1e-7
File ~/anaconda3/envs/plasma-centrifuge-env/lib/python3.13/site-packages/dolfinx/fem/petsc.py:922, in NonlinearProblem.__init__(self, F, u, bcs, J, form_compiler_options, jit_options)
894 def __init__(
895 self,
896 F: ufl.form.Form,
(...) 901 jit_options: typing.Optional[dict] = None,
902 ):
903 """Initialize solver for solving a non-linear problem using Newton's method`.
904
905 Args:
(...) 920 problem = LinearProblem(F, u, [bc0, bc1])
921 """
--> 922 self._L = _create_form(
923 F, form_compiler_options=form_compiler_options, jit_options=jit_options
924 )
...
220 if len(gdims) != 1:
--> 221 raise ValueError("Found domains with different geometric dimensions.")
223 return domains
ValueError: Found domains with different geometric dimensions.
So I assume I need to do some interpolation or something.