- Thank you received: 0
Modifying element's vertices
3 years 8 months ago - 3 years 8 months ago #3705
by alessio
Modifying element's vertices was created by alessio
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!
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!
Attachments:
Last edit: 3 years 8 months ago by alessio.
3 years 8 months ago - 3 years 8 months ago #3707
by cwinters
Replied by cwinters on topic Modifying element's vertices
Hello alessio,
when you iterate over elements
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
and you can change the coordinates of the point corresponding to "v1" by
The change should be visible in the GUI you after calling "mesh.ngmesh.Update()".
Hope that helps.
Best,
Christoph
when you iterate over elements
Code:
for el in mesh.Elements(VOL):
print(type(el))
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
Code:
pnts = mesh.ngmesh.Points()
Code:
pnts[v1] = MeshPoint(Pnt(-1.5,-0.5,0))
Hope that helps.
Best,
Christoph
Last edit: 3 years 8 months ago by cwinters.
3 years 8 months ago #3708
by alessio
Replied by alessio on topic Modifying element's vertices
Hello Christoph,
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.
Alessio
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.
Alessio
Time to create page: 0.122 seconds