Sei sulla pagina 1di 23

Technical Documentation: ICOFSI version 0.

January 6, 2011

1
Contents
1 The Purpose 3

2 Preliminary remark 3

3 Overview of the installation 3

4 Installation of Distributions 3
4.1 OpenFOAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
4.2 DEAL.II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4.3 ICOFSI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

5 The Mesh 5
5.1 OpenFOAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
5.2 DEAL.II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
5.3 Boundary specification . . . . . . . . . . . . . . . . . . . . . . 5

6 The Input to ICOFSI 5


6.1 OpenFOAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
6.2 DEAL.II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

7 Putting all together 6


7.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
7.2 Flow chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
7.3 Setting the damping . . . . . . . . . . . . . . . . . . . . . . . 7
7.4 Setting the threshold . . . . . . . . . . . . . . . . . . . . . . . 7

8 Contact 7

2
1 The Purpose
A description of the installation and the input to the C++ package ICOFSI.

2 Preliminary remark
The diploma work contains further technical details of the implementation
[1]. The reader should regard this document as a complement to section 3.1
in this thesis. At present, the source code is provided by the author of the
project through email. Note: The reader of this document is assumed to have
knowledge of DEAL.II and OpenFOAM.

3 Overview of the installation


The code ICOFSI is written in the context of OpenFOAM using namespace
technique to encapsulate DEAL.II,

• Download the distributions from www.dealii.com and www.openfoam.com.

• Install each distribution separately by following instructions [8, 9].

• verify the correctness of distribution separately by execute tutorials.

• unpack ICOFSI

• open Make/file and Make/options and make necessary changes.

• verify ICOFSI by apply executable on reference case

Note:Follow the README, but if binaries is used from OpenFOAM, en-


sure that alla common libraries and DEAL.II is compiled with the compiler
provided in that distribution.

4 Installation of Distributions
Install the latest version of the packages. Read the README files. Verify the
distribution by running tutorials and control that all third party programs
are not conflicting the distributions. Important: The compiler must be the
same for both packages.

4.1 OpenFOAM
If older distributions than OpenFOAM 1.6 is used for OpenFOAM, some
modification of the code is necessary since the option flags for running Open-
FOAM case have been modified which affect the path variables used in the

3
load and write routines such as in dealiiGrid and DynamicElastic. See Ap-
pendix, [Older distribution than OpenF OAM 1.6]. The OpenFOAM pack-
age is downloaded from http://www.openfoam.com/. For most linux plat-
forms the following command is often sufficient, from the root of the distri-
bution catalogue,
wmake all
Recommendation: Download the binaries, see for further detailed instruc-
tions [9].

4.2 DEAL.II
The deal.II package is downloaded from http://www.dealii.com [8]. For most
linux platforms the following is sufficient, from the root of the distribution
catalogue,
./configure
make all
Note: If binaries used for OpenFOAM, the provided compiler must be used
by ./configure options.

4.3 ICOFSI
ICOFSI is written in the OpenFOAM context. Place all code under a di-
rectory together with a M ake directory and compile by wmake gives an
executable defined in Make/file. See Appendix [ICOF SI Installation] for
a details. An overview of the key files,
• icofsi.C, the main code, icoDymFOAM as template. Contain the defi-
nition of the traction.
• DynamicElastic.H, the structured part solver, step-8 as template.
• IcoDymFOAN.H, the kernel of template for icofsi.C, the fluid part
solver.
• dealiiGrid.H, the mesh handler for structured grid.
• AutoMesh.H, the ALE step.
• InterGridMapping.H, the mapping between fluid and structured mesh
[ALE].
• SetBoundaryIndicator.H, defines the boundary condition by proximity
between fluid and structure.
The main code is icof si.C involves both OpenFOAM and DEAL.II context
using namespace technique.

4
5 The Mesh
5.1 OpenFOAM
The boundaries to be specified is called patches in OpenFOAM, see Ap-
pendix [constant/couplingP arameters]. The procedure in generating fluid
mesh for OpenFOAM is straightforward, there is several conversion routines
that is available [2]. It is recommended that a quadrilateral mesh is applied
on the contact surface to the structure. The there is only one patch for the
fixed surface.

5.2 DEAL.II
For structured grid, the DEAL.II offers several options but the version 0.9
code is restricted to .msh format [7]. For more advanced mesh generator
than primitives see Appendix [Gmesh]. The class dealiiGrid handle the
DEAL.II I/O for the structure regarding the loading/writing mesh.

