Top Banner
Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary a Implementation of multiple deltaTs for the multi-region solver based on chtMultiRegionFoam Yuzhu Pearl Li Department of Mechanical and Structural Engineering and Materials Science, University of Stavanger, Stavanger, Norway 2016-12-5 Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 1 / 38
38

Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Aug 27, 2018

Download

Documents

hoangkhanh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Implementation of multiple deltaTs for the multi-regionsolver based on chtMultiRegionFoam

Yuzhu Pearl Li

Department of Mechanical and Structural Engineering and Materials Science,University of Stavanger,

Stavanger, Norway

2016-12-5

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 1 / 38

Page 2: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Outline

Outline

This work is to demonstrate the structure of chtMultiRegionFoam solverin FOAM-extend-4.0 and to implement modifications upon it.

Introduction

A walk through the solvers

Multi-region loop modifications

Verification: Try with the new solver

Pressure coupled boundary condition

Summary and future work

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 2 / 38

Page 3: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Introduction

Introduction

Multi-physics(multi-region) problems

chtMultiRegionFoam

Solver modifications

*Note that the chtMultiRegionFoam in Foam-extend-4.0 has differences from

the version in OpenFOAM-4.0. This work may not be able to directly applied to

other OpenFOAM versions.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 3 / 38

Page 4: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Multi-physics(multi-region) problems

Multi-physics(multi-region) problems

Conjugate Heat TransferWave-Structure-Soil

Interaction

A multi-physics problem has multiple physical domains; the interactionbetween the domains are achieved by boundary condition update.For some multi-physics problems, it is not efficient to calculate themultiple regions with the same mesh size and time step.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 4 / 38

Page 5: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Multi-physics(multi-region) problems

Conjugate heat transfer and wave-structure-soil interaction

The modification of the chtMultiRegionFoam is regarded as an initialstep to develop a wave-structure-soil (WSS) interaction solver.

chtMultiRegionFoam:heat transfer (Kappa, T) between fluid and solid regions.

Wave-structure-soil Interaction:pressure transfer (p) from fluid to solid regions.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 5 / 38

Page 6: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

chtMultiRegionFoam

chtMultiRegionFoam

What and why?

The chtMultiRegionFoam is a multi-regional(multi-physics) solverworking on fluid and solid regions.

The chtMultiRegionFoam contains solvers for each domain and theyare coupled by boundary condition update.

The physical feature of the conjugate heat transfer is one-waycoupling, from the high temperature regions to the low temperatureregions.

The chtMultiRegionFoam is a transient solver (whilechtMultiRegionSimpleFoam is a steady-state solver).

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 6 / 38

Page 7: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Solver modifications

Solver modifications

Based on chtMultiRegionFoam,

Loop modification with multiple deltaTs (two approaches)

Solver verifications by case study

Pressure coupled boundary condition

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 7 / 38

Page 8: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

A walk through the chtMultiRegionFoam solver

|----- chtMultiRegionFoam.C

|----- fluid

| |----- ...

| |----- solveFluid.H

|----- solid

|----- ...

|----- solveSolid.H

|----- derivedFvPatchFields

| |----- solidWallHeatFluxTemperature

| |----- solidWallMixedTemperatureCoupled

|----- regionProperties

|----- include

|----- readPIMPLEControls.H

|----- Make

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 8 / 38

Page 9: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

A walk through the chtMultiRegionFoam solver

chtMultiRegionFoam.C, the main source file, calls the needed files andsolvers.

regionProperties/ reads fluid and solid region names setted in theconstant/regionProperties of the case files.

fluid/ contains source files that solve equations forcontinuity momentum,enthalpy, pressure for the fluid regions.

solid/ contains source files for solving heat conduction equation in solidregions.

derivedFvPatchFields/ contains files that set new boundary conditionsfor the coupling between solid and fluid domains.

include/ contains files to set/reset the multi-region time step.

Make/ contains files for compilation purpose.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 9 / 38

Page 10: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

chtMultiRegionFoam.C

chtMultiRegionFoam.C

The source file of chtMultiRegionFoam.C provides a main clue of how isthe solver constructed.It can be viewed by

f40NR

cd $FOAM_SOLVERS/heatTransfer/chtMultiRegionFoam

