← Back to team overview

dolfin team mailing list archive

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

 

Question #154697 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/154697

    Status: Open => Answered

Johan Hake proposed the following answer:
dolfin::FiniteElemens is a thin wrapper around ufc::finite_element and are 
ment for the dolfin library to access. Therefore are most of the function only 
available using ufc cell. However, some of the methods have been made 
available using a dolfin::cell. These are evaluate_basis and 
evaluate_basis_all. The last one only in the development version of dolfin. 

Garth or Anders need to comment on if we want to dublicate more of these 
functions or if we should force the user to construct a UFCCell to call the 
methos with. If I am not totally of the latter should be possible by:

...
#include <"dolfin/fem/UFCCell.h">
...
dolfin::UFCCell ufc_cell(c);
finite_element.evaluate_basis_derivatives(i,n,dvalues,coordinates,ufc_cell)


Johan


On Sunday May 1 2011 02:45:30 Nguyen Van Dang wrote:
> Question #154697 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/154697
> 
>     Status: Answered => Open
> 
> Nguyen Van Dang is still having a problem:
> Thank you very much for your reply.
> However, I still got problem with evaluate_basis_derivatives. My code is as
> follows:
>   Poisson::FunctionSpace V(mesh);
>   const dolfin::FiniteElement& finite_element = V.element();
>   const dolfin::Cell& c = Cell(mesh,0);
>   unsigned int i = 0;
>   unsigned int n = 1;
>   double values[1] = {0.0};
>   double coordinates[2] = {0.0,0.5};
>   //finite_element.evaluate_basis(i,values,coordinates,c)  ;
>   //std::cout<<"basis_value ="<<*values<< std::endl;
>   double dval[2] = {0.0,0.0};
>   double* dvalues = &dval[0];
>   unsigned int n = 1;
>   finite_element.evaluate_basis_derivatives(i,n,dvalues,coordinates,c) ;
> I got error because of the fourth variable c. In my program c is declared
> as dofin::Cell& but in original function its type is ufc::cell&.
> My questions are:
> 1. Why didn't I get this problem for evaluate_basis?
> 2. What will I do to fix this problem for evaluate_basis_derivatives?
> 
> Please help me again.
> Thanks in advance.
> Nguyen Van Dang
> 
> On Fri, Apr 29, 2011 at 3:24 PM, Anders Logg <
> 
> question154697@xxxxxxxxxxxxxxxxxxxxx> wrote:
> > Your question #154697 on DOLFIN changed:
> > https://answers.launchpad.net/dolfin/+question/154697
> > 
> >     Status: Open => Answered
> > 
> > Anders Logg proposed the following answer:
> > 
> > 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
> > 
> > --
> > If this answers your question, please go to the following page to let us
> > know that it is solved:
> > https://answers.launchpad.net/dolfin/+question/154697/+confirm?answer_id=
> > 0
> > 
> > If you still need help, you can reply to this email or go to the
> > following page to enter your feedback:
> > https://answers.launchpad.net/dolfin/+question/154697
> > 
> > You received this question notification because you are a direct
> > subscriber of the question.

-- 
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.