← 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

Garth Wells proposed the following answer:

Phil Marinier wrote:
> Question #92245 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/92245
> 
>     Status: Solved => Open
> 
> Phil Marinier is still having a problem:
> These are my declarations
> 
> 100   dolfin::Function GradA;

It's not possible to construct a Function without a FunctionSpace (at
least in recent releases of DOLFIN).

Also, some bugs in function assignment were fixed in the latest release
(0.9.5), so you should update it.

Garth

> 101   dolfin::Function& GradAX = GradA[0];
> 102   dolfin::Function& GradAY = GradA[1];
> 103   dolfin::Function GradC;
> 104   dolfin::Function& GradCX = GradC[0];
> 105   dolfin::Function& GradCY = GradC[1];
> 
> This is my error message
> 
> Fiterator.cc: In member function ‘void Fiterator::solve(double*, double*, double*)’:
> Fiterator.cc:101: error: invalid initialization of non-const reference of type ‘dolfin::Function&’ from a temporary of type ‘dolfin::SubFunction’
> Fiterator.cc:102: error: invalid initialization of non-const reference of type ‘dolfin::Function&’ from a temporary of type ‘dolfin::SubFunction’
> Fiterator.cc:104: error: invalid initialization of non-const reference of type ‘dolfin::Function&’ from a temporary of type ‘dolfin::SubFunction’
> Fiterator.cc:105: error: invalid initialization of non-const reference of type ‘dolfin::Function&’ from a temporary of type ‘dolfin::SubFunction’
> 
> It compiles when I do the deep copy (remove the & from above
> declarations) but then I get this error message when I try to run the
> program:
> 
> terminate called after throwing an instance of 'std::runtime_error'
>   what():  *** Error: Unable to extract sub function, missing coefficients (user-defined function).
> [wolf:26196] *** Process received signal ***
> [wolf:26196] Signal: Aborted (6)
> 
> which means that the Function does not yet have subfunctions? which
> makes sense I guess. I will use the vector().set(block, num_rows, rows)
> as proposed by Patrick, but it would be much more convinient to use the
> shallow subfunction.
> 
> Thank you again
> 
> Phil
>

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