Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

Modifying element's vertices

More
3 years 1 hour ago - 3 years 1 hour ago #3705 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!
Last edit: 3 years 1 hour ago by alessio.
More
2 years 11 months ago - 2 years 11 months ago #3707 by cwinters
Hello alessio,

when you iterate over elements
Code:
for el in mesh.Elements(VOL): print(type(el))
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
Code:
pnts = mesh.ngmesh.Points()
and you can change the coordinates of the point corresponding to "v1" by
Code:
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.
Best,
Christoph
Last edit: 2 years 11 months ago by cwinters.
More
2 years 11 months ago #3708 by alessio
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
Time to create page: 0.163 seconds