couple waves2foam with self-propulsion

41
Cite as: Mahish, M.: Couple waves2Foam with Self-Propulsion. In Proceedings of CFD with OpenSource Software, 2016, Edited by Nilsson. H., http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2016 CFD with OpenSource software A course at Chalmers University of Technology Taught by H˚ akan Nilsson Couple waves2Foam with Self-Propulsion Developed for OpenFOAM-3.0.x Author: Mahish Mohan Chalmers University of Technology [email protected] Peer reviewed by: Turo Valikangas akan Nilsson Licensed under CC-BY-NC-SA, https://creativecommons.org/licenses/ Disclaimer: This is a student project work, done as part of a course where OpenFOAM and some other OpenSource software are introduced to the students. Any reader should be aware that it might not be free of errors. Still, it might be useful for someone who would like learn some details similar to the ones presented in the report and in the accompanying files. The material has gone through a review process. The role of the reviewer is to go through the tutorial and make sure that it works, that it is possible to follow, and to some extent correct the writing. The reviewer has no responsibility for the contents. February 14, 2017

Upload: others

Post on 07-Jun-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Couple waves2Foam with Self-Propulsion

Cite as: Mahish, M.: Couple waves2Foam with Self-Propulsion. In Proceedings of CFD with OpenSource

Software, 2016, Edited by Nilsson. H., http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2016

CFD with OpenSource software

A course at Chalmers University of TechnologyTaught by Hakan Nilsson

Couple waves2Foam with Self-Propulsion

Developed for OpenFOAM-3.0.x

Author:Mahish MohanChalmers University [email protected]

Peer reviewed by:Turo Valikangas

Hakan Nilsson

Licensed under CC-BY-NC-SA, https://creativecommons.org/licenses/

Disclaimer: This is a student project work, done as part of a course where OpenFOAM and someother OpenSource software are introduced to the students. Any reader should be aware that it

might not be free of errors. Still, it might be useful for someone who would like learn some detailssimilar to the ones presented in the report and in the accompanying files. The material has gone

through a review process. The role of the reviewer is to go through the tutorial and make sure thatit works, that it is possible to follow, and to some extent correct the writing. The reviewer has no

responsibility for the contents.

February 14, 2017

Page 2: Couple waves2Foam with Self-Propulsion

Contents

1 Introduction 2

2 Theoretical Background 32.1 InterDyMFoam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Waves2Foam Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2.2.1 Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.2.2 Overview of the library files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3 Case Setup 163.1 Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.2 Mesh Generation using SnappyHexMeshDict . . . . . . . . . . . . . . . . . . . . . . 183.3 Boundary and Initial Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.4 Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

4 Propeller as BodyForce 27

5 Solver Modification 325.1 Implementation of bodyForce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335.2 Coupling of waves2Foam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

6 Conclusion and Future Work 366.1 Results and Discussions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366.2 Conclusion and Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

7 Study Questions 39

1

Page 3: Couple waves2Foam with Self-Propulsion

Learning outcomes

The reader will learn:

How to use it:

• how to use a waves2Foam library.

• how to use a snappyHexMesh utility to mesh the geometry.

• how to use a sixDOFRigidBodyMotion solver to implement trim motion to hull.

The theory of it:

• about interDyMFoam solver and various numerical equations used in the implementation.

• about waves2Foam toolbox and methodology.

• about waves2Foam file structure.

How it is implemented:

• how to create a case setup to implement self-propulsion simulation.

• how to implement waves2Foam toolbox with interDyMFoam solver.

How to modify it:

• how to modify the existing interDyMFoam solver to incorporate the propeller effect.

• how to couple waves2Foam with interDyMFoam.

1

Page 4: Couple waves2Foam with Self-Propulsion

Chapter 1

Introduction

Nowadays, a growing research and focus is on simulating ship motions and to determine the resis-tance in sea conditions rather than in calm waters. The increase of resistance caused due to seawaves is gaining importance in ship design. A more detailed study is also being carried out in un-derstanding the response of ships in waves.

The purpose of this tutorial is to discuss how to set up a case for self-propulsion in waves in Open-Foam using InterDyMFoam, Volume of Fluid (VOF) based solver. The propeller effect is introducedthrough body force modelling. It is very common and fast way to implement the propeller. Themomentum developed by the propeller thrust is introduced as a local source term in the momentumequation.

Further, waves2Foam toolkit is introduced in this tutorial.It generates and absorbs the waves usinga relaxation method. A detailed discussion of the library files and the implementation of the sameis made. A suitable modification of the solver is made to incorporate the relaxation into the solver.

The case setup is done in OpenFOAM-3.0.x.

2

Page 5: Couple waves2Foam with Self-Propulsion

Chapter 2

Theoretical Background

One of the main purpose of the project is simulating waves. However since a default solver whichcompletely serve this purpose is not available in OpenFoam, waves2Foam toolkit is coupled withinterDyMFoam solver to generate waves.This section mainly discusses the theoretical background of waves2Foam library. The methodologyused in the implementation is discussed. A detailed discussion is also made on the structure of thelibrary file. The section also includes a short introduction to the interDyMFoam solver and thedifferent numerical equations used in the implementation. However the reader is expected to havean understanding of Volume of Fluid (VOF) Method.

2.1 InterDyMFoam

The study of ship motions has always been a great challenge as it requires multiphase simulations.Nowadays, Volume of Fluid(VOF) method is widely used to study ship hydrodynamics because of itsflexibility and simplicity. In the present study, interDyMFoam solver which is based on VOF methodis used to simulate the physics of the problem. In this solver, the inter-phase between two phasesis tracked using phase fraction(α) function. The interDyMFoam solver also incorporates dynamicmeshes. The topology of the mesh is updated over each timestep. The governing equations used arethe continuity equation and the Navier Stokes equation.[1]

∇.U = 0 (2.1)

∂(ρU)

∂t+ ρ∇U.U = −∇p+∇.(ν∇U) (2.2)

Further the local density and the viscosity is dependent on the phase fraction

ρ = αρwater + (1− α)ρair (2.3)

µ = αµwater + (1− α)µair (2.4)

As mentioned above, VOF method tracks the phase interface.The advection equation for the α isgiven as

∂α

∂t+∇.Uα = 0 (2.5)

However the above standard equation produces smearing at the interface.This is reduced by intro-ducing interface compression term.

∂α

∂t+∇.Uα+∇.Urα(1− α) = 0 (2.6)

The term is active only when 0< α < 1.

3

Page 6: Couple waves2Foam with Self-Propulsion

2.2. WAVES2FOAM LIBRARY CHAPTER 2. THEORETICAL BACKGROUND

2.2 Waves2Foam Library

2.2.1 Theory

The interDyMFoam solver is further extended by using waves2foam toolkit developed by Jacobsenet al[2]. The toolkit can be downloaded from http://svn.code.sf.net/p/openfoam-extend/svn/

trunk/Breeder_1.6/other/waves2Foam. Save the file in $WM_PROJECT_USER_DIR/applications

/utilities folder.The toolkit defines zones at the inlet and outlet of the domain called as relaxation zones. Thesezones generate and absorb surface waves effectively. The waves are generated at the inlet and ab-sorbtion of the waves takes place at both the inlet and outlet boundaries.[2]. The absorbtion of thewave means that the boundary conditions are not affected by changes in domain.In relaxation zones, velocity and alpha fields are updated during each time step based on chosenweighted function. One such weighted function defined in the solver is given below