vi chtMultiRegionFoam.C

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 10 / 38

Page 11: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

PIMPLE loop

The PIMPLE loop in chtMultiRegionFoam.C

for (int oCorr=0; oCorr<nOuterCorr; oCorr++)

{

forAll(fluidRegions, i)

{

Info<< "\nSolving for fluid region "

<< fluidRegions[i].name() << endl;

#include "setRegionFluidFields.H"

#include "readFluidMultiRegionPIMPLEControls.H"

#include "solveFluid.H"

}

forAll(solidRegions, i)

{

Info<< "\nSolving for solid region "

<< solidRegions[i].name() << endl;

#include "setRegionSolidFields.H"

#include "readSolidMultiRegionPIMPLEControls.H"

#include "solveSolid.H"

}

}

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 11 / 38

Page 12: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

PIMPLE loop

PIMPLE loop

The chtMultiRegionFoam solver uses PIMPLE loop algorithm. PIMPLEalgorithm is a combination of the pressure-implicit split-operator (PISO) and thesemi-implicit method for pressure-linked equations (SIMPLE) algorithms. The

PIMPLE parameters are set in the fvSolution in a case. For example,

PIMPLE

{

momentumPredictor off;

nOuterCorrectors 1;

nCorrectors 2;

nNonOrthogonalCorrectors 1;

pRefCell 0;

pRefValue 0;

}

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 12 / 38

Page 13: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Fluid solver and solid solver

Fluid solver

The fluid solver solves:

density rho

pressure p, the derivative of pressure DpDt

velocity U

thermal energy h

h = cp · dT (1)

where cp is the specific heat capacity at a constant pressure.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 13 / 38

Page 14: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Fluid solver and solid solver

Fluid solver includes four equations:

solveFluid.H

if (oCorr == 0)

{

#include "rhoEqn.H" //Solve the continuity for density.

}

#include "UEqn.H" //Solve the momentum equation

#include "hEqn.H" //Solve the thermal energy

// --- PISO loop

for (int corr = 0; corr < nCorr; corr++)

{

#include "pEqn.H" //solve pressure

}

turb.correct();

rho = thermo.rho();

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 14 / 38

Page 15: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Fluid solver and solid solver

Solid solver

The solid solver solvers temperature T .Variables that are needed for solving the temperature equation are:

thermal conductivity (Kappa)

specific heat capacity (cp)

solid density (rho)

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 15 / 38

Page 16: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Fluid solver and solid solver

Solid solverThe solid solver solves the TEqn for solid regions.

tmp<fvScalarMatrix> TEqn

(

fvm::ddt(rho*cp, T)

- fvm::laplacian(Kappa, T)

);

TEqn().relax();

TEqn().solve();

}

The corresponding mathematical formula for the TEqn is:

ρ · cp∂T

∂t−∇(KT ) = 0 (2)

where K denotes Kappa.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 16 / 38

Page 17: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Interface boundary coupling

Interface boundary coupling

The solidWallMixedTemperatureCoupled directory defines the mixedcoupling boundary condition that the multi-regions are coupled viaDirichlet-Neumann partitioning strategy at the coupled interface:

Dirichlet boundary condition:

Γ1 = Γ2 (3)

where the neighbour patches have the same field value.

Neumann boundary condition:

∂Γ1

∂n1=∂Γ2

∂n2(4)

where the neighbour patches agree on the gradient of the field value.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 17 / 38

Page 18: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Interface boundary coupling

Temperature coupled boundary condition

The temperature coupled boundary condition is declared and defined inthe directory ofderivedFvPatchFields/ solidWallMixedTemperatureCoupled/

:solidWallMixedTemperatureCoupledFvPatchScalarField.H

solidWallMixedTemperatureCoupledFvPatchScalarField.C

The source file of the boundary condition can be viewed by

cd derivedFvPatchFields/solidWallMixedTemperatureCoupled/

vi solidWallMixedTemperatureCoupledFvPatchScalarField.C

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 18 / 38

Page 19: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Loop modification: Implementation of multiple deltaTs to the PIMPLEloop

Goal: The goal of the multi-region loop modification is to introduce anextra time step for the solid regions, in addition to the original time stepfor the fluid regions.

