# Problem with custom mesh quality in docker

**URL:** <https://fenicsproject.discourse.group/t/problem-with-custom-mesh-quality-in-docker/4108>\
**Category:** Uncategorized\
**Created:** [September 16, 2020, 1:55pm UTC](https://fenicsproject.discourse.group/t/problem-with-custom-mesh-quality-in-docker/4108 "2020-09-16T13:55:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![plugged](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/plugged/32/5115_2.png) [@plugged](https://fenicsproject.discourse.group/u/plugged)\
**Post date:** [September 16, 2020, 1:55pm UTC](https://fenicsproject.discourse.group/t/problem-with-custom-mesh-quality-in-docker/4108/1 "2020-09-16T13:55:27Z")

</div>

Hi,

I’ve got a problem regarding a custom implementation of a mesh quality measure. I’ve developed this under Linux (installed fenics with conda), and tested it there (with the ubuntu ppa images) and it works.

Now, I was also testing this under Windows 10, using the docker image [quay.io/fenicsproject/stable:latest](http://quay.io/fenicsproject/stable:latest)  
and unfortunately, the program does not work.

To reproduce this problem, I have the following MWE

```
from fenics import *

_cpp_code_mesh_quality = """
			#include <pybind11/pybind11.h>
			#include <pybind11/eigen.h>
			namespace py = pybind11;

			#include <dolfin/mesh/Mesh.h>
			#include <dolfin/mesh/MeshFunction.h>
			#include <dolfin/mesh/Cell.h>

			using namespace dolfin;

			dolfin::MeshFunction<double>
			quality(std::shared_ptr<const Mesh> mesh)
			{
			  MeshFunction<double> cf(mesh, mesh->topology().dim(), 0.0);

			  for (CellIterator cell(*mesh); !cell.end(); ++cell)
			  {
				cf[*cell] = 1.0;
			  }
			  return cf;
			}

			PYBIND11_MODULE(SIGNATURE, m)
			{
			  m.def("quality", &quality);
			}

		"""

obj = compile_cpp_code(_cpp_code_mesh_quality)
mesh = UnitSquareMesh(10,10)
mf = obj.quality(mesh)

```

which should just return a MeshFunction which has values 1.0 everywhere. This works fine under my Linux installation, but with the Docker image I get the following error:

```
Traceback (most recent call last):
 File "mwe_meshqual.py", line 41, in <module>
 mf = obj.quality(mesh)
TypeError: quality(): incompatible function arguments. The following argument types are supported:
 1. (arg0: dolfin::Mesh) -> dolfin::MeshFunction<double>

Invoked with: <dolfin.cpp.generation.UnitSquareMesh object at 0x7f460bb8ba98> 

```

So, apparently the class for this is not correct, but I have no clue why there is a different behavior between docker and my installation (I also use fenics 2019.1.0, which is the same used for docker)

Thanks a lot for your time.

---

<div class="post-metadata">

**Author:** ![bhaveshshrimali](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/bhaveshshrimali/32/124_2.png) [@bhaveshshrimali](https://fenicsproject.discourse.group/u/bhaveshshrimali)\
**Post date:** [September 16, 2020, 2:32pm UTC](https://fenicsproject.discourse.group/t/problem-with-custom-mesh-quality-in-docker/4108/2 "2020-09-16T14:32:15Z")

</div>

> [@plugged](#):
>
> ```auto
> _cpp_code_mesh_quality = """
> #include <pybind11/pybind11.h>
> #include <pybind11/eigen.h>
> namespace py = pybind11;
> 
> #include <dolfin/mesh/Mesh.h>
> #include <dolfin/mesh/MeshFunction.h>
> #include <dolfin/mesh/Cell.h>
> 
> using namespace dolfin;
> 
> dolfin::MeshFunction<double>
> quality(std::shared_ptr<const Mesh> mesh)
> {
> MeshFunction<double> cf(mesh, mesh->topology().dim(), 0.0);
> 
> for (CellIterator cell(*mesh); !cell.end(); ++cell)
> {
> cf[*cell] = 1.0;
> }
> return cf;
> }
> 
> PYBIND11_MODULE(SIGNATURE, m)
> {
> m.def("quality", &quality);
> }
> 
> """
> 
> obj = compile_cpp_code(_cpp_code_mesh_quality)
> mesh = UnitSquareMesh(10,10)
> mf = obj.quality(mesh)
> 
> ```

Interesting… I just threw this into a a testing container that I have on `binder` (which essentially is a docker container under the hood) and it works absolutely fine.

---

<div class="post-metadata">

**Author:** ![plugged](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/plugged/32/5115_2.png) [@plugged](https://fenicsproject.discourse.group/u/plugged)\
**Post date:** [September 16, 2020, 2:50pm UTC](https://fenicsproject.discourse.group/t/problem-with-custom-mesh-quality-in-docker/4108/3 "2020-09-16T14:50:55Z")

</div>

Well, that’s good news, but makes the problem seems a bit more erratic then…

Thanks for trying this out!

---

<div class="post-metadata">

**Author:** ![bhaveshshrimali](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/bhaveshshrimali/32/124_2.png) [@bhaveshshrimali](https://fenicsproject.discourse.group/u/bhaveshshrimali)\
**Post date:** [September 16, 2020, 3:10pm UTC](https://fenicsproject.discourse.group/t/problem-with-custom-mesh-quality-in-docker/4108/4 "2020-09-16T15:10:18Z")

</div>

Just tested this on a [docker container](https://hub.docker.com/repository/docker/bhaveshshrimali/dolfin_superlu) that I have on my laptop (albeit it has dolfin `2019.2.0.dev0`) and it runs fine there too. The one on binder runs `2019.1.0` version.

---

<div class="post-metadata">

**Author:** ![plugged](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/plugged/32/5115_2.png) [@plugged](https://fenicsproject.discourse.group/u/plugged)\
**Post date:** [September 17, 2020, 5:48am UTC](https://fenicsproject.discourse.group/t/problem-with-custom-mesh-quality-in-docker/4108/5 "2020-09-17T05:48:11Z")

</div>

I’ve now tested 2019.2.0.dev0, too, and it again works there. Same for the stable:2019.1.0.r3 version.  
This is a rather strange behavior, maybe a bug in the stable:latest image?
