This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Issue with C++ version of adaptive Poisson demo

+2 votes

Hi Everyone, I'm playing with the C++ version of the adaptive Poisson demo and have run into some strange behavior.

Out of the box it runs fine. However, if I change the goal functional in the UFL file to something other than M=u*dx(), say M = u * u * dx(), then I get the error below.

This doesn't happen in the python version where I have tried all sorts of goal functionals.

Could someone verify this? It seems like some sort of bug but I'm not sure what and where.

Thanks,
Dave

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at


*** fenics@fenicsproject.org


*** Remember to include the error message listed below and, if possible,
*** include a minimal running example to reproduce the error.


*** -------------------------------------------------------------------------
*** Error: Unable to assemble form.
*** Reason: Coefficient number 0 ("__discrete_primal_solution") has not been set.
*** Where: This error was encountered inside AssemblerBase.cpp.
*** Process: 0


*** DOLFIN version: 1.6.0dev
*** Git changeset: 823502fdf5bf550d5515e595a661a241596fff1e
*** -------------------------------------------------------------------------

asked Aug 5, 2015 by david.bernstein FEniCS User (2,000 points)
edited Aug 5, 2015 by david.bernstein

Hello,

I ran into a similar issue while trying to implement adaptive meshing for the elasticity problem.
Since elasticity is a vector valued solution, I have no choice but to create a scalar function of my solution for the goal functional. I got the exact same error message as you.

Interestingly, FEniCS is able to compute one solution before crashing.

1 Answer

0 votes

You need to assign u to the u inside the goal functional. Not really sure why this is not necessary when M = u * dx.

AdaptiveProblem::GoalFunctional M(mesh);
M.u = u;
answered Aug 6, 2015 by ttreerat FEniCS Novice (220 points)

Did you actually get this to work with the C++ demo code? I get this error:

/main.cpp:60:5: error: no member named 'u' in 'AdaptivePoisson::Form_goal'
M.u = u;

I was using the adaptive nonlinear solver and I assumed that it's the same for the linear case. I just tested it out on the adaptive linear solver and I'm having the same problem you're having, so clearly, that's not the case. You shouldn't have to assign __discrete_primal_solution though. This might be a bug in the C++ interface.

Ok, thanks so much for looking at it. Interesting that the nonlinear adaptive solve behaves differently.

...