← Back to team overview

dolfin team mailing list archive

Re: [Question #129296]: defining a discrete function

 

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

    Status: Open => Answered

Johan Hake proposed the following answer:
On Thursday October 14 2010 06:24:26 andi wrote:
> Question #129296 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/129296
> 
>     Status: Answered => Open
> 
> andi is still having a problem:
> 
> On 14/10/10 11:50, Jack wrote:
> > Question #129296 on DOLFIN changed:
> > https://answers.launchpad.net/dolfin/+question/129296
> > 
> > Jack requested for more information:
> > This is also a problem that I'd also like a solution for. Because, the
> > Vector interface doesn't support the '[]' operator, in the past, I've
> > had to resort to setting the vector via:
> > 
> > void set(const double* block, uint m, const uint* rows)
> > 
> > But, this seems somewhat convoluted.
> > 
> > Therefore, trying what you suggested, Johan, one gets the error:
> > 
> > error: lvalue required as left operand of assignment

Yes, I was a little bit too hasty with the suggestion. I am probably poluted 
with too much PyDOLFIN coding ;)

Because our Vectors are just thin wrappers around other linear algebra 
objects, arent the "set operator[]" implemented. Just the "get operator[]". 

You could construct an array and fill this with values too. This can then be 
used to set the values of the vector:

  Array<double> values(v.size());

  // Fill values...
  v.set_local(values);

> void set(const double* block, uint m, const uint* rows)
> 
> is the way I got a solution as well. Furthermore, I had to define a
> GenericVector, and not a Vector. 
>
> But can I ask you another question?
> To make a proper assignment of the vector values for the function we
> want to define, we need to figure out which the dof mapping is. Have you
> used this feature? If yes, how you did it?

You might post another question with a particular example for this
question.

Johan

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