← Back to team overview

dolfin team mailing list archive

Re: Question from Dolfin user's manual

 

What is it that doesn't work? Please be more specific. Does it
compile? Can you run the program? Do you get the wrong result?

/Anders


On Fri, Apr 21, 2006 at 11:14:05PM -0500, sungskim@xxxxxxx wrote:
> Hello, Dolfin Developers !
> I am a graduate student in math department at UW-Milwaukee.
> Currently, I am exploring Dolfin User’s Manual. I tried to solve the 3D
> Poisson’s equation by following the user’s manual Chaper 7, with the
> Right_Hand_Side
> f(x,y,z) = xzsin(y) in the unit cube
> I run the following Poisson.form and main.cpp. However, I think it doesn’t work.
>  Would you please send me any comment or correction for the code in the manual?
> 
> ----- main.cpp --------
> #include <dolphin.h>
> #include “Poisson.h”
> 
> using namespace dolphin ;
> 
> //Right Hand Side
> class MyFunction : public Function
> {
>    real  operator( )  (const  Point&  p)  const
>   {   return  p.x*p.z*sin(p.y) ;   }
> } ;
> 
> //Boundary Condition
> class  MyBC : public  BoundaryCondition
> {
>   const  BoundaryValue  operator( ) (const  Point& p)
>   {
>     BoundaryValue  value ;
>     if (std::abs(p.x – 0.0) < DOLFIN_EPS)  value = 0.0 ;
>     if (std::abs(p.x – 1.0) < DOLFIN_EPS)  value = 0.0 ;
>     if (std::abs(p.y – 0.0) < DOLFIN_EPS)  value = 0.0 ;
>     if (std::abs(p.y – 1.0) < DOLFIN_EPS)  value = 0.0 ;
>     if (std::abs(p.z – 0.0) < DOLFIN_EPS)  value = 0.0 ;
>     if (std::abs(p.z – 1.0) < DOLFIN_EPS)  value = 0.0 ;
>     return value ;
>   }
> } ;
> 
> int main( )
> {
>   //Set the problem
>   MyFunction  f ;
>   MyBC  bc ;
>   Poisson :: BilinearForm  a ;
>   Poisson :: LinearForm  L(f) ;
> 
> 
>   Mesh  mesh ;
>   Mat  A ;
>   Vec   b ;
>   FEM::assemble(a, L, A, b, mesh, bc) ;
> 
>   //Solve the linear system
>   GMRES solver ;
>   Solver.solve(A, x, b) ;
> 
>   //Save function to file
>   Function  u(x, mesh, a.trial( ) ) ;
>   File file(“poisson.pvd”) ;
>   File << u ;
>   return ( ) ;
> }
> 
> =========================================
> 
> ------- Poisson.form -----------------------------
> 
> #The bilinear form a(u,v) and linear form L(v) for
> #Poisson’s equation.
> #
> #Compile this form with  FFC : ffc poisson.form.
> 
> element = FiniteElement(“Lagrange”,”tetrahedron”,1)
> 
> v = BasisFunction(element)
> u = BasisFunction(element)
> f = Function(element)
> 
> a = v.dx(i)*u.dx(i)*dx
> L = v*f*dx
> ==============================================
> 
> I just followed Chapter 7 in the manual. It didn’t work.
> Would you help me, please. Please send me any comment or correction.
> (Poisson.form was successfully compiled to Poisson.h by ffc)
> I think, main.cpp should be corrected. Help me.
> 
> 
> 
> 
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/cgi-bin/mailman/listinfo/dolfin-dev
> 

-- 
Anders Logg
Research Assistant Professor
Toyota Technological Institute at Chicago
http://www.tti-c.org/logg/



References