← Back to team overview

dolfin team mailing list archive

Re: python vs cpp implementations

 

Hello!

In you example, u is the unknown, right? Then it shoud not be passed to
the BilinearForm (only pass parameters). It seems like you want to do
PressureEquationBilinearForm a(f);

Best,
Dag Lindbo

PS. Welcome to Dolfin&FFC!

> Hi All,
>     I'm just getting started with Dolfin/FFC and have modifed several
> of the demos into a working python code for a test problem, but am
> having difficulty getting the equivalent cpp code working.
>
> The variational form looks like
> ----------------------------------------------------------------
> element = FiniteElement("Lagrange", "triangle", 2)
>
> v = TestFunction(element)
> u = TrialFunction(element)
> f = Function(element)
>
> # set domain size coefficient h/delta
> hondel = 64.
> c = 1/hondel/hondel
>
> a = f*f*f*dot(grad(v),grad(u))*dx + c*f*v*u*dx
> L = v.dx(1)*f*f*f*dx
> ------------------------------------------------------------------
> (which arises in a non-linear wave problem)  where f is a user
> defined function (porosity) which needs to get passed to the bilinear
> form a.
> The python code (attached) works just fine,  but in the c++ code
> where I create
>
> -------------------------------------------------
> // Set up problem
>    UnitSquare mesh(32, 32);
>
>    // Create source function
>    Source f(mesh);
>
>    // Dirichlet boundary conditions
>    Function u1(mesh,1.0);
>    DirichletBoundary boundary;
>    DirichletBC bc(u1, mesh, boundary);
>
>    // Solution function
>    Function u;
>
>    // Create forms and nonlinear PDE
>    PressureEquationBilinearForm a(u);
>    PressureEquationLinearForm L(f);
>    LinearPDE pde(a, L, mesh, bc);
>
>    // Solve
>    pde.solve(u);
> ----------------------------------------------------------------
>
> Everthing compiles just fine but at runtime I get...
> Initializing DOLFIN version 0.7.3.
> Initializing PETSc with given command-line arguments.
> Creating linear PDE with one boundary condition.
> Solving linear PDE.
> terminate called after throwing an instance of 'std::runtime_error'
>    what():  *** Error: Function contains no data.
>
> I'm sure I'm just being stupid, but all help greatly appreciated
> cheers
> marc
>
> 
>
>
>
>
> ----------------------------------------------------
> Marc Spiegelman
> Lamont-Doherty Earth Observatory
> Dept. of Applied Physics/Applied Math
> Columbia University
> http://www.ldeo.columbia.edu/~mspieg
> tel: 845 704 2323 (SkypeIn)
> ----------------------------------------------------
>
>
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev
>




References