Question about tutorial on lagrange multiplier interface

In the tutorial_lagrange_multipliers_interface, you formulate the problem as


There seems to be some confusion here. What is the definition of lambda in this problem? If eta is being solved for, why does the second equation specify “for every eta…”?

You are right, the line which starts with “find” should have lambda instead of eta.

I am still confused about the variational formulation. Why does the function f defined over Omega not show up in the variational problem? Did you leave something out?

Further questions about Tutorial 3 in multiphenicsx. Part of the code has

partitioner = dolfinx.mesh.create_cell_partitioner(dolfinx.mesh.GhostMode.shared_facet)
mesh, subdomains, boundaries_and_interfaces = dolfinx.io.gmshio.model_to_mesh(
    gmsh.model, comm=mpi4py.MPI.COMM_WORLD, rank=0, gdim=2, partitioner=partitioner)
gmsh.finalize()

Can someone please explain to me what a partitioner is and what create_cell_partitioner is doing? Also, if I will not be using multiple processors on my machine, is the argument dolfinx.mesh.GhostMode.shared_facet still necessary?

See
http://jsdokken.com/dolfinx_docs/meshes.html#mesh-partitioning

If you are running in serial ghost mode shared facet is not required, but it will also not cause any extra computations by leaving it there.

I am running on a single laptop


using wsl for linux. Do I have a capability to use parallel processors in processing fenicsx programs?

Yes, you should be able to run things in parallel.
You actually have more memory on your system than I have on my laptop.

How would I start learning how to do this?

I am trying to run tutorial 3 in multiphenicsx and I have hit the following problem in

# Split the block solution in components
(u1, u2, l) = (dolfinx.fem.Function(V1), dolfinx.fem.Function(V2), dolfinx.fem.Function(M))
with multiphenicsx.fem.petsc.BlockVecSubVectorWrapper(
        u1u2l, [V1.dofmap, V2.dofmap, M.dofmap], restriction) as u1u2l_wrapper:
    for u1u2l_wrapper_local, component in zip(u1u2l_wrapper, (u1, u2, l)):
        with component.x.petsc_vec.localForm() as component_local:
            component_local[:] = u1u2l_wrapper_local
u1u2l.destroy()

Here is the diagnostic I get

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[46], line 6
      3 with multiphenicsx.fem.petsc.BlockVecSubVectorWrapper(
      4         u1u2l, [V1.dofmap, V2.dofmap, M.dofmap], restriction) as u1u2l_wrapper:
      5     for u1u2l_wrapper_local, component in zip(u1u2l_wrapper, (u1, u2, l)):
----> 6         with component.x.petsc_vec.localForm() as component_local:
      7             component_local[:] = u1u2l_wrapper_local
      8 u1u2l.destroy()

AttributeError: 'Vector' object has no attribute 'petsc_vec'

Can someone help with this?

You probably haven’t followed the instructions at Installation — multiphenicsx . My guess is that you are using the tutorials from the main branch (i.e, dolfinx dev version), but you have installed a dolfinx release around 0.7.*.

Yes, please see the very beginning of tutorial_lagrange_multipliers_interface for the updated description.

I apologize in advance for my ignorance on these issues. Here is what I have done: I created a new environment in which I installed fenicsx9. When I try to execute
git clone GitHub - multiphenics/multiphenicsx: multiphenicsx - easy prototyping of multiphysics problems in FEniCSx
I get the message
fatal: destination path ‘multiphenicsx’ already exists and is not an empty directory.
This is presumably because I already downloaded multipenicsx previously and created the directory at that time. However, now if I try to execute

import multiphenicsx.fem
import multiphenicsx.fem.petsc

I get
ModuleNotFoundError: No module named ‘multiphenicsx’
I then try to reinstall multiphenicsx and
image

Where do I go from here?

The error says it all. There are some dependencies missing: please try to have a look at how you can install them within your environment (I guess a conda one, so look if there are conda packages for that: can’t tell you by heart because I am not a conda user).

Thanks for your help. I have now successfully installed both dolfinx ver 0.9 and multiphenicsx. Specifically I am now running the tutorial

https://multiphenics.github.io/tutorials/03_lagrange_multipliers/tutorial_lagrange_multipliers_interface.html

When I get to the commands

