Replies: 31 comments 1 reply
-
I actually get a similar issue with tetrahedron, so is there something Im missing? |
Beta Was this translation helpful? Give feedback.
-
I tried to install dolfinx but the instructions in https://github.com/FEniCS/dolfinx do not work. but then I get:
trying: Nonetheless I could reproduce the issue by copying the output you provided. |
Beta Was this translation helpful? Give feedback.
-
I mostly use docker so all dependencies are right,
All dependencies are in the Dockerfile. If you rely on
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I agree that the ordering seems strange, I think there is a bug in dolfinx after changing from FIAT to basix. I will get back to you with something with the correct ordering. It would be great if it was possible to extend UGrid to take in the topology, geometry, and celltype and return a mesh using the VTK arbitrary ordered lagrange elements: https://blog.kitware.com/modeling-arbitrary-order-lagrange-finite-elements-in-the-visualization-toolkit/ |
Beta Was this translation helpful? Give feedback.
-
by reading at the links I think it should be doable! |
Beta Was this translation helpful? Give feedback.
-
@marcomusy Btw. The bug with basix only affects second order geometries.
yielding |
Beta Was this translation helpful? Give feedback.
-
..maybe i'm getting confused here but if I rotate by 90deg (which cannot change handedness) it actually looks clockwise - or anyway opposite to the green cube above: import vedo
import numpy as np
geo = np.array([[1., 0., 0.],
[0., 0., 0.],
[0., 1., 0.],
[1., 1., 0.],
[0., 0., 1.],
[1., 0., 1.],
[0., 1., 1.],
[1., 1., 1.]])
topo = np.array([1, 4, 6, 2, 0, 5, 7, 3])
geo2 = np.zeros((len(topo), 3))
for i in range(len(topo)):
geo2[i] = geo[topo[i], :]
pts = vedo.Points(geo2).rotateY(-90)
vedo.show(pts, pts.labels("id"), axes=1) |
Beta Was this translation helpful? Give feedback.
-
If its clockwise or anti clockwise doesn't really matter, as one is just the reflection of the other, and should be able to render nicely (as it does in Paraview.:) |
Beta Was this translation helpful? Give feedback.
-
So the plan would be the following:
|
Beta Was this translation helpful? Give feedback.
-
True. What matters for the VTK readers is likely to be the order of insertion of the points which happens before the connectivity is loaded, and it's used to define the orientation. My guess is that paraview does it the other way around... but i'm not sure (i asked for it in the vtk discourse).
If I understand, at the end of the day you will need something that generates polygons (and associated data) for visualization of the different elements, as all the analysis would be already made upstream. |
Beta Was this translation helpful? Give feedback.
-
Im not very familiar with VTK and vedo,but I figured that it would be something along the lines described in: https://blog.kitware.com/modeling-arbitrary-order-lagrange-finite-elements-in-the-visualization-toolkit/ to UGrid. |
Beta Was this translation helpful? Give feedback.
-
Yes. |
Beta Was this translation helpful? Give feedback.
-
There are a few ways to think about this. In the simplest case, the mesh data might only be on vertices. The idea is to deprecate the |
Beta Was this translation helpful? Give feedback.
-
Sounds good! |
Beta Was this translation helpful? Give feedback.
-
I havent had a lot of time to look at this yet. However, if you want to start working on this, you could have a look at:
|
Beta Was this translation helpful? Give feedback.
-
Hi @jorgensd , I'm trying the following: sudo docker pull dolfinx/dolfinx
sudo docker run -ti dolfinx/dolfinx
pip3 install vedo
apt update
apt install nano
git clone https://github.com/FEniCS/dolfinx.git
cd dolfinx
git pull origin pull/1161/head
cd cpp
mkdir build
cd build
cmake ..
make install -j3
cd ../../python
pip3 install . and it installs fine. But when import dolfinx i get:
error msg seems has to do with method |
Beta Was this translation helpful? Give feedback.
-
Its tricky to reinstall dolfinx inside the prebuilt image. I would suggest using the
|
Beta Was this translation helpful? Give feedback.
-
It still complains about MPI:
but I've checked that I have both |
Beta Was this translation helpful? Give feedback.
-
Let me have a look, and I'll give you a complete set of tested instructions |
Beta Was this translation helpful? Give feedback.
-
I forgot to add the
|
Beta Was this translation helpful? Give feedback.
-
Thanks Jorgen! I'll get back to you as soon as i have something working smoothly. |
Beta Was this translation helpful? Give feedback.
-
@marcomusy Im looking forward to it! Tools such as vedo would make my life so much easier (after spending one weekend trying to generalize our matplotlib support to quad/hexes, and failing massively). |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
.. while i'm at this - for my research - I'm also implementing a mesher, to mesh arbitrary concave domains, which seems to work pretty well and fast (~50k triangles/sec) with simple syntax: from vedo import Spline, show
from vedo.pyplot import histogram
shape = Spline([[0, 0],
[1, 0],
[1.1, 4],
[1.0, 1.5],
[0.2, 5],
[-1.0, 3.0],
[0.4, 2.7],
[-1.0, 2.4],
],
closed=True).c('red4')
msh = shape.tomesh(resLine=400) # resample boundary
msh.smoothLaplacian().addQuality().addScalarBar3D()
histo = histogram(msh.getCellArray('Quality'),
aspect=3/4, c='RdYlBu', xtitle='triangle mesh quality')
show(shape.ps(3), msh, histo, N=3, sharecam=False) maybe dolfinx people will find it useful too |
Beta Was this translation helpful? Give feedback.
-
That is quite interesting! Are you planning to generalize it to other cell types (quads) or 3D? |
Beta Was this translation helpful? Give feedback.
-
oh i haven't thought about it! Not sure about quads, but for 3d it might be possible.. |
Beta Was this translation helpful? Give feedback.
-
Let me know how you get along with things:) i've spent the day updating my dolfin-x tutorial after we removed matplotlib. When vedo is ready, Im ready to add it to some of the examples, such as: https://jorgensd.github.io/dolfinx-tutorial/chapter3/em.html or https://jorgensd.github.io/dolfinx-tutorial/chapter2/ns_code1.html |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@jorgensd ..first checks with tet meshes.. import dolfinx
import dolfinx.io
import dolfinx.plot
import numpy as np
from mpi4py import MPI
try:
import vedo
except ModuleNotFoundError:
print("vedo is required for this demo")
exit(0)
mesh = dolfinx.UnitCubeMesh(MPI.COMM_WORLD, 4, 3, 5, cell_type=dolfinx.cpp.mesh.CellType.tetrahedron)
# Extract mesh data from dolfin-X
num_cells = mesh.topology.index_map(mesh.topology.dim).size_local
cell_entities = np.arange(num_cells, dtype=np.int32)
vtk_cells, cell_types = dolfinx.plot.create_vtk_topology(mesh, mesh.topology.dim, cell_entities)
scals = np.linspace(0, 1, num=len(cell_types)).astype(float)
m = vedo.TetMesh([mesh.geometry.x, vtk_cells]).addCellArray(scals,'myscal').c('jet')
# m = vedo.UGrid([mesh.geometry.x, vtk_cells, cell_types]).tomesh(shrink=0.9)
# m.cutWithPlane(normal=[1,1,-0.5]).bc('tomato')
vedo.show(m, axes=1, offscreen=1, elevation=-50).screenshot() I wonder if i should keep a specialized class for tetrahedral meshes or "unify" it as |
Beta Was this translation helpful? Give feedback.
-
MWE using dolfinx:
yields:
and
while the correponding
VTU
file contains;Which is the same as the vedo mesh has, but yields
Beta Was this translation helpful? Give feedback.
All reactions