Errors while running asimov-contact demos

Hello everyone,
I have installed dolfinx_contact and can build it successfully, but I run into an error when executing the demo scripts (e.g. demo_friction_cylinders.py). The issue seems similar to the one discussed here: TypeError: ContactProblem argument mismatch — ‘incompatible function arguments’ in dolfinx_contact · Issue #185 · Wells-Group/asimov-contact · GitHub
I followed the installation steps using:

  • conda install -c conda-forge fenics-dolfinx=0.9.0
  • then building asimov-contact from source with CMake/Ninja and installing the Python package
git clone https://github.com/Wells-Group/asimov-contact.git
cd asimov-contact/
export VERBOSE=1
cmake -G Ninja -DCMAKE_BUILD_TYPE=Developer  -B build-contact -S cpp/
ninja -C build-contact install
python3 -m pip -v install -r ./python/build-requirements.txt
python3 -m pip -v install --no-build-isolation python/
cd python/demos/hertz_contact
python3 -m pip install scipy
python3 -m pip install matplotlib
mkdir -p ../meshes
python3 demo_friction_cylinders.py 

I also tried an alternative installation approach from the FEniCS discourse thread ((Problems installing Asimov-Contact - #7 by dokken)), but the same error persists.

The error I get is:

TypeError: __init__(): incompatible function arguments. The following argument types are supported:
    1. __init__(self, markers: collections.abc.Sequence[dolfinx::mesh::MeshTags<int>], surfaces: dolfinx::graph::AdjacencyList<int>, contact_pairs: collections.abc.Sequence[collections.abc.Sequence[int]], mesh: dolfinx::mesh::Mesh<double>, search_method: collections.abc.Sequence[dolfinx_contact.cpp.ContactMode], quadrature_degree: int = 3) -> None

Invoked with types: dolfinx_contact.general_contact.contact_problem.ContactProblem, list, dolfinx.cpp.graph.AdjacencyList_int32, list, dolfinx.cpp.mesh.Mesh_float64, kwargs = { quadrature_degree: int, search_method: list }

I also experimented with changing the argument order in the ContactProblem call, but it didn’t resolve the issue.

I am not sure whether this is due to an installation/version mismatch or something subtle in how the demo is being run. Has anyone recently been able to run these demos successfully? Any guidance would be appreciated.

Thanks for your time.

Hi, by following your installation I ran into the same error and it turned out to be a nanobind version mismatch. I’d suggest checking your nanobind version and comparing it with the one required by fenics-dolfinx=0.9.0 from conda-forge (it should be nanobind 2.8).
If it doesn’t match (in my case it was 2.12.0), the fix was:

pip uninstall -y nanobind  
conda install -c conda-forge nanobind=2.8.0

and then rebuilding dolfinx_contact against the correct nanobind version. After that the demos ran fine.

Hope it helps!

Btw, im in the process of upgrading asimov-contact to v0.10.0, see: Dokken/fixes for 010 by jorgensd · Pull Request #186 · Wells-Group/asimov-contact · GitHub for progress.

Thanks for the update Mr.Dokken. This is great to hear. Thanks a lot again for your time and support.

I have one small question: after updating the contact libraries, do we need to reinstall dolfinx?

Sincerely,
Kumar.

Once asimov-contact is up to date with v0.10, you should first install fenics-dolfinx v0.10, then rebuild the contact library.

Hello Mr. Dokken,
I updated my environment to dolfinx v0.10** and then rebuilt the asimov-contact library as recommended. The core contact functionality compiles and runs, so that part seems fine.

However, I am still facing several issues inside the ContactWriter class, especially in file output.py. Some of the errors appear to be related to API changes in UFL and dolfinx(e.g., Cell, quadrature elements, create_submesh, EntityMap, etc.). I tried adjusting the syntax manually, but each fix leads to another incompatibility.

I wanted to ask whether the ContactWriter code is already updated for DOLFINx v0.10 * or
if I might have an installation issue on my side.

Before I continue altering things manually, I thought it would be better to ask once with you.

Thanks for your time and support.

Could you provide me with a link to the code that fails? As all the demos and tests pass, i don’t have an example where this writer is used.

I tried running the friction cylinders demo asimov-contact/python/demos/hertz_contact/demo_friction_cylinders.py at main · Wells-Group/asimov-contact · GitHub.

I modified the below mentioned part based on the suggestion in TypeError: ContactProblem argument mismatch — ‘incompatible function arguments’ in dolfinx_contact · Issue #185 · Wells-Group/asimov-contact · GitHub

from dolfinx.mesh import meshtags
vals = facet_marker.values.copy()
vals[vals == 5] = 4
vals[vals == 8] = 7
vals[vals == 11] = 10
vals[vals == 14] = 13
facet_marker = meshtags(mesh, facet_marker.dim, facet_marker.indices, vals)
mesh.topology.create_connectivity(0, tdim) 

The code runs fine when the ContactWriter part is commented out.

  writer = ContactWriter(
        mesh,
        contact_problem,
        u,
        contact_pairs,
        contact_problem.coeffs,
        args.order,
        simplex,
        [(tdim - 1, 0), (tdim - 1, -R)],
        outname,
    )