dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #16910
Re: [Question #92245]: Gradients and SubFunctions
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
>
Follow ups
References