Hello to everyone,
I am working on a mesh adaptation algorithm and I would need to manually edit the vertices or points of single elements. It looks like I cannot set the attributes vertices and points of the objects of the class 'netgen.libngpy._meshing.Element3D.
I would like to know if there is another way to perform this operation (maybe deleting the element and create a new one).
Here attached there is a simple example of of a tetrahedron uniformly refined in 8 tetrahedra, for which I would like to change the 4 inner tetrahedra, changing the diagonal for one of the other 2 diagonals of the octahedron.
Thank you very much for your time and kindness in advance!
when you iterate over elements
for el in mesh.Elements(VOL):
you get objects of the type “Ngs_Element”, which is defined in python_comp_mesh.cpp:L252. All the attributes of this type are read only, thus your approach does not work.
If you really want to change some elements, you would have to copy the mesh points, copy the unchanged elements and then add your custom elements. Might be helpful to check this out.
Modifying/moving some points, leaving the mesh topology the same, is way easier. The mesh on the Netgen side provides a reference to the points
pnts = mesh.ngmesh.Points()
and you can change the coordinates of the point corresponding to “v1” by
pnts[v1] = MeshPoint(Pnt(-1.5,-0.5,0))
The change should be visible in the GUI you after calling “mesh.ngmesh.Update()”.
Hope that helps.
thank you very much for your quick answer!
Changing the point’s coordinates is something I need to do anyway, but I do need to change the topology of the mesh.
So to copy the mesh as you said it is the only way to go.
Thank you, again, it was very helpful.