I noticed that only the triangular cells were imported. According to this post, FEniCS does not support such mixed elements. Has it changed since 2018?
These outer layers are PMLs and they are known to be structured. I honestly don’t know how bad would it be if they weren’t. Would you advise me to proceed nevertheless or structured mesh is a must for PMLs?
FEniCS still does not support mixed element meshes. What I would recommend is to switch to dolfinx, as the support for quadrilaterals cells are better there.
I would use unstructured quads in the interior, and structured quads in the PML.
Mixed elements are on the todo list for dolfinx, but it is not a short term goal.
Thank you @dokken. I’ll check it out. So in order to import the mesh you mentioned, what should I change in this snippet?
import numpy as np
import meshio
from fenics import *
msh = meshio.read("<path_to_file>.msh")
clls = np.vstack((
cell.data for cell in msh.cells if cell.type == "triangle")) # only write 2D cells unless you need lower dimensional elements in your code
meshio.xdmf.write("channel.xdmf", meshio.Mesh(msh.points, cells = {"triangle": clls}))
mesh = Mesh()
XDMFFile("channel.xdmf").read(mesh)
I’ve remeshed my domain with structured and unstructured quadrilaterals. Now I’m on the process of gueting Dolfinx running properly. To that end, I’m using Docker and I wish to be able to share files between my local system and the Dolfinx container.
I tried
$ sudo docker run -ti -v $(pwd):/home/fenics/shared dolfinx/dolfinx
on the terminal, but then I couldn’t list any file at all. How can this be done?
It would be nice if I could share files between Dolfinx container and Jupyter Lab too (if I’m not asking too much )
Simply do cd /home/fenics/shared after you have started your docker container.
Add the flag -w /home/fenics/shared to the docker command to make it your working directory. Complete command: docker run -ti -v $pwd):/home/fenics/shared -w /home/fenics/shared dolfinx/dolfinx
Thank you @dokken, it works. But now I’m facing another problem. I tried running the Poisson and Stokes examples from here. I simply copied the code to a .py file in my shared folder and ran root@6efded275412:/home/fenics/shared# python3 file.py, both gave the error
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 4 Illegal instruction: Likely due to memory corruption
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind
[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors
[0]PETSC ERROR: likely location of problem given in stack below
[0]PETSC ERROR: --------------------- Stack Frames ------------------------------------
[0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available,
[0]PETSC ERROR: INSTEAD the line number of the start of the function
[0]PETSC ERROR: is given.
application called MPI_Abort(MPI_COMM_WORLD, 50152059) - process 0
[unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=50152059
:
system msg for write_line failure : Bad file descriptor
Then I mimicked the code @awarru wrote here. The mesh generation works well, but when I try running the solver I get Illegal instruction (core dumped).
Well, for example the Helmholtz2D example. I created a .py file containing only the headers to see if it runs flawlessly.
helmholtz2D.py
import numpy as np
from mpi4py import MPI
from dolfinx import (Function, FunctionSpace, UnitSquareMesh,has_petsc_complex, solve)
from dolfinx.fem.assemble import assemble_scalar
from dolfinx.io import XDMFFile
from ufl import FacetNormal, TestFunction, TrialFunction, dx, grad, inner
I cannot reproduce this error on my system (ubuntu 16.04 running docker with the commands above, except for the sudo in front of docker).
Could you try to single out which of the imports above that causes the error message?
I believe the problem is with the dolfinx library. The Illegal instruction (core dumped) error message is displayed only for
from dolfinx import (Function, FunctionSpace, UnitSquareMesh,has_petsc_complex, solve)
from dolfinx.fem.assemble import assemble_scalar
from dolfinx.io import XDMFFile
imports (I tested them individually)
FEniCS runs ok via Docker though. Maybe some corrupted library in Dolfinx or some hardware limitation could explain this…
As Im am Also running the same docker image, it is most likely a strange hardware limitation. I’ll do another run tomorrow to double check it.
What kind of system and Which version of docker are you using?
Well, it has something to do with my desktop… I went through this Docker installation guide on my laptop, which runs the same Ubuntu version, and I was able to run the helmholtz2D.py example. Then I uninstalled Docker on my desktop and reinstalled it following the same protocol as for the laptop, but the error remained. As I’ll upgrade my hardware shortly, there’s no need to further investigation. The only thing I’d ask for is a snippet in order to import .msh files with quadrilaterals cells into Dolfinx.
Thanks in advance!