How to generate four-node quadrilateral mesh and element?

Question 1: Q4 mesh
Suppose we have two matrices A and B describing Node and Coordinate relationships, and Element and Node relationships, respectively:

A: (Node and Coordinate relationships)
Node1 x1 y1
Node2 x2 y2
Node3 x3 y3

B: (Element and Node relationships)
Element1 Node1 Node2 Node3 Node4
Element2 Node1 Node2 Node3 Node4
Element3 Node1 Node2 Node3 Node4

How could we transfer these two relationships of four-node quadrilateral mesh (not just square or rectangle mesh) into mesh entities such as the one obtained from RectangleMesh in FEniCS?

Question 2: Q4 element
Once we obtain a mesh entity containing the Q4 mesh, do we need to do some other modifications in the code?

For quadrilateral and hexahedral elements, it is recommended to use dolfin-x, as the support for these elements has been vastly improved. See for instance: dolfinx/test_higher_order_mesh.py at main · FEniCS/dolfinx · GitHub

2 Likes

Hi Dokken, thanks for your reply very much, and I just have two follow-up questions:

(1) Does the dolfinx contain all the contents in dolfin? That is, can I use from dolfinx import * to replace from dolfin import *?

(2) I am a newcomer to docker and I have installed docker in the windows 10 system. I use docker command to download dolfinx (about 3.16 GB). But when I try to use from dolfinx import *, a warning appears that ‘no module named dolfinx’. What should I do then?
I am using VScode and Ubuntu 18.04LTS, and the classical dofinx runs very smoothly.

Dolfin-X is quite different from dolfin. They both use UFL, but the syntax has changed quite alot. See for instance: The FEniCSx tutorial — FEniCSx tutorial for an overview of the new syntax.

The docker image you should use is the dolfinx/dolfinx image on Dockerhub. You shoul be able to pull the image, create a container and run python3 -c "import dolfinx" without any error message.

1 Like

Hi Dokken, I try to pull the image by using Docker, but the warning still exists. Could you please tell me how to deal with it?

This is my image list:

This is my container:

I think I can only run dolfinx in this way:
image
But it will change the file directory. Is there some elegant way to run it?

The dolfinx docker image is like any other docker image. You need to start a container using docker run to be able to access a terminal that has dolfinx installed. A docker container always have its own file system, and you can share a folder with the container by running the following:

docker run -ti -v $(pwd):/root/shared -w /root/shared --rm dolfinx/dolfinx
2 Likes

Thank you, Dokken! You help me a lot. Now I can run my code with dolfinx.
But when I try to reproduce the result in this tutorial: Implementation — FEniCS-X tutorial (jorgensd.github.io), there is a warning: No module named ‘pyvista’. For other parts, they work well.

Pyvista has to be installed, as it is an optional dependency of dolfinx. You should run the following inside your container

apt-get -qq update && \
    apt-get -y install libgl1-mesa-dev \
    xvfb 
pip3 install pyvista matplotlib
1 Like