Reason: To improve the efficiency of the whole system when the time steprequirements varies between different physical regions.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 19 / 38

Page 20: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Two approaches

Two approaches of implementation

The first approach. Introduce a time step for the solid regions(solidRegionDeltaT) which is an integral multiple of the fluidregion time step (deltaT), i.e.

solidRegionDeltaT = n · deltaT (5)

where n is an integer.The ’adjustTimeStep’ switch should be turned off.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 20 / 38

Page 21: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

The first approach

First approach: implementation overview

1 Rename the solver as chtMultiRegionMultiDeltaTFoam.

2 Create a new variable to control the solid region delta T calledsolidRegionDeltaT. The creating of this variable should be implementedin solid/readSolidTimeControls.H.

3 A checking statement is written to check if the solidRegionDeltaT isintegral multiple of the deltaT. If not, the program will stop runninginstead of generating garbage results.

4 Based on the modification of step 3, inchtMultiRegionMultiDeltaTFoam.C, Add

#include <math.h>

for the computation of the remainder between two floating numbers.

5 Modify the PIMPLE loop.

6 Run wmake in the top-level of the new solver.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 21 / 38

Page 22: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

The first approach

The modified PIMPLE loop

for (int oCorr=0; oCorr<nOuterCorr; oCorr++)

{

forAll(fluidRegions, i)

{

Info<< "\nSolving for fluid region "<< fluidRegions[i].name() << endl;

#include "setRegionFluidFields.H"

#include "readFluidMultiRegionPIMPLEControls.H"

#include "solveFluid.H"

}

//To write the time variables in the log file.

Info << "If statement remainder: "

<< fmod(runTime.value(), solidRegionDeltaT)

<< nl

<< "RunTime, solidDeltaT:" << nl

<< runTime.value() << ", " << solidRegionDeltaT

<< endl;

//To check if the solid solver is to be run.

if(fmod(runTime.value(), solidRegionDeltaT) < SMALL)

{

forAll(solidRegions, i)

{

Info<< "\nSolving for solid region " << solidRegions[i].name() << endl;

#include "setRegionSolidFields.H"

#include "readSolidMultiRegionPIMPLEControls.H"

#include "solveSolid.H"

}

}

}

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 22 / 38

Page 23: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

The first approach

The second approach

The second approach is to introduce two variables:

solidRegionDeltaTRef

solidRegionRunTime

Every time the runTime difference in equation (7) passessolidRegionDeltaTRef, the solid regions will be solved.

runTime(i)− solidRegionRunTime(j-1) > solidRegionDeltaTRef (6)

And thensolidRegionRunTime(j) = runTime(i) (7)

The second approach will allow the adjustment of the time step.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 23 / 38

Page 24: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

The second approach

Second approach: implementation overview

1 Give the name to the new solver aschtMultiRegionMultiDeltaTRefFoam.

2 Modifications in the Make/files.

3 Two new variables need to be created insolid/readSolidTimeControls.H:solidRegionDeltaTRef and solidRegionRunTime.

4 Modify the PIMPLE loop in the main source file.

5 Compile the solver.

Detailed steps will be shown in the next slides.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 24 / 38

Page 25: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

The second approach

Implementation of multiple deltaTs to the multi-region solver

Give the name to the new solver as chtMultiRegionMultiDeltaTRefFoam.

mkdir -p $WM_PROJECT_USER_DIR/applications/solvers/multiphysics/

cd $WM_PROJECT_USER_DIR/applications/solvers/multiphysics/

cp -r $FOAM_SOLVERS/heatTransfer/chtMultiRegionFoam .

mv chtMultiRegionFoam chtMultiRegionMultiDeltaTRefFoam

cd chtMultiRegionMultiDeltaTRefFoam

mv chtMultiRegionFoam.C chtMultiRegionMultiDeltaTRefFoam.C

Make sure that the binary file ends up in the user directory, followingmodifications need to be implemented in the make/files,

sed -i s/chtMultiRegionFoam/chtMultiRegionMultiDeltaTRefFoam/g Make/files

sed -i s/FOAM_APPBIN/FOAM_USER_APPBIN/g Make/files

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 25 / 38

