Fluid Dynamics Demo 1: A 2-D incompressible CFD problem using quadrilateral elements


The main program

Let us present an program that solves the 2-D time dependent incompressible Navier-Stokes equations.


The class 'User'

We define here the class User that defined the Dirichlet boundary conditions. All other data (body, surface forces and initial conditions) are assumed null, so they don't need be defined. This class inherits from the abstract class UserData. The constructor using mesh is already implemented in UserData. We need here to define the function BoundaryCondition in a very simple way.

class User : public UserData

   User(Mesh &mesh) : UserData(mesh) { }

   double BoundaryCondition(const Point &x, int code, double time=0., size_t dof=1)
      time = 0;
      dof = 1;
      double ret = 0.0;
      if (code==1)
         ret = 0.0;
      if (code==2)
         ret = 1.;
      return ret;


An example

Let us run this program with the data presented in the following project file:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<Project name="cavity">
   <time_step value="0.1"/>
   <max_time value="1.0"/>
   <verbose value="1"/>
   <output value="1"/>
   <mesh_file value="cavity.m"/>
   <parameter label="v_file" value="cavity.v"/>
   <parameter label="p_file" value="cavity.p"/>

Note that only execution and time integration parameters are given. All other data were given through the class User.

Copyright © 1998-2016 Rachid Touzani