5.3 Boundary specification


There is a routine that automatic matches couplings surfaces, the setBoundaryIndicator.H,
which project each fluid face point at couplings surface onto each structure
face element and if within a threshold to the cell surface it is marked Neu-
mann [movable] and Dirichlet otherwise [fixed]. This require however that
the fluid mesh is to be finer than the structure initial before refinement is
applied, which calls for the reason using this parameter cycle/refinement.
Note: threshold for surface normal alignment and the distance can be re-
quired to be changed for the purpose of correct mapping.

6 The Input to ICOFSI


6.1 OpenFOAM
The input for the fluid solver requires specification of velocity field U ,
pressure field p and few other parameters. The specification can be con-
sulted by OpenFOAM guides with example input files given in Appendix
[0/U ,0/p,0/pointDisplacement ...] as support. One important aspect is the
determination of the driven force of the fluid, namely, pressure or velocity
driven. The effects are chosen patch [=boundary condition for OpenFOAM].

6.2 DEAL.II
The input for the structured solver is specified by input file < name >.prgm,
the < name > is specified in Appendix [constant/couplingP arameters],
placed under OpenFOAM syntax case structure, see Appendix [Case]. The

5
keywords in this file is specified by define the sub category and then param-
eter name, see Appendix [T he keywords f or dealiiP arameterHandler].
The subcategory have the syntax subsection < name > with end marker
< end >, the parameter is defined by syntax set < name of parameter >
< value >. As an example,

subsection Dynamical Constants


set The Alpha Damping Coefficient = 0.0
set The Beta Damping Coefficient = 0.0
end

Note: the input is case sensitive. See Appendix [dealii/marker0,dealii/object0.prgm]


for example files.

7 Putting all together


7.1 General
The project is executed in same way as icoDymF oam, a tutorial in Open-
FOAM. The time step and write interval is set by system/controlDict [affect
both packages]. The mesh for structure is placed in deal.ii/constant while
the fluid follow the OpenFOAM standard, in this example by 0 catalogue.
The restart vectors [u restart, v restart]in output deal.ii/ouput match the
latest catalogue for OpenFOAM.

7.2 Flow chart


Break down the procedure into the following steps,

• Install and verify each package using icoDymFOAM and step-8 tuto-
rials.

• Create Case [See Appendix]

• Create Mesh [Section 5]

• Run the Case using icoDymF oam solver to stationary fluid state [2]

• Evaluate the mean frontal pressure on the structure from the input
from previous step

• Run the structure solver DynamicElastic with mean frontal pressure


specified from previous step.

• Run ICOFSI with stationary flow and settings for stable structure.

6
7.3 Setting the damping
Damping is vital to remove the initial energy by holding structure to fixed
position, depending on the Case, the necessity for restart and use new damp-
ing can be optional choice while reducing the computational effort. Regard-
ing the specify the mean pressure for deal.ii, either one set this through
using OpenFOAM or see Appendix [Testing the structure]

7.4 Setting the threshold


An important task for partitioned solvers is the setting of thresholds, there is
a trial and error in choosing parameters and in some cases no such is feasible.
See diploma work for further details [1]. Improper settings often leads to
numerical instability manifested as Floating point exception, divergence,
drifting.

8 Contact
If you experience some problem during installation or have any comments
upon the code, please contact me at johan lorentzon@hotmail.com

7
References
[1] Fluid-Structure Interaction (FSI) case study of a cantilever us-
ing OpenFOAM and DEAL.II with application to VIV, ISRN
LUTMDN/TMHP–09/5186–SE.

[2] http://www.openfoam.com/docs/user.

[3] Which strategy to move the mesh in the. Computational Fluid Dynamic
code. OpenFOAM. Christophe Kassiotis. April 12, 2008. cole Normale
Suprieure de Cachan.

[4] http://www.dealii.org/developer/doxygen/tutorial/index.html .

[5] https://help.ubuntu.com/community/OpenFOAM.

[6] http://www.openfoam.com/download/source.php.

[7] http://geuz.org/gmsh/.

[8] http://www.dealii.org/developer/readme.html#installation.

[9] http://www.openfoamwiki.net/index.php/Howto compile OpenFOAM.

8
Appendix: ICOFSI installation
Make/file
cyclicHashTable.C
icofsi.C
EXE = \$(FOAM_USER_APPBIN)/ICOFSI

