Getting node positions in higher-order elements #4078
Answered
by
dham
ethrelfall
asked this question in
Firedrake support
-
Dear community, I want to interpolate a function onto a higher-order mesh. I'm calling the function from the mpmath library and this doesn't work with the interpolate() method, so I thought I'd write the function values onto the node positions. Can I do this and how i.e. access the spatial positions of nodes on e.g. a CG(2) function space? Currently I only know how to do this at first order using mesh.coordinates.dat.data[i] to get the node positions on the lowest-order elements (CG(1)). Did search for matching discussions - nada. Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
dham
Feb 28, 2025
Replies: 1 comment 2 replies
-
Dear Ed,
The basis coefficients of any Lagrange element of any degree are the values of the function at those points. So the steps are:
1. Get x,y,z = SpatialCoordinate(mesh) [or x,y in 2d]
2. Interpolate x, y, z separately to Functions from CG2, call them X, Y, Z
3. Create a new CG2 function, and write to its .dat.data[:] from X.dat.data[:]. Y.dat.data[:] using mpmath.
However, what is the function? It might be best just to get it added to UFL and support in TSFC.
All the best
--cjc
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Extracting higher order coordinate node locations is covered in the manual here: https://www.firedrakeproject.org/interpolation.html#interpolation-from-external-data
There is no need to treat separate components separately.