# Define restrictions
dofs_V1_Omega1 = dolfinx.fem.locate_dofs_topological(V1, subdomains.dim, cells_Omega1)
dofs_V2_Omega2 = dolfinx.fem.locate_dofs_topological(V2, subdomains.dim, cells_Omega2)
dofs_M_Gamma = dolfinx.fem.locate_dofs_topological(M, boundaries_and_interfaces.dim, facets_Gamma)
restriction_V1_Omega1 = multiphenicsx.fem.DofMapRestriction(V1.dofmap, dofs_V1_Omega1)
restriction_V2_Omega2 = multiphenicsx.fem.DofMapRestriction(V2.dofmap, dofs_V2_Omega2)
restriction_M_Gamma = multiphenicsx.fem.DofMapRestriction(M.dofmap, dofs_M_Gamma)
restriction = [restriction_V1_Omega1, restriction_V2_Omega2, restriction_M_Gamma]

I get the error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[30], line 5
      3 dofs_V2_Omega2 = dolfinx.fem.locate_dofs_topological(V2, subdomains.dim, cells_Omega2)
      4 dofs_M_Gamma = dolfinx.fem.locate_dofs_topological(M, boundaries_and_interfaces.dim, facets_Gamma)
----> 5 restriction_V1_Omega1 = multiphenicsx.fem.DofMapRestriction(V1.dofmap, dofs_V1_Omega1)
      6 restriction_V2_Omega2 = multiphenicsx.fem.DofMapRestriction(V2.dofmap, dofs_V2_Omega2)
      7 restriction_M_Gamma = multiphenicsx.fem.DofMapRestriction(M.dofmap, dofs_M_Gamma)

File ~/anaconda3/envs/fenicsx9/lib/python3.13/site-packages/multiphenicsx/fem/dofmap_restriction.py:31, in DofMapRestriction.__init__(self, dofmap, restriction)
     29 except AttributeError:  # pragma: no cover
     30     _dofmap = dofmap
---> 31 super().__init__(_dofmap, restriction)

TypeError: __init__(): incompatible function arguments. The following argument types are supported:
    1. __init__(self, dofmap: dolfinx::fem::DofMap, restriction: collections.abc.Sequence[int]) -> None

Invoked with types: multiphenicsx.fem.dofmap_restriction.DofMapRestriction, dolfinx.cpp.fem.DofMap, ndarray

Can you help?

That’ typically means that you have a mismatch between the nanobind version that was used to build dolfinx within conda, and the one that you installed locally.
Can you check which version of nanobind was used in conda? How did you install nanobind in your environment?

I had to install nanobind after installing dolfinx because I was getting the diagnostic that I posted above.

(fenicsx9) dannyb@dannyslaptop:~/multiphenicsx$ python -m pip install nanobind
Collecting nanobind
  Downloading nanobind-2.2.0-py3-none-any.whl.metadata (1.8 kB)
Downloading nanobind-2.2.0-py3-none-any.whl (231 kB)
Installing collected packages: nanobind
Successfully installed nanobind-2.2.0

suggestion would be to never mix up pip installed wheels and conda packages, hence install nanbobind and skbuild from conda. However, I wouldn’t know how to do that in a way that guarantees that you get the same versions used at dolfinx 0.9.0 build time, cc @minrk for help :heart:

if you install nanobind with conda, dolfinx has a constraint that should ensure you get the right version:

mamba install fenics-dolfinx=0.9 nanobind

gets you nanobind 2.1 today

mamba install fenics-dolfinx=0.9 nanobind=2.2

(correctly) refuses to install with a conflict:

The following packages are incompatible
├─ fenics-dolfinx 0.9**  is installable and it requires
│  └─ fenics-basix-nanobind-abi 0.2.1.17 , which requires
│     └─ nanobind 2.1.* , which can be installed;
└─ nanobind 2.2**  is not installable because it conflicts with any installable versions previously reported.
1 Like

Here is what I tried

(fenicsx9) dannyb@dannyslaptop:~/multiphenicsx$ mamba install fenics-dolfinx=0.9 nanobind
Command 'mamba' not found, did you mean:
  command 'samba' from deb samba (2:4.15.13+dfsg-0ubuntu1.6)
Try: sudo apt install <deb name>

use conda install -c conda-forge fenics-dolfinx=0.9 nanobind if you do not have mamba installed.