Page 26: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

The second approach

Implementation of multiple deltaTs to the multi-region solverIn solid/readSolidTimeControls.H.

vi solid/readSolidTimeControls.H

Add the following commands after the declaration of scalar maxDi:

scalar solidRegionDeltaTRef = runTime.controlDict().

lookupOrDefault<scalar>("solidRegionDeltaTRef", runTime.deltaT().value());

scalar solidRegionRunTime;

Add the Info statement also.

Info << "solidRegionDeltaTRef set to: "

<< solidRegionDeltaTRef

<< " s."

<< endl;

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 26 / 38

Page 27: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

The second approach

Implementation of multiple deltaTs to the multi-region solver

In chtMultiRegionMultiDeltaTRefFoam.C, before the line ’while(runTime.run())’, add

solidRegionRunTime=0.0;

Then, before ’runTime.write();’, replace the PIMPLE loop by the following codes(continue on the next page)

// --- PIMPLE loop

for (int oCorr=0; oCorr<nOuterCorr; oCorr++)

{

forAll(fluidRegions, i)

{

Info<< "\nSolving for fluid region "

<< fluidRegions[i].name() << endl;

#include "setRegionFluidFields.H"

#include "readFluidMultiRegionPIMPLEControls.H"

#include "solveFluid.H"

}

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 27 / 38

Page 28: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

The second approach

Implementation of multiple deltaTs to the multi-region solver//To write the time step variables in the log file.

Info << "RunTime-solidRegionRunTime: "

<< runTime.value()-solidRegionRunTime

<< nl

<< "RunTime, solidRegionRunTime, solidRegionDeltaTRef:"

<< nl

<< runTime.value() << ", " << solidRegionRunTime

<< ", " << solidRegionDeltaTRef

<< endl;

//To check if the solid solver is to be run:

if(runTime.value()-solidRegionRunTime > solidRegionDeltaTRef)

{

//set the solidRegionRunTime as current runTime and

//store it in the variable for the next comparison

solidRegionRunTime = runTime.value();

forAll(solidRegions, i)

{

Info<< "\nSolving for solid region "

<< solidRegions[i].name() << endl;

#include "setRegionSolidFields.H"

#include "readSolidMultiRegionPIMPLEControls.H"

#include "solveSolid.H"

}

}

}

Run wmake.Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 28 / 38

Page 29: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Try with the new solver

A quick hands-on: Try with the new solver:Following the commands below to test the solver. Copy the tutorial casechtMultiRegionFoam/multiRegionHeater into run directory and rename it asmultiRegionHeaterMultiDeltaTRef.

f40NR

mkdir -p $WM_PROJECT_USER_DIR/run/tutorials/test/chtMultiRegionFoam

cd $WM_PROJECT_USER_DIR/run/tutorials/test/chtMultiRegionFoam

cp -r $FOAM_TUTORIALS/heatTransfer/chtMultiRegionFoam/multiRegionHeater .

mv multiRegionHeater multiRegionHeaterMultiDeltaTRef

cd multiRegionHeaterMultiDeltaTRef

In the system/controlDict, add the new created variable solidRegionDeltaTRef and set it to0.01. Add the following line in to the controlDict file:

solidRegionDeltaTRef 0.01;

In the Allrun file,

sed -i s/chtMultiRegionFoam/chtMultiRegionMultiDeltaTRefFoam/g Allrun

Then, type ./Allrun

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 29 / 38

Page 30: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Verification and visualization

Verification

Check the log.chtMultiRegionMultiDeltaTRefFoam file. It shows that, the solid regions wererun every time the RunTime-solidRegionRunTime is larger than 0.01.For example, at the first time step, the deltaT was adjusted to 0.101s, therefore, RunTimeminus solidRegionRunTime was 0.101, larger than solidRegionDeltaTRef(0.01), so the solidregions were computed at this time step.

deltaT = 0.1

Time = 0.101

Solving for fluid region bottomAir...

Solving for fluid region topAir...

RunTime-solidRegionRunTime: 0.101

RunTime, solidRegionRunTime, solidRegionDeltaTRef:

0.101, 0, 0.01

Solving for solid region heater...

Solving for solid region leftSolid...