Make/option
EXE_INC = \
\$(WM_DECOMP_INC) \
-I\$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I\$(LIB_SRC)/dynamicMesh/lnInclude \
-I\$(LIB_SRC)/meshTools/lnInclude \
-I\$(LIB_SRC)/cfdTools/incompressible \
-I\$(LIB_SRC)/finiteVolume/lnInclude \
-I\$(LIB_SRC)/dynamicMesh/motionSolver \
-I /home/\$(USER)/deal.II/contrib/boost/include \
-I /home/\$(USER)/deal.II/lac/include \
-I /home/\$(USER)/deal.II/base/include \
-I /home/\$(USER)/deal.II/deal.II/include
EXE_LIBS = \
-ldynamicFvMesh \
-ldynamicMesh \
-lmeshTools \
-lfiniteVolume \
-ltriSurface \
/home/\$(USER)/deal.II/lib/libbase.g.so\
/home/\$(USER)/deal.II/lib/libdeal_II_3d.g.so\
/home/\$(USER)/deal.II/lib/liblac.g.so\
/home/\$(USER)/OpenFOAM/ThirdParty-1.6/gcc-4.3.3/platforms/\
"linux64"/lib64/libstdc++.so.6

Important: The last line refer to the libstdc++ library its related to current
compilator and both distribution must use the same.

9
Case
A case contain all input files and output, each placed under specified direc-
tories,

Case
0
U
p
pointDisplacement
cellDisplacement
cellMotionU
...
constant
couplingParameter
transportProperties
dynamicMeshDictionary
...
deal.ii
constant
<name>
output
<name>.prgm
marker
system
controlDict
...

Note: The 0 Case represent the start time of the simulation, could be set
arbitrary according to the input file controlDict.

10
Older distribution than OpenFOAM 1.6
The current distribution 1.7 use a syntax for path description not compati-
ble to older version 1.5 and earlier. The locations to change the path settings
can be found,

dealiiGrid.H:

void Grid<dim>::set_path(char* arglist[], const char name[])


{
filename.append(arglist[2]);
filename.append("/deal.ii/constant/");
filename.append(name);
}

Dynamicelastic.H:

void TopLevel<dim>::set_grid_path( char* arglist[], const char name[])


{
filename.append(arglist[2]);
path=filename;
path.append("/");
printf("%s\n",path.c_str());
filename.append(name);
}

In both snippets it is the arglist that cause eventual problem running the
code.

11
constant/couplingParameter
This input file defines the number of structural elements in the calculation
[nObject], density of fluid [Density], time for start of FSI [time], label of
the boundaries[f luidSide,solidSide]. The vector after label is the SI unit
specification. The f luidSide and solidSide defines the tag used for label
the boundary for OpenFOAM respectively naming the input/output files
for DEAL.II. To separate multiples of surfaces/structures The OpenFOAM
mesh tags is differentiated by a suffix from 2 to nObjects + 1 [ 1 refers to the
fixed surface domain under one patch], while for DEAL.II the input/output
files for structures are by suffix enumerated from 0 till nObjects − 1. An
example,

FoamFile
{
version 2.0;
format ascii;

root "";
case "";
instance "";
local "";

class dictionary;
object couplingParameters;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nObject nObject [0 0 0 0 0 0 0] 1.0;
fluidSide SURFACE;
solidSide object;
Density Density [1 -3 0 0 0 0 0] 1000.0;
startMeshMotion time [0 0 1 0 0 0 0] 7.065;
// ************************************************************************* //

SURFACE1 refers to the fixed wall, SURFACE2 is the flexible structured


part specified in the tags for the respective surface if fluid mesh to Open-
FOAM. The object0.prgm is the input file to DEAL.II solver and marker0
the probes.

12
0/U
The patch [boundary condition] is f ixedV alue for fixed wall and movingW allV elocity
for the structural element that are allowed to interact. This is a velocity
driven fluid but the dirichlet set inlet of U.
FoamFile
{
version 2.0;
format ascii;

root "";
case "";
instance "";
local "";

class volVectorField;
object U;
}

dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);

boundaryField
{
INLET
{
type fixedValue;
value uniform (1.0 0 0);
}
SURFACE1
{
type fixedValue;
value uniform (0 0 0);
}
SURFACE2
{
type movingWallVelocity;
value uniform (0 0 0);
}
OUTLET
{
type zeroGradient;
}
}

