- Thank you received: 0
Can I edit mesh points after a solution, in order to rotate the solution.
- jameslowman
- Topic Author
- Offline
- New Member
Less
More
5 years 3 months ago #1870
by jameslowman
Can I edit mesh points after a solution, in order to rotate the solution. was created by jameslowman
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?
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?
- mneunteufel
- Offline
- Premium Member
Less
More
- Thank you received: 59
5 years 3 months ago #1871
by mneunteufel
Replied by mneunteufel on topic Can I edit mesh points after a solution, in order to rotate the solution.
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
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
Attachments:
The following user(s) said Thank You: jameslowman
- jameslowman
- Topic Author
- Offline
- New Member
Less
More
- Thank you received: 0
5 years 3 months ago - 5 years 3 months ago #1872
by jameslowman
Replied by jameslowman on topic Can I edit mesh points after a solution, in order to rotate the solution.
Thanks so much for your quick reply, and code. I think you may have solved my problem.
Last edit: 5 years 3 months ago by jameslowman.
- jameslowman
- Topic Author
- Offline
- New Member
Less
More
- Thank you received: 0
5 years 3 months ago - 5 years 3 months ago #1873
by jameslowman
Replied by jameslowman on topic Can I edit mesh points after a solution, in order to rotate the solution.
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.
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.
Last edit: 5 years 3 months ago by jameslowman.
- walker_tr9
- Offline
- Senior Member
Less
More
- Thank you received: 0
2 years 8 months ago #4322
by walker_tr9
Replied by walker_tr9 on topic Can I edit mesh points after a solution, in order to rotate the solution.
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.
2 years 8 months ago #4324
by joachim
Replied by joachim on topic Can I edit mesh points after a solution, in order to rotate the solution.
within the latest nightly you find a
mesh.Coordinates()
which returns a numpy view of the point coordinates
mesh.Coordinates()
which returns a numpy view of the point coordinates
Time to create page: 0.103 seconds