← Back to team overview

ffc team mailing list archive

Re: source term in bilinear form

 

Thank you.
Is there any document on the NonlinearPDE or how to use it? 

Bests,
Reza



----- Original Message ----
From: Mehdi Nikbakht <M.Nikbakht@xxxxxxxxxx>
To: Reza Farrahi Moghaddam <imriss@xxxxxxxxx>
Sent: Monday, April 14, 2008 10:03:27 AM
Subject: Re: [FFC-dev] source term in bilinear form

Hello, 
Since in your bilinearform, you have two functions(U0 and f), then you need to
call "NonlinearPoissonBilinearForm" with two arguments.
regards,
--
Mehdi




Quoting Reza Farrahi Moghaddam <imriss@xxxxxxxxx>:

> 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
> 
>  
> 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
> 
> 
>      __________________________________________________________________
> Ask a question on any topic and get answers from real people. Go to Yahoo!
> Answers and share what you know at http://ca.answers.yahoo.com


      __________________________________________________________________
Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail.  Click on Options in Mail and switch to New Mail today or register for free at http://mail.yahoo.ca

Follow ups