← Back to team overview

ffc team mailing list archive

Re: source term in bilinear form

 



Reza Farrahi Moghaddam wrote:
Hello,
I am not sure if this post fits the ffc-dev list, but I would be grateful if you send me some suggestions. I want to use dolfin/ffc for solving image processing problems. I start from Nonlinear Poisson demo. After linearization of the governing weak equation, the input form file is as follows:
element = FiniteElement("Lagrange", "triangle", 1)
v = TestFunction(element)
U = TrialFunction(element)
U0= Function(element)
f = Function(element)
a = -v*(U0-f)*dot(grad(U0),grad(U))*dx
L = v*(0.01+dot(grad(U0),grad(U0)))*(U0-f)*dx + 0.01*dot(grad(v),grad(U0))*dx The "f" represents the input image (at moment only a simple analytic function is used). The form file compiles well, but when I try to make the main program, there are some errors on NonlinearPoissonBilinearForm matching.
The complete log of make:
[rfarahi@alteran cpp]$ make
`pkg-config --variable=compiler dolfin` `pkg-config --cflags dolfin` -c main.cpp
main.cpp: In function `int main(int, char**)':
main.cpp:89: error: no matching function for call to `NonlinearPoissonBilinearForm::NonlinearPoissonBilinearForm(dolfin::Function&)' NonlinearPoisson.h:4672: note: candidates are: NonlinearPoissonBilinearForm::NonlinearPoissonBilinearForm(const NonlinearPoissonBilinearForm&) NonlinearPoisson.h:4675: note: NonlinearPoissonBilinearForm::NonlinearPoissonBilinearForm(dolfin::Function&, dolfin::Function&)
mpic++: No such file or directory
make: *** [main.o] Error 1


You need to pass a function to your bilinear form for f.

Garth

If I change the script and delete the "f" term from the bilinear form, the error doesn't show up:
element = FiniteElement("Lagrange", "triangle", 1)
v = TestFunction(element)
U = TrialFunction(element)
U0= Function(element)
f = Function(element)
a = -v*(U0)*dot(grad(U0),grad(U))*dx
L = v*(0.01+dot(grad(U0),grad(U0)))*(U0-f)*dx + 0.01*dot(grad(v),grad(U0))*dx The input cpp file:
// Copyright (C) 2006-2007 Garth N. Wells.
// Licensed under the GNU LGPL Version 2.1.
//
// Modified by Anders Logg, 2005
//
// First added:  2005
// Last changed: 2007-08-20
//
#include <dolfin.h>
#include "NonlinearPoisson.h"
using namespace dolfin;
// Right-hand side
class Source : public Function
{
  public:
    Source(Mesh& mesh) : Function(mesh) {}
    real eval(const real* x) const
    {
      return x[0];
    }
};
// Dirichlet boundary condition
class DirichletBoundaryCondition : public Function, public TimeDependent
{
  public:
DirichletBoundaryCondition(Mesh& mesh, real& t) : Function(mesh), TimeDependent(t) {}
    real eval(const real* x) const
    {
      return 1.0;
    }
};
// Sub domain for Dirichlet boundary condition
class DirichletBoundary : public SubDomain
{
  bool inside(const real* x, bool on_boundary) const
  {
    return std::abs(x[0] - 1.0) < DOLFIN_EPS && on_boundary;
  }
};
int main(int argc, char* argv[])
{
  dolfin_init(argc, argv);
// Set up problem
  UnitSquare mesh(16, 16);
  // Pseudo time
  real t = 0.0;
  // Create source function
  Source f(mesh);
  // Dirichlet boundary conditions
  DirichletBoundary dirichlet_boundary;
  DirichletBoundaryCondition g(mesh, t);
  DirichletBC bc(g, mesh, dirichlet_boundary);
  // Solution function
  Function u;
  // Create forms and nonlinear PDE
  NonlinearPoissonBilinearForm a(u);
  NonlinearPoissonLinearForm L(u, f);
  NonlinearPDE pde(a, L, mesh, bc);
  // Solve nonlinear problem in a series of steps
  real dt = 1.0; real T  = 3.0;
//  pde.dolfin_set("Newton relative tolerance", 1e-6);
//  pde.dolfin_set("Newton convergence criterion", "incremental");
  // Solve
  pde.solve(u, t, T, dt);
  // Plot solution
  plot(u);
  // Save function to file
  File file("nonlinear_poisson.pvd");
  file << u;
  return 0;
}
Any suggestion? Bests,
Reza

------------------------------------------------------------------------
Looking for the perfect gift?* Give the gift of Flickr!* <http://www.flickr.com/gift/>


------------------------------------------------------------------------

_______________________________________________
FFC-dev mailing list
FFC-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/ffc-dev



References