0% found this document useful (0 votes)
218 views

02 Lectures OpenFOAM Solver Modification

The lecture discusses developing custom solvers in OpenFOAM. It covers the structure of solvers, compiling with wmake, examining the icoFoam solver, adding energy equation variables and equations to the code, and modifying test cases to solve the additional equation. The document provides guidance on building solvers in OpenFOAM from selecting prototype solvers to modifying test cases for new equations.

Uploaded by

paniya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
218 views

02 Lectures OpenFOAM Solver Modification

The lecture discusses developing custom solvers in OpenFOAM. It covers the structure of solvers, compiling with wmake, examining the icoFoam solver, adding energy equation variables and equations to the code, and modifying test cases to solve the additional equation. The document provides guidance on building solvers in OpenFOAM from selecting prototype solvers to modifying test cases for new equations.

Uploaded by

paniya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

Use Of Open Source Programs In Metallurgy

Lecture 02: Developing OpenFOAM® solver

Dr. Alexander Vakhrushev

Alexander Vakhrushev @ ResearchGate

January | 2019
OpenFOAM® resources
http://wiki.openfoam.com/Tutorials
Tutorials at OpenFOAM Wiki

http://www.tfd.chalmers.se/~hani/kurser/OS_CFD/
Chalmers University (Sweden)

http://openfoamwiki.net/index.php/Main_Page
Bernhard F.W. Gschaider (Leoben)

http://holzmann-cfd.de/free-material
Tutorial from Holzmann CFD (Germany)

http://www.openfoam.com
Official OpenFOAM® ESI version

http://openfoam.org
The OpenFOAM® Foundation version

http://sourceforge.net/projects/foam-extend/
foam-extend Community Driven Project
Outline

 Introduction
 Solver structure

 Make settings with “files” and “options”

 Compiling solver with “wmake”

 A look at the “icoFoam” solver

 Adding energy equation variables

 Adding energy equation

 Modifying and running cavity case


Developing your solver: select a prototype
1 2

3
Navigate through the OpenFOAM® source tree
Outline
 Introduction

 Solver structure
 Make settings with “files” and “options”

 Compiling solver with “wmake”

 A look at the “icoFoam” solver

 Adding energy equation variables

 Adding energy equation

 Modifying and running cavity case


icoFoam solver structure

Solver folder
Build settings

Files & solver name


Directives / libraries

Header(s)

Main file
Outline
 Introduction

 Solver structure

 Make settings with “files” and “options”


 Compiling solver with “wmake”

 A look at the “icoFoam” solver

 Adding energy equation variables

 Adding energy equation

 Modifying and running cavity case


Modifying “files” input

icoFoam.C

EXE = $(FOAM_APPBIN)/icoFoam

icoFoam.C

EXE = $(FOAM_USER_APPBIN)/myIcoFoam
Content of the “options” file

EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude

EXE_LIBS = \
-lfiniteVolume \
-lmeshTools
Outline
 Introduction

 Solver structure

 Make settings with “files” and “options”

 Compiling solver with “wmake”


 A look at the “icoFoam” solver

 Adding energy equation variables

 Adding energy equation

 Modifying and running cavity case


OpenFOAM® build utilities “wclean” / “wmake”
Outline
 Introduction

 Solver structure

 Make settings with “files” and “options”

 Compiling solver with “wmake”

 A look at the “icoFoam” solver


 Adding energy equation variables

 Adding energy equation

 Modifying and running cavity case


A walk-through the icoFoam

System include files


in $FOAM_SRC

Solver variables
A walk-through the icoFoam
A walk-through the icoFoam
A walk-through the icoFoam
A walk-through the icoFoam
A walk-through the icoFoam
A walk-through the icoFoam
Outline
 Introduction

 Solver structure

 Make settings with “files” and “options”

 Compiling solver with “wmake”

 A look at the “icoFoam” solver

 Adding energy equation variables


 Adding energy equation

 Modifying and running cavity case


Reading properties in “createFields.H”
Creating fields in “createFields.H”
Creating energy equation fields in “createFields.H”
Outline
 Introduction

 Solver structure

 Make settings with “files” and “options”

 Compiling solver with “wmake”

 A look at the “icoFoam” solver

 Adding energy equation variables

 Adding energy equation


 Modifying and running cavity case
Add new equation to “icoFoam.C”
𝝏𝑻
𝝆𝒄𝒑 + 𝛁 ∙ 𝒖𝑻 = 𝝀𝛁𝟐 𝑻
𝝏𝒕 𝝏𝑻
+ 𝛁 ∙ 𝒖𝑻 = 𝜶𝛁 𝟐 𝑻
𝝆 = 𝒄𝒐𝒏𝒔𝒕 𝝏𝒕
𝒄𝒑 = 𝒄𝒐𝒏𝒔𝒕
Outline
 Introduction

 Solver structure

 Make settings with “files” and “options”

 Compiling solver with “wmake”

 A look at the “icoFoam” solver

 Adding energy equation variables

 Adding energy equation

 Modifying and running cavity case


Adding new field to “0/T”
Modifying “constant/transportProperties”
Modifying “system/fvSchemes”
Modifying “system/fvSolution”
Simulation results
Thank you for your attention!

You might also like