← Back to team overview

dolfin team mailing list archive

how to easily distinguish between physical entities

 

Hello,
I am new to fenics and I have a question how to handle complex BC.

In all the demos you are just using very simple boundary conditions,
which can be easily handled by a code like this:

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

 // Neumann boundary condition
 class NeumannBC : public Function
 {
   real eval(const Point& p, unsigned int i)
   {
     if ( std::abs(p.x() - 1.0) < DOLFIN_EPS )
       return 1.0;
     else
       return 0.0;
   }
 };

but I have a complex geometry, let's say I build the geometry in gmsh
and create physical entities and the dirichlet and neumann BC change
across the entities and also other parameters in the equations are
different for each entity. What is the preferred way to handle this?

This is how I do it in my FEM code so far, which uses libmesh:
I mesh the geometry in gmsh (it assigns a number of the entity to all
elements which result in meshing this particular entity), then I parse
the output file and extract element numbers belonging to each entity
and then use them in the assembly of matrices to correctly handle all
the parameters and BCs.

The gmsh unfortunately is not able to mesh my complex 3D geometry, but
fortunately tetgen is. But I need to write some scripts to extract the
correct element numbers from the tetgen output, which I haven't done
yet.

I am sure everyone who wants to solve more complex geometry need to
tackle this problem somehow, so I would be interested in your
approaches.

Also, it seems to me that dolfin only handles tetrahedrons in 3D so
far. But because I am going to use tegen anyway, it doesn't matter.

BTW, I also tried several demos and they work fine, except
dolfin-0.6.4/src/demo/pde/convection-diffusion, which runs ok and at the end:

...
Solving linear system of size 25140 x 25140 (uBlas Krylov solver).
*** Error: BiCGStab breakdown. rho = 5.54996e-26
[./dolfin/uBlasKrylovSolver.h:360: solveBiCGStab()]


Thanks for any help,
Ondrej Certik


Follow ups