Learning Object Oriented Programming in the Context of Using a Multi-physics Finite Element Library

processroguishSoftware and s/w Development

Nov 18, 2013 (4 years and 1 month ago)

104 views

Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

1
/15

Iason Papaioannou

Orkun Özkan Dönmez


Supervisor : Stefan Kollmansberger

Learning Object Oriented Programming


in the Context of Using a Multi
-
physics
Finite Element Library

Software Lab


2
nd

Presentation

Solution of the flow around a cylinder

using a FE library

Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

2
/15

Overview


Introduction


Specific problem description


Implementation


Creating a refineable mesh


Defining the problem


Timestepping


Driver code


Results


Steady case


Unsteady case


Summary and further steps

Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

3
/15

Introduction


is an
object
-
oriented
, open
-
source
finite
-
element library

for the simulation of
multi
-
physics

problems.

The basic features of the library are compiled in
virtual

classes or
classes with basic implemented member functions.

The user must write a code for each specific problem following a
predefined structure, i.e. creating classes
derived

from precompiled
base classes
.

Basic attributes are passed into classes using class
templates
.

Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

4
/15

Specific problem description

The 2D
steady

driven
-
cavity problem
in a square domain

S
olve

Re,
j
i i
j
j i j j i
u
u u
p
u
x x x x x
 

 
 
   
 
 
    
 

and

0,
i
i
u
x




in the square domain





0,1;1,2
i
D x i
  
, subject to the
D
irichlet boundary conditions
:



| 0,0
D
u



on the right, top and left boundaries
and



| 1,0
D
u



on the bottom boundary,
2
0
x

.

2.2m

0.15m

0.16m

0.1m

0.15m

U=V=0

outlet

inlet

(0,0)

Non
-
dimensional form of
Navier
-
Stokes

equations:


Conservation of
mass:


Conservation of
momentum:

Discretization:
9
-
node quadrilateral Crozier
-
Raviart

finite elements

Re
   

  
 
    
   
   
     
   
j
i i i
j
j i j j i
u
u u u
p
u
t x x x x x

Biquadratic interpolation of velocity


Bilinear interpolation of pressure

Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

5
/15

Implementation

Creating a refineable mesh


class

RectangleWithHoleDomain:
public

Domain;


Pass a pointer to the curvilinear geometric object (circle)


Pass the dimensions of the rectangle


Generate
macro elements

(ME)


Implement
interpolation functions

for each ME boundary


template
<
class

ELEMENT>


class

RectangleWithHoleMesh:
public virtual

Mesh;


Create the domain


Convert ME to finite elements (FE)

F
r
a
m
e
0
0
1

3
1
O
c
t
2
0
0
6

Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

6
/15

F
r
a
m
e
0
0
1

3
1
O
c
t
2
0
0
6

F
r
a
m
e
0
0
1

3
1
O
c
t
2
0
0
6

Implementation

F
r
a
m
e
0
0
1

3
1
O
c
t
2
0
0
6

Creating a refineable mesh

template
<
class

ELEMENT>

class

AdaptiveRectangleWithHoleMesh :


public
RectangleWithHoleMesh<ELEMENT>,


public
RefineableQuadMesh<ELEMENT>;


Associate each FE with a
Quad Tree


Setup
Quad Tree forest

for mesh refinement


Mesh is refined/unrefined
adaptively

in regions in which the

solution undergoes
rapid/slow variations

F
r
a
m
e
0
0
1

2
9
O
c
t
2
0
0
6

F
r
a
m
e
0
0
1

2
9
O
c
t
2
0
0
6

Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

7
/15

Implementation

Defining the problem

template
<
class

ELEMENT,
class

TIMESTEPPER>

class

FlowAroundCylinderProblem :
public
Problem;


Allocate the
timestepper


Build the
refineable

mesh


Set the
error estimator

for the adaptive refinement


Set parameters (Re) and boundary conditions

template
<
class

ELEMENT,
class

TIMESTEPPER>

class

FlowAroundCylinderProblem<ELEMENT,TIMESTEPPER>::

actions_after_adapt();

Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

8
/15

Implementation

Timestepping

template
<
class

ELEMENT,
class

TIMESTEPPER>

class

FlowAroundCylinderProblem<ELEMENT,TIMESTEPPER>::


unsteady_run(DocInfo& doc_info);


Set value of
time step

and number of time steps


Set maximum number of adaptations


Loop over the time steps


Solve adaptively using an
unsteady Newton

solver


Shift the time values back


Advance the Problem’s global time and calculate the weights

for the timestepper


Call the nonlinear solver to find unknowns at current time


Document the solution

Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

9
/15

Implementation:
Driver code

int
main(){


// Set physical parameters and dimensions


.....



//Create a new ellipse object as the central cylinder


.....



// Set up doc info


DocInfo doc_info;


doc_info.number()=0;


doc_info.set_directory("RESLT");




// Set up problem


FlowAroundCylinderProblem


<RefineableQuadCrozierRaviartElement,BDF<2> >

problem(cylinder_pt,length,height);



// Refine the mesh a couple of times


problem.refine_uniformly();


problem.refine_uniformly();




// Run the unsteady simulation


problem.unsteady_run(doc_info);}

pass the
element type
and
timestepper

Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

10
/15

Results

Steady case: Re = 20


Euclidean Norm


of velocity vector


Pressure distribution

[m/s]

[Pa]

measure points

for the pressure difference

Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

11
/15

Results

Method

Unknowns

Δ
P

FD
-

Blockstructured

13299

51159

200607

0.1169

0.1172

0.1172

FV


Blockstuctured

15000

60000

240000

0.1166

0.1173

0.1175

FE


Unstructured


Tailor
-
Hood

2298

6297

20487

0.1110

0.1160

0.1170



FE


Crozier Raviart

22077

89213


13049
(adapt.)

0.11697

0.11710

0.11738

Comparison of pressure difference

between front and end point of the cylinder with reference solutions

Steady case: Re = 20

Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

12
/15

Results

Unsteady case: Re = 100


Euclidean Norm


of velocity vector


Pressure distribution

[m/s]

[Pa]

Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

13
/15

Results

Unsteady case: Re = 100

0
0.5
1
1.5
2
2.5
0
1
2
3
4
5
6
7
8
9
10
Time [s]
ΔP [Pa]
oomph-lib
CFX
Comparison of pressure difference between

front and end point of the cylinder with reference FV solution (CFX)

2.38
2.4
2.42
2.44
2.46
2.48
2.5
2.52
9
9.1
9.2
9.3
9.4
9.5
9.6
9.7
9.8
9.9
10
Time [s]
ΔP [Pa]
oomh-lib
CFX
Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

14
/15

Summary and further steps

until now we...


... familiarised ourselves with the library‘s structure

... implemented two example problems


a 1D poisson problem


a steady 2D driven cavity problem

... solved the
flow around a cylinder

our further step is...


... to solve a
flow around a moving cylinder

Lehrstuhl für Bauinformatik

Object oriented programming using
oomph
-
lib

15
/15

Iason Papaioannou

Orkun Özkan Dönmez


Supervisor : Stefan Kollmansberger

Learning Object Oriented Programming


in the Context of Using a Multi
-
physics
Finite Element Library

Software Lab


2
nd

Presentation

Solution of the flow around a cylinder

using a FE library