dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #09133
Re: Visualizing basis functions
2008/8/11 Anders Logg <logg@xxxxxxxxx>
> On Sun, Aug 10, 2008 at 03:54:25PM +0200, Evan Lezar wrote:
> > Hi there
> >
> > After some time away I have once again been able to try and get do grips
> with
> > dolfin. By a bit of a round about way I was able to solve a
> magnetic-field
> > based eigenvalue problem giving me the cutoff wavenumbers for a square
> > waveguide structure - it is still, however, a work in progress.
> >
> > One question I do have is regarding the visualization of the results I
> have
> > obtained. To this end I have two questions - the first is simply the
> > visualization of the basis functions (vector Nedelec) themselves (see the
> > attached image taken from Finite Element Method for Electromagnetics by
> Volakis
> > et al) - how could this be achieved in dolfin? Put another way - how can
> I set
> > the coefficient for a single basis function equal to 1 and zero the rest
> and
> > display the result?
>
> Marie Rognes has code for doing just this (plotbases.py in the
> bdm-2007 repository). I don't want to post it myself, but I imagine
> she would be willing to post the code. Marie?
>
> > Then the second question builds on this. If I have the coefficients
> associated
> > with all the basis functions in a system, how would I set up a function
> to
> > calculate the weighted sum of the vector basis functions anywhere in the
> mesh?
> >
> > I am using pydolfin.
> >
> > If anything is unclear, please contact me so that I can clarify matters.
>
> If you have a Function u, you can just call u.eval() to evaluate it at
> any point x. This will locate the cell to which x belongs and compute
> the linear combination. Take a look at the demo in demo/function/python/.
>
Anders
I am communicating with Marie regarding the visualization of the basis
functions - I am still running into problems with the function evaluation.
Consider the following:
mesh = UnitSquare(1,1)
element = FiniteElement("Nedelec", "triangle", 0)
# obtain a list of coefficients for the basis fuctions in the finite element
system
f = Function(element, mesh, coefficient_list)
Now this is where the problems start. As far as I am aware, f should be a
vector function which could be evaluated at any point (x,y), so for
argument's sake, let
p = array((0.5,0.5))
then if I execute the following
F_val = f.eval(p)
Then F_val should contain the x and y components of the function as a
weighted sum of the basis functions?
Please let me know if I am understanding this correctly, or if I am doing
something wrong.
Evan
Follow ups
References