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

Error for a coefficient defined in the UFL

0 votes

Hello,

I am trying to produce a wave in elastoplastic media. I posted my full code and supporting files on fenics support mailing list recently. If you need that to help me get this running, kindly comment below and I' ll post the link. In my UFL file, I define a time step as a coefficient 'dt' in DG space inspired from this undocumented nonlinear demo.

DG0      = FiniteElement("Discontinuous Lagrange", triangle, 0)
# Time stepping parameters (Newmark)
beta    = Coefficient(DG0)
gamma   = Coefficient(DG0)
dt      = Coefficient(DG0)

After defining it as a coefficient in UFL, I defined it as follows in the main.cpp :

// Time parameters
  double t = 0.0;
  auto dt = std::make_shared<Constant>(0.005);  // Time step 
  double T = 75*(*dt);  
  auto beta = std::make_shared<Constant>(0.36);
  auto gamma = std::make_shared<Constant>(0.7);

I get the following error which I am unable to resolve:

Error: Unable to assemble form. Reason: Coefficient number 3 ("dt")
has not been set. Where: This error was encountered inside
AssemblerBase.cpp.

Why do I get this error with 'dt' and not with 'beta' or 'gamma'?..... and the same arrangement compiles smoothly in the nonlinear demo hyperlink I provided above.

asked Jun 20, 2016 by Chaitanya_Raj_Goyal FEniCS User (4,150 points)

1 Answer

0 votes
 
Best answer

Hi,
i think (i haven't tested this suggestion) that you need to initialize the coefficient dt in the bilinear and linear part of your problem (see the lines 178 and 186 of the elastodynamics demo that you have provided).

answered Jun 20, 2016 by hernan_mella FEniCS Expert (19,460 points)
selected Jun 20, 2016 by Chaitanya_Raj_Goyal

Thanks a lot for your reply Hernan. That worked. Thankfully, now the program compiles, but I ran it and for the 1st time step, it ran 49 Newton iterations and crashed with the following error.

*** Error: Unable to solve nonlinear system with NewtonSolver.
*** Reason: Newton solver did not converge because maximum number of iterations reached.
*** Where: This error was encountered inside NewtonSolver.cpp.

This has nothing to do with the previous question though. I believe, I may have made an error in defining the solver.

...