χ(ξ) = 1− exp(ξβ − 1)

exp(1)− 1(2.7)

φ = χφcomputed + (1− χ)φtarget (2.8)

φtarget represents the target value of alpha or velocity which is defined using the applied wavetheory and is defined on the boundary and inside the relaxation zone. Considering φtarget as α ,thevalue is either 0 or 1 if the cell is completely wet or dry. For the computational cells intersected bythe wave function η, the value is computed by the toolbox and computation method is defined inconvexPolyhedral class which is referred in next subsection. φcomputed are the numerically computedvalues based on Navier Stokes and VOF equation .ξ represents local co-ordinate system for therelaxation zone.A weight χ is assigned such that the target value gains more weightage near theboundary away from the interface.Thus the boundary condition at the wall is not affected by thecomputational domain.The weight is given by an exponential expression by default and same hasbeen used in the present case.The representation of the relaxation zone is shown in Fig.2.1[1]

Figure 2.1: Relaxation Zone

2.2.2 Overview of the library files

The library waves2Foam contains few major classes listed below

1. relaxationZone

2. relaxationScheme

3. relaxationShape

4. relaxationWeight

4

Page 7: Couple waves2Foam with Self-Propulsion

2.2. WAVES2FOAM LIBRARY CHAPTER 2. THEORETICAL BACKGROUND

5. waveTheory

6. convexPolyhedral

Only the excerpts from these classes which are important for understanding of the class is shownfurther.However, one can look further in detail from $WM_PROJECT_USER_DIR/applications

/utilities/waves2Foam/src/waves2Foam. The library is referred via a dictionary file named wave-Properties in the tutorial as shown below. The excerpts from this dictionary file is further used inthe description of classes.

/*--------------------------------*- C++ -*----------------------------------*\

| ========= | |

| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |

| \\ / O peration | Version: 3.0.x |

| \\ / A nd | Web: www.OpenFOAM.org |

| \\/ M anipulation | |

\*---------------------------------------------------------------------------*/

FoamFile

{

version 2.0;

format ascii;

class dictionary;

object waveProperties;

}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

seaLevel 0.25;

seaLevelAsReference false;

relaxationNames ( inlet outlet );

initializationName inlet;

inletCoeffs

{

waveType stokesFirst;

depth 4;

period 2;

direction (-1 0 0 );

phi 0;

height 0.25;

waveNumber (-1 0 0);

omega 3.14;

relaxationZone

{

relaxationScheme Spatial;

relaxationShape Rectangular;

beachType Empty;

relaxType INLET;

startX ( 20 0 -2 );

endX ( 15 5 2 );

orientation ( -1 0 0 );

}

5

Page 8: Couple waves2Foam with Self-Propulsion

2.2. WAVES2FOAM LIBRARY CHAPTER 2. THEORETICAL BACKGROUND

}

outletCoeffs

{

waveType potentialCurrent;

U (0 0 0 );

Tsoft 2;

relaxationZone

{

relaxationScheme Spatial;

relaxationShape Rectangular;

beachType Empty;

relaxType OUTLET;

startX ( -12 0 -2 );

endX ( -14 5 2 );

orientation ( -1 0 0 );

}

}

The different classes are further described below.

1. waveTheoryDifferent wave theories are included in the library files. The commonly used is the stokes wavetheory for studying wave behaviour and same has been used in this tutorial. The user cantake a look at various available theories from$WM_PROJECT_USER_DIR/applications/utilities/waves2Foam/src/waves2Foam

/waveTheories.

The excerpt from base class waveTheory.H is shown below. An autopointer of waveTheoryclass is created. The choice of wave theory is referred in the dictionary file which is passedas an argument as seen below. Base class shows different virtual class for defining the wavefunction η, pressure gradient and velocity.

static autoPtr<waveTheory> New

(

const word& subDictName,

const fvMesh& mesh_

);

virtual void printCoeffs() = 0;

// Destructor

virtual ~waveTheory();

// Member Functions

//-

virtual Switch conflictTSoftInitialise() const = 0;

const vector windVelocity( const scalar& time ) const

{

return factor( time )*wind_;

};

6

Page 9: Couple waves2Foam with Self-Propulsion

2.2. WAVES2FOAM LIBRARY CHAPTER 2. THEORETICAL BACKGROUND

// Access - single value

virtual scalar eta

(

const point&,

const scalar&

) const = 0;

virtual scalar ddxPd

(

const point&,

const scalar&,

const vector&

) const = 0;

virtual vector U

(

const point&,

const scalar&

) const = 0;

virtual scalar p

(

const point&,

const scalar&

) const { return 0.0; };

// Access - field

virtual scalarField eta

(

const pointField&,

const scalar&

) const;

virtual scalarField ddxPd

(

const pointField&,

const scalar&,

const vectorField&

) const;

virtual vectorField U

(

const pointField&,

const scalar&

) const;

// Return the unit vertical direction in the direction of g

const inline vector& returnDir() const { return direction_;}

};

2. convexPolyhedralThis class allows for computation of the intersections between geometric objects (polyhe-dral, polygon) and a given surface. The surface is the water surface which is given by

7

Page 10: Couple waves2Foam with Self-Propulsion

2.2. WAVES2FOAM LIBRARY CHAPTER 2. THEORETICAL BACKGROUND

an equation from wave theory for example:η = a(cosωt − kx), where η is the water sur-face elevation, a is the wave amplitude, ω is the cyclic frequency, t is time, k is the hor-izontal wave number vector, and x is a spatial coordinate.This class is used to divide thecell inside the relaxation zone based on the level of water given by the wave equation ηand then different fields like alpha and velocity in the cell is defined. This class is alsoaccessed by fvPatchField class to cut the boundary patch based on η function and defineboundary conditions.The reader can have a detailed understanding of the convexPolyhedralclass from $WM_PROJECT_USER_DIR/applications/utilities/waves2Foam/src/waves2Foam

/convexPolyhedral

3. relaxationZoneDifferent relaxation techniques are used to avoid unnecessary wave interferences like thosecaused due to reflections of waves from outlet boundaries and also avoid waves interfering theinlet boundaries.This is achieved by using relaxation weight which is explained further.A relax-ation zone involves defining relaxation shape and relaxation weight.The relaxationZone class islocated at $WM_PROJECT_USER_DIR/applications/utilities/waves2Foam/src/waves2Foam/relaxationZone.The constructor of relaxationZone class is shown below:

relaxationZone::relaxationZone

(

const fvMesh& mesh,

volVectorField& U,

volScalarField& alpha

)

:

mesh_(mesh),

U_(U),

alpha_(alpha),

relaxationWeightsMomentum_(NULL),

relaxationWeightsSource_(NULL),

targetAlpha_(NULL),

targetVelocity_(NULL),

relaxNames_((mesh_.thisDb().lookupObject<IOdictionary>("waveProperties"))

.lookup("relaxationNames")),

relaxSchemePtr_(relaxNames_.size())

{

forAll (relaxNames_, relaxi)

{

relaxSchemePtr_[relaxi] = relaxationSchemes::relaxationScheme::

New(relaxNames_[relaxi], mesh_, U_, alpha_);

}

}

