Can I edit mesh points after a solution, in order to rotate the solution.

Cheers,

I am attempting to solve a simple PDE on a defined mesh, then I wish to rotate that solution (the mesh is centered around the origin) so that it may be interpolated onto another mesh.

I know I have access to the points by means of:

for v in mesh.vertices:
print(v.point)

but unfortunately, I am unable to edit the points in the same manner.

Is there a way to edit a meshes domain location after a solution is saved on a gridfunction?

Hi jameslowman,

it is possible to copy the mesh and to interpolate the old GridFunction into a new one.
Maybe the attached code can help.

Best,
Michael

https://ngsolve.org/media/kunena/attachments/889/movingmesh.py

Attachment: movingmesh.py

Thanks so much for your quick reply, and code. I think you may have solved my problem.

For all who encounter this problem in the future: mneunteufel has the answer in his code generously shared in his response. You can edit mesh points directly (and at any point in execution) via the ngmesh.Points function:

for p in mesh.ngmesh.Points():
px,py = p[0], p[1]
p[0] = func1(px,py)
p[1] = func2(px,py)

where func1, func2 are whatever you choose to mutate your mesh.

Thanks again mneuteufel.

The last post gives an ok method, but is there a way to update the mesh points as a numpy array? The solution above assumes we have explicit functions to give new mesh coordinates. It would be more convenient to pass in my own array. And yes, I already know about the mesh deformation method.

within the latest nightly you find a

mesh.Coordinates()

which returns a numpy view of the point coordinates

Well hot dog! Thanks.

How do I get the latest nightly again? I did this before to get the most recent pre-release:

pip install ngsolve==6.2.2202.dev38

But telling pip to upgrade with that doesn’t work.

How do I upgrade my install to the latest nightly with pip?

You can check the latest pip pre-releases ngsolve · PyPI . As far as I’m aware, the nighly builds are not yet automatically released on pypi. I you need the latest nighly release, I guess your only options are to get the from the downloads section or build from sources.

Note: this functionality has changed to:

mesh.ngmesh.Coordinates()