13
0/p
The patch [boundary condition] is f ixedV alue for fixed wall and movingW allV elocity
for the structural element that are allowed to interact. Note the pressure set
to 0 at outlet and 0 gradient for the purpose of consistency with specification
of a velocity driven fluid.
FoamFile
{
version 2.0;
format ascii;

root "";
case "";
instance "";
local "";

class volScalarField;
object p;
}

dimensions [0 2 -2 0 0 0 0];

internalField uniform 0;

boundaryField
{
SURFACE1
{
type zeroGradient;
}
SURFACE2
{
type zeroGradient;
}
OUTLET
{
type fixedValue;
value uniform 0;
}
INLET
{
type zeroGradient;
}
}

14
constant/dynamicMeshDict
This section specify what kind of solver to be used to solve the laplacian
that defines the deformation in the ALE step. For further details, see [3].
Related input files are cellDisplacement, pointdisplacement,cellmotionU,

FoamFile
{
version 2.0;
format ascii;

root "";
case "";
instance "";
local "";

class dictionary;
object motionProperties;
}

twoDMotion no;
dynamicFvMesh dynamicMotionSolverFvMesh;
motionSolverLibs ("libfvMotionSolvers.so");
solver displacementLaplacian;
diffusivity quadratic inverseDistance 1(SURFACE2);
(
);

15
0/cellMotionU
FoamFile
{
version 2.0;
format ascii;

root "";
case "";
instance "";
local "";

class volVectorField;
object motionU;
}

dimensions [0 1 -1 0 0 0 0];

internalField uniform (0 0 0);

boundaryField
{
INLET
{
type fixedValue;
value uniform (0 0 0);
}
SURFACE1
{
type fixedValue;
value uniform (0 0 0);
}
SURFACE2
{
type fixedValue;
value uniform (0 0 0);
}
OUTLET
{
type zeroGradient;
}
}

16
0/cellDisplacement
FoamFile
{
version 2.0;
format ascii;

root "";
case "";
instance "";
local "";

class volVectorField;
object cellDisplacement;
}

dimensions [0 1 0 0 0 0 0];

internalField uniform (0 0 0);

boundaryField
{
SURFACE2
{
type fixedValue;
value uniform (0 0 0);
}
SURFACE1
{
type fixedValue;
value uniform (0 0 0);
}
INLET
{
type fixedValue;
value uniform (0 0 0);
}
OUTLET
{
type fixedValue;
value uniform (0 0 0);
}
}

17
0/pointDisplacement
Note: calculated from cellDisplacement, hence flexible structure should have
calculated patch.
FoamFile
{
version 2.0;
format ascii;

root "";
case "";
instance "";
local "";

class pointVectorField;
object pointDisplacement;
}

dimensions [0 1 0 0 0 0 0];

internalField uniform (0 0 0);

boundaryField
{
SURFACE2
{
type calculated;
}
SURFACE1
{
type fixedValue;
value uniform (0 0 0);
}
INLET
{
type fixedValue;
value uniform (0 0 0);
}
OUTLET
{
type fixedValue;
value uniform (0 0 0);
}
}

18
constant/transportProperties
This file defines the kinematic viscosity.

