← Back to team overview

dolfin team mailing list archive

Re: [Question #154697]: computation of basis function values and derivatives

 

On Fri, Apr 29, 2011 at 08:01:55AM -0000, Nguyen Van Dang wrote:
> New question #154697 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/154697
>
> Hello,
>
> I am working with FEnics on C++. I want to take the values of basis function at each vertex directly. I read BasisFunction.h online but I don't know how to use this one.
>
> Finally, I found in "Poisson.h" (created from "Poisson.ufl" in dolfin/demo/pde/poisson/cpp) class "poisson_finite_element_0" in which there is function "evaluate_basis(unsigned int i, double* values, double* coordinates, const ufc::cell& c)".
> In "main.cpp" (in the same directory), I wrote:
>    unsigned int i;
>    double* values;
>    double* coordinates;
>    ufc::cell c;
>    poisson_finite_element_0 finite_element;
>    finite_element.evaluate_basis(i,values,coordinates,c);
> I compiled it without any errors.
> The problem is that how to input the value for c?
> In fact, I have read the paper "efficient representation of computational meshes" of A. Logg and I could make a loop for all cells as well as vertices. However, the cell in this loop doesn't match with c anymore (because they have different type). Moreover, it is difficult to initialize the cell data structure:
>   c.entity_indices = new unsigned int [...];
>   c.coordinates = new double[..];
>   .....
>
> Is there any simple way to do this? Do you have any examples working on basis functions?

Look at the FiniteElement class and the function interpolate_vertex_values.

More generally (for evaluation at arbitrary points), you can use the
functions evaluate_basis or evaluate_basis_all.

--
Anders



Follow ups

References