← Back to team overview

dolfin team mailing list archive

Boundary conditions for Stokes

 

Hello,

I was trying to calculate Stokes flow through along a 2D horizontal
channel. I applied pressure boundary conditions 1 at the left boundary
and 0 at the right boundary, and no-flow at to and bottom boundaries.  

But I got a wrong pressure field (see enclosed pic). 

The following is the code:

//-----------------------------------------
#include <dolfin/Stokes2D.h>
#include <dolfin/Stokes3D.h>
#include <dolfin/Solver.h>
#include <dolfin/StokesSolver.h>

using namespace dolfin;

// Right-hand side
class MyFunction : public Function
{
  real eval(const Point& p, unsigned int i)
  {
          return 0.0;
  }
};
// Boundary condition
class MyBC : public BoundaryCondition
{
  void eval(BoundaryValue& value, const Point& p, unsigned int i)
  {

    // Boundary condition for pressure
    if ( std::abs(p.x - 0.0) < DOLFIN_EPS )
    {
	    if ( i == 2 )
	    {
	      value = 1.0;
	      return;
	    }
		}
    if ( std::abs(p.x - 1.0) < DOLFIN_EPS )
    {
	    if ( i == 2 )
	    {
	      value = 0.0;
	      return;
	    }
		}		
		
    // Boundary condition for velocity
/**
    if ( std::abs(p.x - 0.0) < DOLFIN_EPS )
    {
      if ( i == 0 )
				value = 1.0;
      else if ( i == 1 )
				value = 0.0;
		}
    else if ( std::abs(p.x - 1.0) < DOLFIN_EPS )
    {
      if ( i == 0 )
				value = 1.0;
      else if ( i == 1 )
				value = 0.0;

    }
**/
    if ( std::abs(p.y - 0.0) < DOLFIN_EPS )
    {
      if ( i == 0 )
				value = 0.0;
      if ( i == 1 )
				value = 0.0;
    }
    else if ( std::abs(p.y - 1.0) < DOLFIN_EPS )
    {
      if ( i == 0 )
				value = 0.0;
      if ( i == 1 )
				value = 0.0;
    }
  }
};

int main()
{
  UnitSquare mesh(32, 32);
  MyFunction f;
  MyBC bc;
  
  StokesSolver::solve(mesh, f, bc);
  
  return 0;
}

//---------------------------------------------

I used Dolfin 0.5.12.

Any suggestion what might have done something wrong?

Regards

Jingsheng Ma


Dr. Jingsheng Ma
Institute of Petroleum Engineering
Heriot-Watt University
Edinburgh, UK, EH14 4AS  
Tel: 00 44 (0)131 451 8296
Fax: 00 44 (0)131 451 3127
Email: Jingsheng.Ma@xxxxxxxxxxxx <mailto:Jingsheng.Ma@xxxxxxxxxxxx> 
web: http://www.pet.hw.ac.uk

 

 


Attachment: pipe2d.jpg
Description: pipe2d.jpg