FoamFile
{
version 2.0;
format ascii;

root "";
case "";
instance "";
local "";

class dictionary;
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu nu [0 2 -1 0 0 0 0] 5e-4;
// ************************************************************************* //

19
deal.ii/object0.prgm
subsection FEM
set The Write Interval = 250
set The Order of FE_QGauss = 1
set The Order of Gauss Quadrature = 2
set The Number of Refinements = 1
set The Number of Cycles = 1
end

subsection The Theta Method


set The Theta Coefficient = 0.5
end

subsection BodyForce Constants


set The Gravity = 0
end

subsection Dynamical Constants


set The Alpha Damping Coefficient = 0.0
set The Beta Damping Coefficient = 0.0
end

subsection Material Constants


set The Lame Parameter Lambda = 11538000.46
set The Lame Parameter Mu = 7692000.31
set The Density = 1000.
end

subsection Aitken Relaxation Constants


set The Omega Coefficient = 1.0
set The Tolerance Factor = 1e-6
end

deal.ii/marker
The first line presents starting time of evaluate the probes, the number of
probes. Second line contains the probes coordinates in (x,y,z).

7.06301 3
1.1 0.6 1.95 1.01 0.6 1.0 1.18 0.6 1.0

Note: The point must be inside the structure element not onto surface due
to the search function assumes strictly inside [<].

20
The keywords for dealiiP arameterHandler
The following list the parameters where the first name is the subcategory
they placed under. The definitions of reading parameters are in dealiiP arameterHandler.

• T he T heta M ethod, T he T heta Coef f icient, the blending coefficient


for the theta method. Default value is set to Crank-Nicholson (0.5).

• F EM , T he W rite Interval, the output is written on disk by interval


per iteration. Default is every iteration (0). [inactivated in ICOFSI]

• F EM , T he Order of F E QGauss, the order of basis for FEM. Default


is linear (1).

• F EM , T he Order of Gauss Quadrature, the order of Quadrature.


Default is under integration (1).

• F EM , T he N umber of Ref inements, the number of refinements.


Default is none (0).

• F EM , T he N umber of Cycles, the number of adaptive refinements.


Default is none (0).

• M aterial Constants, T he Lame P arameter Lambda, the lame λ pa-


rameter, Default is 0.

• M aterial Constants, T he Lame P arameter M u, the lame µ param-


eter, Default is 0.

• M aterial Constants, T he Density, the density of structure, default


is 1.

• BodyF orce Constans, T he Gravity, the gravity, default is 0.

• Dynamical Constants, T he Alpha Damping Coef f icient, the α in


Rayleight damping. Default 0.

• Dynamical Constants, T he Beta Damping Coef f icient, the β in


Rayleight damping. Default 0.

• Aitkens Relaxation Constants, T he Omega Coef f icient, the ω in


Aitkens formula. Default 1.

• Aitkens Relaxation Constants, T he T olerance Coef f icient, the ω


in Aitkens formula. Default 0.

• OpenF oam T o DEAL.II T olerance M esh Distance, the threshold


distance from surface of structure.

21
Gmesh
Here follows a short quote from a forum in how to generate hexahedral mesh
for DEAL.II using gmesh utility.

The only algorithms currently available in gmsh that produce hexahedral


elements are the transfinite and the extrusion algorithms. See demos/hex.geo
for a simple example.

The input to Gmesh is command like specification with a robust GUI.

DEAL.II meshing routine


Alternative procedure is deal.ii own routines, see the dealiiGrid.H to gen-
erate the cantilever mesh used in [1],

void Grid<dim>::create_grid ()
{
std::vector<double> step_x(4,0.05),step_y(4,.05),step_z(16,0.125);
std::vector<std::vector<double> > step_size(3);
step_size.at(0)=step_x; step_size.at(1)=step_y; step_size.at(2)=step_z;
const Point<3> p1(1.4,0.50,.0),p2(1.6,0.7,2.0);
const bool flag=false;
GridGenerator::subdivided_hyper_rectangle(triangulation,step_size,p1,p2,flag);
boundary();
if (filename.size()) save();
}

Remark: Be aware that round off error affect the routine directly and er-
ror will be produced. No round off than floating point related in the step
declaration.

22
Testing the structure
The Main code is,
#include "InterGridMapping.H"
namespace shared
{
InterGridMapping<3>* icofsi_db_list[10] ;
InterGridMapping<3> icofsi_db;
}
// DYNAMIC
#include "DynamicElastic.H"
#include "dealiiGrid.H"
#include "setBoundaryIndicator.H"
#include "dealiiParameterHandler.H"
int main(int argc,char* argv[]) {
shared::icofsi_db_list[0] = new InterGridMapping<3>();
dealiiParameterHandler::Base prm(argv,"object0.prm");
prm.print();
int i=0;
SmartPointer<Triangulation<3> > tria;
dealiiGrid::Grid<3> newGrid;
newGrid.set_path(argv,"object");
newGrid.create_grid();
tria=newGrid.get_triangulation();
DynamicElastic::TopLevel<3> test(prm,tria,i);
test.set_grid_path(argv,"object");
double time_is_everything=0;
while(time_is_everything<1) {
test.set_current_time(time_is_everything);
time_is_everything+=0.001;
test.run();
test.next_step();
}
}
To apply the pressure, modify DynamicElastic.H at the following point,
for ( unsigned int q_point=0;q_point<n_face_q_points;++q_point) {
// DO: calculate pressure function
cell_rhs(i)+=shared::icofsi_db_list[n_object]->get_traction(component_i,cell->face_i
invrho*fe_face_values.shape_value(i,q_point)*fe_face_values.JxW(q_point
}
Replace the shared :: icof si db list[n object]− > get traction(component i, cell− >
f ace index(f ace)) to a specific value or use exact pressure from an Open-
Foam calculation.

23