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.

Basis Functions and Interpolation

More
3 years 8 months ago #3114 by oliverxia2020
Dear NGSolve community,

I am new to NGSolve and I'd like to ask two basic questions.

1. How can I get the ordering of the basis functions on each element?
I know we can use
Code:
fes.GetDofNrs(el)
to get the DOF number for each element. But I wonder how can I know what basis function corresponds to a given DOF. For example, I am using L2 space for quadrilateral meshes. I know the L2 space uses a tensor product of Legendre Polynomials in x and y directions. But I notice that in some elements, the basis functions are ordering like 1, y, x, x*y...., while in some other element, they are ordering like 1, x, y, x*y. Is there an easy way to know the ordering of the basis functions in each element?

2. Can I do interpolation with a set of points?
I know we can use GridFunction.Set to interpolate a CoefficientFunction, but I wonder if I have a set of points and values (x_i, y_i, eval_i), can I interpolate (or do least squares) to an element in the finite element space?

Thank you for answering my questions.

Best,
Oliver
More
3 years 8 months ago #3115 by joachim
Hi Oliver,

the transformation from local coordinates to global coordinates depends on the element vertex numbers. This ensures consistent orientation on edges and faces.
It would not be necessary for L2, but we made L2 consistent with the other spaces.

See Sabine's thesis:
www.numa.uni-linz.ac.at/Teaching/PhD/Finished/zaglmayr-diss.pdf
around page 66

Or have a look directly into the code:
github.com/NGSolve/ngsolve/blob/master/fem/l2hofe_impl.hpp
line 403 is the L2-quad

The face f is ordered with the vertex numbers, f[0] becomes the smallest.



Here is a pure Python-solution for least squares approximation of arbitrary point data.
If you need performance, you can recode the same in C++.
If you want to interpolate data from a structured grid, you can use the VoxelCoefficientFunction.
If your interpolation points are given on the reference element, you can use user-defined integration-rules.


best,
Joachim
The following user(s) said Thank You: oliverxia2020
More
3 years 8 months ago #3117 by oliverxia2020
Hi Joachim

Thank you for your reply. I understand them now.

Best,
Oliver
Time to create page: 0.140 seconds