dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #02442
Question from Dolfin user's manual
Hello, Dolfin Developers !
I am a graduate student in math department at UW-Milwaukee.
Currently, I am exploring Dolfin Users Manual. I tried to solve the 3D
Poissons equation by following the users 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 doesnt 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
#Poissons 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 didnt 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.
Follow ups