A pointer for a class relaxationScheme is created named relaxSchemePtr_ and the class isaccessed for each relaxation zone Inlet and Outlet mentioned in waveProperties dictionaryA member function correct() of class relaxationZone is shown below. An object of relax-ationZone is created inside the interDyMFoam solver and the object of the class is used to

8

Page 11: Couple waves2Foam with Self-Propulsion

2.2. WAVES2FOAM LIBRARY CHAPTER 2. THEORETICAL BACKGROUND

access the member function correct().The detailed modification of interDyMFoam solver isdiscussed in Solver Modification section.

void relaxationZone::correct()

{

scalar preTime = mesh_.time().elapsedCpuTime();

resetTargetFields();

forAll (relaxSchemePtr_, relaxi)

{

relaxSchemePtr_[relaxi]->correct();

}

correctBoundaries();

Info << "Relaxing time: " << mesh_.time().elapsedCpuTime() - preTime

<< " s" << endl;

}

As seen above, the correct() of relaxationZone points to the correct() of relaxationSchemeclass using the pointer as relaxSchemePtr_[relaxi]->correct(). This function updatesthe alpha and U values at the boundaries and also the relaxation weight and cells inside therelaxation shape.This is further described during discussion of relaxationScheme class.

4. relaxationSchemeThe relaxationScheme has a base class called relaxationScheme and derived classes which is ac-cessed using auto-pointer and is shown below.It also has a member function correct() as men-tioned above in relaxationZone class.All the classes of relaxationScheme can be accessed from$WM_PROJECT_USER_DIR/ applications/utilities/waves2Foam/src/waves2Foam/relaxationZone/relaxationScheme.

static autoPtr<relaxationScheme> New

(

const word& subDictName,

const fvMesh& mesh,

vectorField& U,

scalarField& alpha

);

virtual void correct() = 0;

The relaxation scheme also defines all the pointers for relaxationShape,relaxationWeight andwaveTheory.

{

relaxShape_ = relaxationShapes::relaxationShape::New(subDictName, mesh_);

relaxWeight_ = relaxationWeights::relaxationWeight::New(subDictName, mesh_);

waveProps_ = waveTheories::waveTheory::New(subDictName, mesh_);

numBeach_ = numericalBeaches::numericalBeach::New(subDictName, mesh_ );

}

Further the correct() of the derived class spatial is shown below.The function basicallyupdates the value of alpha and U in case of dynamic meshes. The function begins by accessingthe cells() and local co-ordinate function sigma() using relaxShape_ pointer.It is a pointerfor relaxationShape which is described further. If there is any change in cells, the weights

9

Page 12: Couple waves2Foam with Self-Propulsion

2.2. WAVES2FOAM LIBRARY CHAPTER 2. THEORETICAL BACKGROUND

are updated by calling function as relaxWeight_->weights(cells, sigma, weight_). Thecells are then again cut based on the selected waveTheory and scalar alpha and vector U areupdated.

void relaxationSchemeSpatial::correct()