Solving for solid region rightSolid...

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 30 / 38

Page 31: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Verification and visualization

VisualizationTo author’s knowledge, the multiRegionHeater tutorial case solved by chtMultiRegionFoam doesnot work well with paraview visualization in Foam-extend-4.0. Therefore, current way for solvingsuch problem is to use paraview in OpenFOAM-4.0 instead.Open a new terminal, and source OpenFOAM-4.0 by:

OF4x

Then create files for each region for paraview post-processing by:

touch multiRegionHeater{bottomAir}.OpenFOAM

touch multiRegionHeater{heater}.OpenFOAM

touch multiRegionHeater{leftSolid}.OpenFOAM

touch multiRegionHeater{rightSolid}.OpenFOAM

touch multiRegionHeater{topAir}.OpenFOAM

Then

paraview

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 31 / 38

Page 32: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Verification and visualization

Visualization

Meshes of the

multiRegionHeater 3D view of multiRegionHeater

Density of the topAirYuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 32 / 38

Page 33: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Pressure coupled boundary condition

A pressure coupled boundary condition for multi-physics solver wasdeveloped. It has not yet been applied into the solver at this stage.

solidWallPressureCoupled boundary condition was developedbased on solidWallMixedTemperatureCoupled boundarycondition.

When pressure transfers from fluid to solid, it is only to do with theDirichlet type boundary condition. Both sides agree on the pressurevalues:

p1 = p2 (8)

However, in the development, the Neumann type andDirichlet-Neumann partitioning strategy is kept in case of futureextension.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 33 / 38

Page 34: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Pressure coupled boundary condition

The code of the new boundary conditionsolidWallPressureCoupled can be found in the attachments ofthis project.

At current stage, the verification of such boundary condition cannotbe done. To verify, more modifications to the solid solver need to beimplemented.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 34 / 38

Page 35: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Try with the Pressure coupled boundary conditionReplace the following condition in the field p in the tutorial case multiRegionHeater inFoam-extend-4.0,

bottomAir_to_rightSolid

{

type buoyantPressure;

value uniform 1e+05;

}

by

bottomAir_to_rightSolid

{

type solidWallPressureCoupled;

neighbourRegionName rightSolid;

neighbourPatchName rightSolid_to_bottomAir;

neighbourFieldName p;

p p;

value uniform 1e+05;

}

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 35 / 38

Page 36: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Try with the Pressure coupled boundary condition

However, after running, the case will stop with an error. It complains that:

request for volScalarField p from objectRegistry rightSolid failed

available objects of type volScalarField are

5

(

cp

Kappa

rho

T

rhosCps

)

This is because a pressure field was not created for the solid regions. Avolume field p needs to be created in order to use the pressure coupledboundary condition.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 36 / 38

Page 37: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Summary and future work

The chtMultiRegionFoam has been studied and modified. Thestructure of the chtMultiRegionFoam solver was discussed. Twoapproaches of loop modifications were implemented and verified. Anew boundary condition for pressure coupling was implemented.

More work needs to be done:

The test and verification of the pressure coupled boundary condition.Solid solver modification for computing displacement and stress.Fluid solver modification for solving the incompressible two-phase fluids.

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 37 / 38

Page 38: Implementation of multiple deltaTs for the multi-region ...hani/kurser/OS_CFD_2016/YuzhuPearlLi/slides.pdf · Outline Introduction The chtMultiRegionFoam solver Loop modi cation Test

Outline Introduction The chtMultiRegionFoam solver Loop modification Test the new solver Pressure coupled B.C. Summary and future work Acknowledgement

Acknowledgement

I would like to thank Professor Hakan Nilson for providing the course ofCFD with opensource software OpenFOAM and the continuous patienceand support.Thanks to Gregor Cvijetic for the technical help and very useful advices.Thanks to Turo Valikangas for the knowledge sharing of the conjugateheat transfer solvers.I am immensely grateful to my supervisor Professor Muk Chen Ong fromUniversity of Stavanger.

Many thanks to all the classmates in this course for we have shared a goodtime and knowledge with each other!

Yuzhu Pearl Li Implementation of multiple deltaTs based on chtMultiRegionFoam 2016-12-5 38 / 38