← Back to team overview

dolfin team mailing list archive

Re: [Question #92245]: Gradients and SubFunctions

 

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

    Status: Open => Answered

Patrick Riesen proposed the following answer:
hey phil,

you can extract or set some subfunction values with something like

*snip*
    // extract velocity solution and scale it
     dolfin::uint m_e = _e->vector().size();
     dolfin::uint m = _v->vector().size();
     double* _block = new double[m];

     dolfin::uint* _rows = new dolfin::uint[m];
     for(dolfin::uint i = 0; i < m; i++)
       _rows[i] = m_e + i;

     _evp->vector().get(_block, m, _rows);
*snap*

in the above code, evp is a function with three subfunctions (e,v,p).
i need to fetch the values from v (thats evp[1]) and do something with 
them. they are located in evp with an offset m_e (that's the length of 
e, i.e. evp[0]).
get() will return them in _block, then do something with this and use 
set(_block, m, _rows) to put the values back in.

( note that this is dolfin0.9.4, (changeset7400) )

  Since the programmers refernce is off the site, I can't
> look there.


you can generate the programmers reference yourself if you call the 
script makedoc (~/dolfin/scripts)
(you need doxygen installed and you'll find the reference in 
~/dolfin/doc/progr_ref.. )

> The second part of my question involves FunctionSapces. The only thing I am using GradAvg for is defining Neumann BCs. As I understand it, I need to define the same number of points for my Function as there are in the domain that was used to create the FunctionSpace. For example, if "mesh" has 100 nodes, if I need to define 100 values, regardless of if the subdomain I am using this Function in only has 8 nodes. All the values that I don't care about should be set to zero, or i guess it doesn't really matter, since they won't be used. At least, that's the way I've been doing when the numbering system doesn't match up with my boundary. Because when nodes 0 through 7 will be assigned the first 8 values, and if those nodes aren't on your boundary, they won't be used.
> But since it's now possible to define a Function without including a FunctionSpace, how will dolfin figure it out? 

i think that's not possible anymore. Function() will not work. you need 
to specify the FunctionSpace. Or else you use Expression.

I have a subdomain for my neumann BC. Do I just need to define values 
for every point in my subdomain?

I guess here you want to use the Expression class to specify your BC 
values. from the demos you can learn how to use the Expression class.

patrick

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