← Back to team overview

dolfin team mailing list archive

give me some idea

 

Hi,
   I am learning how to use the dolfin to solve the pde equation, this softeware
is really helpful. And now i met problem, could anyone give me any idea about
how to solve the equation like this:
   -grad(c(x,y)*grad(u))+b(x,y)*u=f(x,y)

   where c(x,y)=80 in some part of the domain, and c(x,y)=2 in the rest
part,b(x,y)=2 in the whole domain.

i changed the Possion.form as following:

element = FiniteElement("Lagrange", "triangle", 1)

v = TestFunction(element)
U = TrialFunction(element)

f = Function(element)
b = Function(element)
c = Function(element)

a = dot(c*grad(U), grad(v))*dx + b*U*v*dx
L = v*f*dx

and use ffc compile it ,seems no problem, and i also changed the main.cpp as
following:

int main()
{
  // Right-hand side
  class Source : public Function
  {
    real eval(const Point& p, unsigned int i)
    {
      return p.x*sin(p.y);
    }
  };

  //define function c
  class MyFunc : public Function
  {
     real eval(const Point& p, unsigned int i)
     {
        if (p.x>0.25 && p.x<0.75 && p.y<0.25 && p.y<0.75)
        {
            return 80;
        }
        else
        {
            return 2;
        }
     }
  };

  //definde funcion b
   class MyFunb : public Function
  {
     real eval(const Point& p, unsigned int i)
    {
        return 2;
    }
  };



  // Boundary condition
  class MyBC : public BoundaryCondition
{
    void eval(BoundaryValue& value, const Point& p, unsigned int i)
    {
      if ( std::abs(p.x - 1.0) < DOLFIN_EPS )  value = 0.0;
      if ( std::abs(p.y - 1.0) < DOLFIN_EPS )  value = 0.0;
      if ( std::abs(p.x - 0.0) < DOLFIN_EPS )  value = 0.0;
      if ( std::abs(p.y - 0.0) < DOLFIN_EPS )  value = 0.0;
    }
  };

  // Set up problem
  Mesh mesh;
  File in("mesh1.xml");
  in>>mesh;
  Source f;
  MyFunc c;
  MyFunb b;
  MyBC bc;
  Poisson::BilinearForm a;
  Poisson::LinearForm L(f);
  PDE pde(a, L, mesh, bc);

  // Compute solution
  Function U = pde.solve();

  // Save solution to file
  File file("poisson.m");
  file << U;

  return 0;
}
  however, when i make it ,it shows me the error message like this:

[]# make
`dolfin-config --compiler` `dolfin-config --cflags` -c main.cpp
main.cpp: In function `int main()':
main.cpp:90: no matching function for call to `dolfin::Poisson::BilinearForm::
   BilinearForm()'
Poisson.h:24: candidates are: dolfin::Poisson::BilinearForm::BilinearForm(const
   dolfin::Poisson::BilinearForm&)
Poisson.h:403:
   dolfin::Poisson::BilinearForm::BilinearForm(dolfin::Function&,
   dolfin::Function&)
make: *** [main.o] Error 1

  it seems i wrote the wrong .form file, who can give me any idea about how to 
fix it, since i am still at the very beginning of learning to use dolfin.
thanks very much!

jun




Follow ups

References