{

// Obtain relaxation zone cells and local sigma coordinate

// The number of cells and the sigma coordinate can have changed

// for dynamic meshes

const labelList& cells = relaxShape_->cells();

const scalarField& sigma = relaxShape_->sigma();

// Compute the relaxation weights - only changes for moving/changing meshes

if (weight_.size() != sigma.size())

{

weight_.clear();

weight_.setSize(sigma.size(), 0.0);

}

relaxWeight_->weights(cells, sigma, weight_);

// Perform the correction

const scalarField& V(mesh_.V());

const vectorField& C(mesh_.C());

const cellList& cc(mesh_.cells());

const pointField& pp(mesh_.points());

const faceList& fL(mesh_.faces());

forAll (cells, celli)

{

const label cellNo = cells[celli];

const pointField& p = cc[cellNo].points(fL, pp);

// Evaluate the cell height and the signedDistance to the surface from

// the cell centre

scalar cellHeight

(

Foam::max(p & waveProps_->returnDir())

- Foam::min(p & waveProps_->returnDir())

);

scalar sdc(signedPointToSurfaceDistance(C[cellNo]));

// Target variables

scalar alphaTarget(0.0);

vector UTarget(waveProps_->windVelocity(mesh_.time().value()));

// Only do cutting, if surface is close by

if (Foam::mag(sdc) <= 2*cellHeight)

{

localCellNeg lc(mesh_, cellNo);

dividePolyhedral(point::zero, vector::one, lc);

if (lc.ccNeg().size() >= 4)

10

Page 13: Couple waves2Foam with Self-Propulsion

2.2. WAVES2FOAM LIBRARY CHAPTER 2. THEORETICAL BACKGROUND

{

UTarget = waveProps_->U(lc.centreNeg(), mesh_.time().value());

alphaTarget = lc.magNeg()/V[cellNo];

}

}

else if (sdc < 0)

{

alphaTarget = 1.0;

UTarget = waveProps_->U( C[cellNo], mesh_.time().value() );

}

else

{

alphaTarget = 0.0;

UTarget = waveProps_->windVelocity( mesh_.time().value() );

}

U_[cellNo] = (1 - weight_[celli])*UTarget + weight_[celli]*U_[cellNo];

alpha_[cellNo] = (1 - weight_[celli])*alphaTarget

+ weight_[celli]*alpha_[cellNo];

}

5. relaxationShapeThis class is used to define the shape of relaxation zone.The purpose of this class is to com-pute the cells inside the zone and sigma co-ordinate which is the local coordinate required fordefining the relaxation weights.The reader can refer to the class from $WM_PROJECT_USER_DIR/

applications/utilities/waves2Foam/src/waves2Foam/relaxationZone/relaxationShape

The parameters required for defining the relaxation shape is defined in the waveProperties

IO Dictionary.An excerpt from the same is defined below.

relaxationZone

{

relaxationScheme Spatial;

relaxationShape Rectangular;

beachType Empty;

relaxType INLET;

startX (-1.5 -1 0);

endX (-1.2 1 0);

orientation (1 0 0);

}

startX ,endX and orientation are used to define limits and the primary orientation of the rectan-gular shape. Different relaxation shapes can be chosen like cylindrical,semicylindrical,rectangularetc.In base class relaxationShape.H, first the derived classes is referred through pointer as shownbelow. The derived class is chosen based on the relaxation shape type mentioned in dictionarywhich is passed as an argument.

static autoPtr<relaxationShape> New

(

const word& subDictName,

11

Page 14: Couple waves2Foam with Self-Propulsion

2.2. WAVES2FOAM LIBRARY CHAPTER 2. THEORETICAL BACKGROUND

const fvMesh& mesh_

);

There are two member functions refreshCells() and refreshSigma() in relaxationShapeclass. These member functions update computational cells and local coordinate sigma if anytopological changes in mesh is observed.Excerpts from the relaxationShape.C is presentedbelow indicating the functions.

void relaxationShape::refreshCells()

{

if (refreshIndexCells_ != mesh_.time().timeIndex() && mesh_.changing())

{

findComputationalCells();

}

refreshIndexCells_ = mesh_.time().timeIndex();

}

void relaxationShape::refreshSigma()

{

refreshCells();

if (refreshIndexSigma_ != mesh_.time().timeIndex())

{

computeSigmaCoordinate();

}

refreshIndexSigma_ = mesh_.time().timeIndex();

}

findComputationalCells() and computeSigmaCoordinate() functions called in the aboveexcerpt are defined in the derived relaxationShape classes. findComputationalCells() calcu-lates the cells inside the relaxation zone. computeSigmaCoordinate() calculates the locationof cells based on local co-ordinate system. An excerpt from relaxationShapeRectangular.C

is shown below showing the two functions.

void relaxationShapeRectangular::findComputationalCells()

{

const vectorField& cc = mesh_.C();

cells_.setSize(5000);

label count(0);

forAll (cc, celli)

{

if (insideZone( celli ))

{

cells_[count++] = celli;

if (count == cells_.size())

{

cells_.setSize( static_cast<label>( count*1.1 ) );

}

}

12

Page 15: Couple waves2Foam with Self-Propulsion

2.2. WAVES2FOAM LIBRARY CHAPTER 2. THEORETICAL BACKGROUND

}

cells_.setSize(count);

}

void relaxationShapeRectangular::computeSigmaCoordinate()

{

const vectorField& C = mesh_.C();

sigma_.setSize(cells_.size(), 0);

forAll (cells_, celli)

{

vector cc( C[cells_[celli]] );

cc -= ( ( cc & direction_ )*direction_ );

sigma_[celli] = Foam::mag(((xAxis_ & cc) - (xAxis_ & cornerNodes_[0])))

/( Foam::mag(xAxis_)*width_ );

if (relaxType_ == "INLET")

{

sigma_[celli] = Foam::mag( sigma_[celli] - 1.0 );

}

}

}

6. relaxationWeightThe type of relaxation weight to be used is specified in the waveProperties IO Dictionary.Differenttype of relaxation weights are available .The base class and different derived classes are avail-able at $WM_PROJECT_USER_DIR/applications/utilities /waves2Foam/src/waves2Foam/

relaxationZone/relaxationWeight.First a pointer is defined in the base class relaxationWeight.Hfor selection of relaxation weight type.

autoPtr<relaxationWeight> relaxationWeight::New

(

const word& subDictName,

const fvMesh& mesh_

)

If a relaxation weight type is not specified, by default exponential type is used.The excerptshown below is from relaxationWeight.C file.

{

const dictionary coeffDict_

(

(mesh_.thisDb().lookupObject<IOdictionary>("waveProperties"))

.subDict(subDictName + "Coeffs")

.subDict("relaxationZone")

);

relaxationWeightTypeName = coeffDict_.lookupOrDefault<word>

(

"relaxationWeight",

"Exponential"

);

}

13

Page 16: Couple waves2Foam with Self-Propulsion

2.2. WAVES2FOAM LIBRARY CHAPTER 2. THEORETICAL BACKGROUND

In this project, exponential type is used. The below excerpt shows the expression for expo-nential type defined in relaxationWeightExponential.C file.

forAll (weight_, celli)

{

weight_[celli] = 1.0 -

(Foam::exp(Foam::pow(sigma[celli],exponent_)) - 1.0)

/(Foam::exp(1.0) - 1.0);

}

The value of an exponent can be provided in the dictionary file or by default it takes 3.5. Thevalue of exponent is defined in class relaxationWeightExponential.C file as shown below.

relaxationWeightExponential::relaxationWeightExponential

(

const word& subDictName,

const fvMesh& mesh_

)

:

relaxationWeight(subDictName, mesh_),

exponent_( coeffDict_.lookupOrDefault<scalar>("exponent",3.5) )

{

}

7. fvPatchField This sets the wave boundary condition for VOF solvers.The alpha value is setbased on the intersection of wave surface on the boundary face.The reader can further look intodetails by referring to $WM_PROJECT_USER_DIR/applications/utilities/waves2Foam/src

/waves2Foam/fvPatchFields. The three boundary patchfields are the waveAlpha,waveVelocityand wavePressure defined in this class. This field values are further used to set wavy inlet con-dition for the computational domain.

8. setWaveField This class is used to set a given wavefield as initial condition in in the com-putational domain. It takes input from waveProperties dictionary file kept in the constant

folder of the tutorial. A pre-processing utility called setWaveField is used to access this class.It should be noted that the class and the utility has the same name setWaveField. This utilityis located in $WM_PROJECT_USER_DIR/applications/utilities/waves2Foam/applications

/utilities/preProcessing. An excerpt from the utility is shown below

Info << "Setting the wave field ...\n" << endl;

setWaveField swf(mesh, U, alpha, pd);

swf.correct();

alpha.write();

U.write();

pd.write();

externalWave->close();

Info << nl << "End" << nl << endl;

14

Page 17: Couple waves2Foam with Self-Propulsion

2.2. WAVES2FOAM LIBRARY CHAPTER 2. THEORETICAL BACKGROUND

return 0;

An object swf of class setWaveField is created and correct() function of the setWaveFieldclass is accessed.The below excerpt is from setWaveField class function located in $WM_PROJECT_USER_DIR/applications/utilities/waves2Foam/src

/waves2Foam/setWaveField

void setWaveField::correct()

{

const scalarField& V( mesh_.V() );

forAll (U_, celli)

{

localCell lc = dividePolyhedral( celli, point::zero, point::one);

vector UTarget(waveProps_->windVelocity(U_.db().time().value()));

scalar pTarget(0.0);

scalar alphaTarget(0.0);

// If size is less than 4, then one cannot evaluate centre/magnitude

// without getting an floating point exception error

if (lc.ccNeg().size() >= 4)

{

UTarget = waveProps_->U(lc.centreNeg(), U_.db().time().value());

pTarget = waveProps_->p(lc.centreNeg(), U_.db().time().value());

alphaTarget = lc.magNeg()/V[celli];

}

U_[celli] = UTarget;

alpha_[celli] = alphaTarget;

p_[celli] = pTarget;

}

}

correct() sets the wave parameters in the entire domain. The parameters UTarget, pTarget,alphaTarget is initialized with zero values. WindVelocity in the current case is set to zero.Further based on the cell below the wave surface η obtained from wave equation, the values ofthe parameters are set.

15

Page 18: Couple waves2Foam with Self-Propulsion

Chapter 3

Case Setup

The case setup is done based on the tutorial of Wigley Hull, LTSInterFoam.The tutorial is availablein OpenFoam-2.2.x. The tutorial is referred from github at https://github.com/OpenFOAM/OpenFOAM-2.2.x/tree/dbd1e1f445bb46e92f1fb401580567a5a9e81b75/tutorials/multiphase

/LTSInterFoam. The tutorial is used as a reference to prepare case for DTC hull on InterDyMFoam.The DTC hull geometry which is used in the tutorial is available at $WM_PROJECT_DIR/tutorials/resources/geometry. The DTC-scaled.stl is to be copied to /constant/trisurface/.

The entire case setup is available with the report. The reader should take a look into the setupwhile going through further sections.

3.1 Geometry

The geometry setup requires a ship floating in water thus forming an interface of air and water.The meshing of the hull surface is done using snappyHexMesh tool. This requires a backgroundmesh which is done using blockMesh utility. A block of size 22m x 4m x 4m is created and meshedusing blockMesh utility.The final block of size 22m x 4m x 4m is show in Fig.3.1. It consists ofthree patches inlet, outlet, atmosphere and sides. The sides are declared as symmetry plane. TheblockMeshDict file is shown below. It is kept in system folder.

Figure 3.1: 22m x 4m x 8m block

16

Page 19: Couple waves2Foam with Self-Propulsion

3.1. GEOMETRY CHAPTER 3. CASE SETUP

/*--------------------------------*- C++ -*----------------------------------*\

| ========= | |

| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |

| \\ / O peration | Version: 3.0.x |

| \\ / A nd | Web: www.OpenFOAM.org |

| \\/ M anipulation | |

\*---------------------------------------------------------------------------*/

FoamFile

{

version 2.0;

format ascii;

class dictionary;

object blockMeshDict;

}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 1;

vertices

(

(-8 0 -2)

(14 0 -2)

(14 4 -2)

(-8 4 -2)

(-8 0 2)

(14 0 2)

(14 4 2)

(-8 4 2)

);

blocks

(

hex (0 1 2 3 4 5 6 7) (40 20 20) simpleGrading (1 1 1)

);

edges

(

);

boundary

(

outlet

{

type patch;

faces

(

(0 4 7 3)

);

}

inlet

{

type patch;

faces

(

17

Page 20: Couple waves2Foam with Self-Propulsion

3.2. MESH GENERATION USING SNAPPYHEXMESHDICT CHAPTER 3. CASE SETUP

(2 6 5 1)

);

}

atmosphere

{

type patch;

faces

(

(4 5 6 7)

);

}

sides

{

type symmetry;

faces

(

(1 5 4 0)

(3 7 6 2)

(0 3 2 1)

);

}

);

3.2 Mesh Generation using SnappyHexMeshDict

This section deals with the meshing process adopted for the case. As previously mentioned blockMeshutility is used to generate background mesh controlled by blockMeshDict .SnappyHexMesh is usedto create a high quality hex dominant mesh based on the hull geometry.The meshing is controlledby snappyHexMeshDict available in system folder.The various stages involved in generation of meshusing snappyHexMesh utility is described below.

• Loading geometryThe stl file DTC-scaled.stl is loaded with patch name and type.

geometry

{

DTC-scaled.stl

{

type triSurfaceMesh;

name hull;

patchInfo

{

type wall;

}

}

box1

{

type searchableBox;

min (-10 -5 -0.5);//(-1 -0.5 -0.25);

max ( 10 5 2);//( 1 0.5 1 );

}

box2

18

Page 21: Couple waves2Foam with Self-Propulsion

3.2. MESH GENERATION USING SNAPPYHEXMESHDICT CHAPTER 3. CASE SETUP

{

type searchableBox;

min (-4 -0.6 -0.5);

max ( 7 0.6 1);

}

};

box 1 and box 2 are used further for refinement of the base mesh i.e refinement region.

• Generation of castellatted meshThis is the first stage of refinement and all the settings are defined in a subdictionary castel-latedMeshControls. The mesh generated is called as castellated mesh. The various refinementparameters are specified like number of buffer layers to be inserted between each level ofrefinement,max number of cells after refinements,minimum refinement cells and such otherparameters.

maxLocalCells 100000;

maxGlobalCells 2000000;

minRefinementCells 0;

nCellsBetweenLevels 3;

• Refine basemeshBoth surface and volume based refinement of the base mesh is done in the project.The max-imum and minimum refinement level is kept as 1 .The resolveFeatureAngle ensures that thecells with multiple intersections and intersections more than 45deg gets resolved to maximumrefinement level.

refinementSurfaces

{

hull

{

level (1 1);

}

}

resolveFeatureAngle 45;

refinementRegions

{

box1

{

mode inside;

levels ((1e15 1));//1

}

box2

{

mode inside;

levels ((1e15 2));//2

}

}

19

Page 22: Couple waves2Foam with Self-Propulsion

3.2. MESH GENERATION USING SNAPPYHEXMESHDICT CHAPTER 3. CASE SETUP

• Remove cellsA keypoint is specified and should remain in the region which remains after cell removal. Thepoint is specified in cartesian co-ordinates.In the present case locationInMesh (-4 0 0); isspecified and lies outside the hull geometry boundary surface.

• Snap mesh to surfaceThis is the second most important stage of meshing. In this process the patch face(hull) isprojected onto the surface geometry.The process is called as snapping. The various settingsare defined under snapControls sub-dictionary.

snapControls

{

nSmoothPatch 3;

tolerance 1.0;

nSolveIter 300;

nRelaxIter 5;

}

• Adding mesh layer(hexahedral meshes)This is the final meshing stage. In this layer of cells are added to specified set of boundarypatches.In the present case it is hull patch.All the settings are specified under addLayersCon-trols subdictionary.

layers

{

hull

{

nSurfaceLayers 1;

}

}

• Mesh quality controlsThe generic mesh quality settings are specified under meshQualityControls. The generatedmesh using snappyHexMesh tool is kept within the limits specified within this subdictionary.Different features like maxNonOrtho, maxBoundarySkewness, maxInternalSkewnes and soon are kept under specified value. An excerpt is presented below.

meshQualityControls

{

maxNonOrtho 65;

maxBoundarySkewness 20;

maxInternalSkewness 4;

maxConcave 80;

minVol 1e-13;

Thus the final mesh generated using snappyHex tool is shown in Fig.3.2 with finer meshesclose to hull.

20

Page 23: Couple waves2Foam with Self-Propulsion

3.3. BOUNDARY AND INITIAL CONDITIONS CHAPTER 3. CASE SETUP

Figure 3.2: Mesh

3.3 Boundary and Initial Conditions

The initial and boundary conditions are kept in 0.org folder. Most of the boundary conditions usedare similar to dambreak tutorial available in $WM_PROJECT_DIR/tutorials/multiphase/interFoam

/ras/damBreak. The description of some derived boundary conditions used here are given below.

• movingWallVelocity is a velocity condition, used especially for moving walls like hull.

• pressureInletOutletVelocity condition specifies zeroGradient at all times, except on the tan-gential component which is set to fixedValue for inflow.

• totalPressure is a pressure conditions and is the kinematic pressure calculated from specifiedhydrostatic pressure and local velocity

• fixedFluxPressure:This boundary condition is similar to zeroGradient but incoporates the ef-fects of forces such as gravity.It is used on hull patches.

The boundary condition for the inlet velocity and volume fraction differs from the one specified indambreak tutorial.The inlet condition of volume fraction α and velocity U is specified as waveAlphaand waveVelocity which is obtained from waves2Foam library.

inlet

{

type waveAlpha;

refValue uniform 0;

refGrad uniform 0;

valueFraction uniform 1;

value uniform 0;

}

inlet

{

type waveVelocity;

refValue uniform ( 0 0 0 );

refGradient uniform ( 0 0 0 );

valueFraction uniform 1;

value uniform ( 0 0 0 );

}

21

Page 24: Couple waves2Foam with Self-Propulsion

3.4. DICTIONARIES CHAPTER 3. CASE SETUP

3.4 Dictionaries

The turbulence and transport properties are specified in constant directory.The properties are sameas in the Wigley Hull tutorial available in OpenFoam 2.2.x.

• transportPropertiesThe density and the kinematic viscosity is to be specified.

phases (water air);

water

{

transportModel Newtonian;

nu [0 2 -1 0 0 0 0] 1.09e-06;

rho [1 -3 0 0 0 0 0] 998.8;

}

air

{

transportModel Newtonian;

nu [0 2 -1 0 0 0 0] 1.48e-05;

rho [1 -3 0 0 0 0 0] 1;

}

sigma [1 0 -2 0 0 0 0] 0;

• turbulencePropertiesKOmega-SST model is used for turbulence modelling.

simulationType RAS;

RAS

{

RASModel kOmegaSST;

turbulence on;

printCoeffs on;

}

• wavePropertiesInaddition to above files, a new file called waveProperties is to be included. The free surfaceis set to 0.25 using the seaLevel keyword.The type of wave and the properties of the waveis specified under the inletCoeffs and outletCoeffs.The Coeffs keyword should be prefixed bythe relaxation names specified.In the present case it is specified as inlet and outlet. Thewavetype chosen is stokesFirst. The total water depth ,timeperiod,phase angle phi,direction offlow,wave height ,wave number vector and the angular frequency omega is specified. The typeof relaxation scheme and shape is chosen. The rectangular box is defined. Similarly, relaxationzone for outlet region is also defined. A potential current is chosen at the outlet. A detaileddescription of the same is given in Chapter2, Theoretical Background.

22

Page 25: Couple waves2Foam with Self-Propulsion

3.4. DICTIONARIES CHAPTER 3. CASE SETUP

/*--------------------------------*- C++ -*----------------------------------*\

| ========= | |

| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |

| \\ / O peration | Version: 3.0.x |

| \\ / A nd | Web: www.OpenFOAM.org |

| \\/ M anipulation | |

\*---------------------------------------------------------------------------*/

FoamFile

{

version 2.0;

format ascii;

class dictionary;

object waveProperties;

}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

seaLevel 0.25;

seaLevelAsReference false;

relaxationNames ( inlet outlet );

initializationName inlet;

inletCoeffs

{

waveType stokesFirst;

depth 4;

period 2;

direction (-1 0 0 );

phi 0;

height 0.25;

waveNumber (-1 0 0);

omega 3.14;

relaxationZone

{

relaxationScheme Spatial;

relaxationShape Rectangular;

beachType Empty;

relaxType INLET;

startX ( 20 0 -2 );

endX ( 15 5 2 );

orientation ( -1 0 0 );

}

}

outletCoeffs

{

waveType potentialCurrent;

U (0 0 0 );

Tsoft 2;

23

Page 26: Couple waves2Foam with Self-Propulsion

3.4. DICTIONARIES CHAPTER 3. CASE SETUP

relaxationZone

{

relaxationScheme Spatial;

relaxationShape Rectangular;

beachType Empty;

relaxType OUTLET;

startX ( -12 0 -2 );

endX ( -14 5 2 );

orientation ( -1 0 0 );

}

}

• dynamicMeshDictThe dynamicMeshDict dictionary is used to incorporate mesh motions.In the present case,dynamicFvMesh is used. One of the subclass of dynamicFvMesh is the dynamicMotionSolver-FvMesh. The dynamicMotionSolverFvMesh is to coupled with a suitable solver. Thus a meshmorphing motion solver sixDoFRigidBodyMotion is used.The sixDoFRigidBodyMotionCoeffs specifies all the inputs required by sixDoFRigidBodyMo-tion solver. The patch i.e hull subjected to 6DOF motions is specified. The mesh region aroundthe body is divided into two, one body motion region and other is mesh morphing region.The re-gion inside the innerDistance is body motion and between the innerDistance and outerDistanceis the mesh morphing region.The reader can have a detailed understanding of the same by refer-ring to the solver at $WM_PROJECT_DIR/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver.C. Other hull parameters are specified in the dictionary file.The restraints specified arethe translational and rotational dampers. The hull is constrained to move linearly only in z-direction and can trim about Y-axis .

/*--------------------------------*- C++ -*----------------------------------*\

| ========= | |

| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |

| \\ / O peration | Version: 3.0.x |

| \\ / A nd | Web: www.OpenFOAM.org |

| \\/ M anipulation | |

\*---------------------------------------------------------------------------*/

FoamFile

{

version 2.0;

format ascii;

class dictionary;

location "constant";

object dynamicMeshDict;

}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dynamicFvMesh dynamicMotionSolverFvMesh;

motionSolverLibs ("libsixDoFRigidBodyMotion.so");

solver sixDoFRigidBodyMotion;

sixDoFRigidBodyMotionCoeffs

{

patches (hull);

innerDistance 0.3;

24

Page 27: Couple waves2Foam with Self-Propulsion

3.4. DICTIONARIES CHAPTER 3. CASE SETUP

outerDistance 0.7;

centreOfMass (2.929541 0 0.2);

mass 412.73;

momentOfInertia (40 921 921);

rhoInf 1;

report on;

value uniform (0 0 0);

accelerationRelaxation 0.9;

solver

{

type Newmark;

}

constraints

{

zAxis

{

sixDoFRigidBodyMotionConstraint line;

direction (0 0 1);

}

yPlane

{

sixDoFRigidBodyMotionConstraint axis;

axis (0 1 0);

}

}

restraints

{

translationDamper

{

sixDoFRigidBodyMotionRestraint linearDamper;

coeff 8596;

}

rotationDamper

{

sixDoFRigidBodyMotionRestraint sphericalAngularDamper;

coeff 11586;

}

}

}

• surfaceFeatureExtractDict This dictionary file is located in system folder. A utility calledsurfaceFeatureExtract uses this dictionary to produce DTC-scaled.eMesh file in constant\trisurface

folder. The file lists all the edges forming an angle less than 150 deg.This list is further usedby snappyHexMeshDict to perform refinements at these edges.

/*--------------------------------*- C++ -*----------------------------------*\

| ========= | |

| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |

25

Page 28: Couple waves2Foam with Self-Propulsion

3.4. DICTIONARIES CHAPTER 3. CASE SETUP

| \\ / O peration | Version: 3.0.x |

| \\ / A nd | Web: www.OpenFOAM.org |

| \\/ M anipulation | |

\*---------------------------------------------------------------------------*/

FoamFile

{

version 2.0;

format ascii;

class dictionary;

object surfaceFeatureExtractDict;

}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

DTC-scaled.stl

{

// How to obtain raw features (extractFromFile || extractFromSurface)

extractionMethod extractFromSurface;

extractFromSurfaceCoeffs

{

// Mark edges whose adjacent surface normals are at an angle less

// than includedAngle as features

// - 0 : selects no edges

// - 180: selects all edges

includedAngle 150;

}

subsetFeatures

{

// Keep nonManifold edges (edges with >2 connected faces)

nonManifoldEdges yes;

// Keep open edges (edges with 1 connected face)

openEdges yes;

}

// Write options

// Write features to obj format for postprocessing

writeObj yes;

}

// ************************************************************************* //

Some additional dictionaries are required for the propeller and are described in Chapter.4.

26

Page 29: Couple waves2Foam with Self-Propulsion

Chapter 4

Propeller as BodyForce

The propeller dynamics is introduced as a bodyForce model.This model involves treating propellerthrust as localized momentum source term.The bodyForce model used here is based on work presented by Prof.Eric Paterson at OpenFOAMWorkshop 7 and can be referred from https://sourceforge.net/projects/openfoam-extend/files

/OpenFOAM_Workshops/OFW7_2012_Darmstadt/Training/EricPaterson/.All the dictionary files and +bodyForce.H+ file which will be discussed below is available with theattached files. The dictionary files needed to configure propeller thrust are kept in constant folderand same is presented below.

• bodyForceDictA dictionary named bodyForceDict is created which defines the propeller size.

/*--------------------------------*- C++ -*----------------------------------*\

| ========= | |

| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |

| \\ / O peration | Version: 3.0.x |

| \\ / A nd | Web: www.OpenFOAM.org |

| \\/ M anipulation | |

\*---------------------------------------------------------------------------*/

FoamFile

{

version 2.0;

format ascii;

class dictionary;

object bodyForceDict;

}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

xProp -0.15;

yProp 0.0;

zProp 0.0;

xPropmin -0.18;

xPropmax -0.14;

tipRadius 0.1;

hubRadius 0.01;

// ************************************************************************* //

27

Page 30: Couple waves2Foam with Self-Propulsion

CHAPTER 4. PROPELLER AS BODYFORCE

• dragForceDictdragForceDict shown below specifies the patchname, UName and rhoName required by func-tion object forces. The function object is used to determine the hull forces at runtime./

/*--------------------------------*- C++ -*----------------------------------*\

| ========= | |

| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |

| \\ / O peration | Version: 3.0.x |

| \\ / A nd | Web: www.OpenFOAM.org |

| \\/ M anipulation | |

\*---------------------------------------------------------------------------*/

FoamFile

{

version 2.0;

format ascii;

class dictionary;

location "constant";

object dragForceDict;

}

type forces;

patches (hull);

rhoInf 998.8;

rhoName rhoInf;

UName U;

CofR (2.93 0 0.2);

Further, bodyForce.H file has to be created which uses the above two dictionary files. This fileis to be included with interDyMFoam solver and is explained at a later stage.

• bodyForce.HThe bodyForce.H file is shown below for reference.bodyForce.H file contains the implementa-tion of propeller thrust.The vector field PropThrust is created. The unit is kg/m2s2 and initialized to zero value.The two dictionary bodyForceDict and dragForceDict are imported. The propeller thrustcylindrical region is defined.An object F of forces class is created. calcForcesMoment() calculates the normal, tangentialand porous forces on the hull surface. forceEff() sums up the three forces and x-componentof the total force is taken as the thrust delivered by propeller. The total cylindrical volumeis determined by first selecting all the cells with the cell center inside the cylindrical volumeusing the if condition. The pos(s) used returns 1 if s is positive.The total volume is calcu-lated by summing up the cell volume. The cell volume is obtained by using mesh.V()[cellID]

function. The required propeller thrust is redistributed radially. rstar is the normalized valueof the propeller radius. tdist is the radial distribution of the load. Finally the vector fieldPropThrust carries the forward thrust.

Info<< "Propeller Thrust calculation" << endl;

// Allocate the body force vector field and initialize it to zero

volVectorField PropThrust

(

IOobject

(

"PropThrust",

runTime.timeName(),

28

Page 31: Couple waves2Foam with Self-Propulsion

CHAPTER 4. PROPELLER AS BODYFORCE

mesh,

IOobject::NO_READ,

IOobject::AUTO_WRITE

),

mesh,

dimensionedVector("PropThrust", dimensionSet(1,-2,-2,0,0,0,0), Foam::vector(0,0,0))

);

// Read a dictionary to configure the body force

IOdictionary bodyForceDict

(

IOobject

(

"bodyForceDict",

runTime.time().constant(),

runTime,

IOobject::MUST_READ,

IOobject::NO_WRITE

)

);

IOdictionary dragForceDict

(

IOobject

(

"dragForceDict",

runTime.time().constant(),

runTime,

IOobject::MUST_READ,

IOobject::NO_WRITE

)

);

// Define the (cylindrical) region for the body force from dictionary values

const scalar yProp (readScalar(bodyForceDict.lookup("yProp")));

const scalar zProp (readScalar(bodyForceDict.lookup("zProp")));

const scalar xPropmin (readScalar(bodyForceDict.lookup("xPropmin")));

const scalar xPropmax (readScalar(bodyForceDict.lookup("xPropmax")));

const scalar tipRadius (readScalar(bodyForceDict.lookup("tipRadius")));

const scalar hubRadius (readScalar(bodyForceDict.lookup("hubRadius")));

forces F

(

"forces",

mesh,

dragForceDict

);

F.calcForcesMoment();

vector force =F.forceEff();

scalar drag = force.x();

Info << "Thrust = " << drag << endl;

scalar thrust = 1.1*drag; //Considering 10% more

//Total Volume of the propeller disc using cell integration

29

Page 32: Couple waves2Foam with Self-Propulsion

CHAPTER 4. PROPELLER AS BODYFORCE

label numCells(0),numInside(0);

scalar integratedVolume(0.0);

forAll(mesh.cells(),cellID)

{

// Loop over all the cells in the mesh

++numCells;

const vector& cellCenter = mesh.C()[cellID];

const scalar dy = cellCenter[1] - yProp;

const scalar dz = cellCenter[2] - zProp;

const vector r(0,dy,dz);

if ((pos(xPropmax-cellCenter[0])) &&

(pos(cellCenter[0]-xPropmin)) &&

(pos(tipRadius-mag(r))) &&

(pos(mag(r)-hubRadius)))

{

++numInside;

integratedVolume += mesh.V()[cellID];

}

}

// Reduce values for parallel execution

reduce(numInside,sumOp<label>());

reduce(numCells,sumOp<label>());

reduce(integratedVolume,sumOp<scalar>());

Info << "integratedVolume ="<< integratedVolume<< endl;

//Info << "AnalyticalVolume =" << analyticalTotalVolume << endl;

// Radial Distribution of the thrust

scalar dt = 0.0;

scalar rstar = 0.0;

scalar integratedThrust = 0.0;

scalar tdist = 0.0;

forAll(mesh.cells(),cellID)

{

++numCells;

const vector& cellCenter = mesh.C()[cellID];

const scalar dy = cellCenter[1] - yProp;

const scalar dz = cellCenter[2] - zProp;

const vector r(0,dy,dz);

if ((pos(xPropmax-cellCenter[0])) &&

(pos(cellCenter[0]-xPropmin)) &&

(pos(tipRadius-mag(r))) &&

(pos(mag(r)-hubRadius)))

{

rstar=(mag(r)-hubRadius)/(tipRadius-hubRadius);

tdist = 1.0;

tdist = 3.5183*rstar*::sqrt(1.0-rstar);

dt = thrust/(integratedVolume)*tdist;

vector tempForce(dt, 0, 0);

PropThrust[cellID] =tempForce;

integratedThrust += dt * mesh.V()[cellID];

30

Page 33: Couple waves2Foam with Self-Propulsion

CHAPTER 4. PROPELLER AS BODYFORCE

}

}

reduce(integratedThrust,sumOp<scalar>());

Info << "integratedThrust = " << integratedThrust << endl;

31

Page 34: Couple waves2Foam with Self-Propulsion

Chapter 5

Solver Modification

In this chapter, the interDyMFoam solver is modified to incorporate propeller thrust and relaxationzone from waves2Foam toolkit.Copy the interDyMFoam solver to the user directory as below .Rename the interDyMFoam solverto waveProp.

mkdir $WM_PROJECT_USER_DIR/applications/solvers/waveProp

cp -r $WM_PROJECT_DIR/applications/solvers/multiphase/interFoam/

interDyMFoam/* $WM_PROJECT_USER_DIR/applications

/solvers/waveProp

cp -r $WM_PROJECT_DIR/applications/solvers/multiphase/interFoam/

alphaCourantNo.H alphaEqn.H alphaEqnSubCycle.H

setRDeltaT.H setDeltaT.H createFields.H $WM_PROJECT_USER_DIR/applications/solvers/waveProp

cd $WM_PROJECT_USER_DIR/applications/solvers/waveProp

mv interDyMFoam.C waveProp.C

Change the files in Make folder :

waveProp.C

EXE = $(FOAM_USER_APPBIN)/waveProp

Also include bodyForce.H file, discussed in previous chapter, in the solver folder. The waves2Foamtoolkit can be downloaded using the below link

svn co http://svn.code.sf.net/p/openfoam-extend/svn/trunk/Breeder_1.6/

other/waves2Foam

Download the files to $WM_PROJECT_USER_DIR/applications/utilities. The waves2Foam is thencompiled by executing Allwmake file.However, this will result in the installation of complete tool-box including all solvers and utilities. It is upto the reader to choose the files to be compiled.The entire toolkit will take considerable time to get compiled. Once the library file is compiledlibwaves2Foam.so will be created inside

$WM_PROJECT_USER_DIR/platforms/linux64GccDPInt32Opt/lib.

Now further modify the option file in Make folder to include the library files libforces and lib-waves2Foam.

EXE_INC = \

-I$(LIB_SRC)/postProcessing/functionObjects/forces/lnInclude \

-I$(WM_PROJECT_USER_DIR)/applications/utilities/waves2Foam/src/

waves2Foam/lnInclude

EXE_LIBS = \

-lforces \

-L$(FOAM_USER_LIBBIN)

32

Page 35: Couple waves2Foam with Self-Propulsion

5.1. IMPLEMENTATION OF BODYFORCE CHAPTER 5. SOLVER MODIFICATION

5.1 Implementation of bodyForce

The body Force PropThrust is introduced in the UEqn as a local source term. The excerpts fromUEqn is shown below

fvVectorMatrix UEqn

(

fvm::ddt(rho, U) + fvm::div(rhoPhi, U)

+ MRF.DDt(rho, U)

+ turbulence->divDevRhoReff(rho, U)

- PropThrust

==

fvOptions(rho, U)

);

Include #include "forces.H" along with the list of header files in the solver.Further #include "bodyForce.H" in the waveProp.C file prior to the inclusion of UEqn.H as shownbelow.

#include "bodyForce.H"

#include "UEqn.H"

Fig.5.1a and Fig.5.1b shows a local acceleration in the flow compared to the surrounding due topresence of propeller.The red region indicates a cylindrical region behind the propeller caused dueto propeller thrust.

33

Page 36: Couple waves2Foam with Self-Propulsion

5.2. COUPLING OF WAVES2FOAM CHAPTER 5. SOLVER MODIFICATION

(a)

(b)

Figure 5.1: Propeller Local Acceleration

5.2 Coupling of waves2Foam

The wave is introduced by including relaxationZone.H and readWaveProperties.H in waveProp.Cfile. Include the relaxationZone.H along with the list of header files. The readWaveProperties.Hfile is included before createFields.H. readWaveProperties.H creates IOdictionary wavepropertieswhich is further read by relaxationZone class [3]. An excerpt from the readWaveProperties.H file isshown below for information.

IOdictionary waveProperties

(

IOobject

(

"waveProperties",

runTime.constant(),

mesh,

IOobject::MUST_READ,

IOobject::NO_WRITE

)

34

Page 37: Couple waves2Foam with Self-Propulsion

5.2. COUPLING OF WAVES2FOAM CHAPTER 5. SOLVER MODIFICATION

);

An object of the relaxationZone class is created in createFields.H file.Three arguments passed aremesh ,volVectorField U and volScalarfield alpha1.

relaxationZone relaxing(mesh, U, alpha1)

The relaxing.correct() is included after the mesh.update() in waveProp.C so that relaxationzone is updated with the change in mesh[3]. After making all the inclusions, solver can be compiledby running wmake.

35

Page 38: Couple waves2Foam with Self-Propulsion

Chapter 6

Conclusion and Future Work

6.1 Results and Discussions

The results are presented in this section and related discussions are made.

Figure 6.1: Contour Plot-Wave Generation

Figure 6.2: Wave Plot-2D view

Figure 6.1 and 6.2 indicates wave generation at the inlet. It can be observed that there is nosignificant diverging waves from the hull. This is because of the speed being less in the range of0.3-0.4 m/s at the inlet to the hull. Also the mesh is very coarse to show the significance. The wavespeed selected in this project has also been limited due to very coarse mesh. However a good meshcan produce significantly better results.

36

Page 39: Couple waves2Foam with Self-Propulsion

6.2. CONCLUSION AND FUTURE WORKCHAPTER 6. CONCLUSION AND FUTURE WORK

Figure 6.3: Dynamic Mesh

Figure 6.3 indicates dynamic motion of the mesh.Deformation in the mesh can be observed inthe forward end which shows the trim of the ship.

6.2 Conclusion and Future Work

The tutorial has demonstrated how a self propulsion simulation which is very common in marinehydrodynamics can be carried out using OpenFoam. The tutorial showed how an existing solverin OpenFoam can be extended to incorporate a propeller. Further, a reader would have learned indetail how a wave can be simulated using an external library waves2Foam, since a dedicated solveris not available in OpenFoam. A detail description of the library files would have helped the readerto have a good understanding of the structure and working principle of the library file.The scope of work of this project has been limited by time and can be further extended.The futurework could be in the areas of meshing and propeller modelling and as listed below.

1. The project focuses only on the setup for coupling of waves2Foam with SelfPropulsion. Forbetter results, further work has to be carried out on meshing of DTC hull. The wave is sensitive tothe meshing and hence a better meshing around the hull and fine mesh has to be used in the domain.

2. A better propeller modelling can be done and propeller to be coupled with the motion of the hull.

37

Page 40: Couple waves2Foam with Self-Propulsion

Bibliography

[1] N. Bruinsma. Validation and application of a fully nonlinear numerical wave tank. Master’sthesis, TU Delft, mar 2016.

[2] David R. Fuhrman Niels G. Jacobsen and JA¸rgen FredsA¸e. A wave generation toolbox forthe open-source cfd library: Openfoam. INTERNATIONAL JOURNAL FOR NUMERICALMETHODS IN FLUIDS, 2011.

[3] OpenFoamWiki. waves2foam. http://openfoamwiki.net/index.php/Contrib/waves2Foam.

38

Page 41: Couple waves2Foam with Self-Propulsion

Chapter 7

Study Questions

How to use it:

• Where to find waves2Foam tookit?

• Which utility is used for meshing of the hull geometry?

• What are the major steps of meshing in snappyHexMesh utility?

The theory of it:

• Which are the various classes in waves2Foam that have been discussed in this project?

How it is implemented:

• How a propeller has been implemented in this project?.

How to modify it:

• Which are those files created to incorporate propeller ?

• Which class object do you create in the interDyMFoam solver?Also name the member functionsaccessed.

39