SlideShare une entreprise Scribd logo
1  sur  12
Télécharger pour lire hors ligne
OpenFOAM Programming Tips
Keywords:
• OpenFOAM
• findPatchID
• gSum
• faceCells
• DynamicList
English
Fumiya Nozaki
Last Updated: 6 May 2015
2
1. How to get patch’s label from patch’s name
label patchID = mesh.boundaryMesh().findPatchID("NAME_OF_PATCH");
Info << "patchID = " << patchID << endl;
Example
5
(
inlet
{
type patch;
nFaces 30;
startFace 24170;
}
outlet
{
type patch;
nFaces 57;
startFace 24200;
}
upperWall
{
type wall;
inGroups 1(wall);
nFaces 223;
startFace 24257;
}
lowerWall
{
type wall;
inGroups 1(wall);
nFaces 250;
startFace 24480;
}
…
)
label patchID = mesh.boundaryMesh().findPatchID(“upperWall");
Info << "patchID = " << patchID << endl;
⇒ patchID = 2
0
1
2
3
3
2. How to calculate the sum over the specified patch
label outletPatchID = mesh.boundaryMesh().findPatchID(“outlet");
scalar outFlux = gSum(phi.boundaryField()[outletPatchID]);
Info << “Volumetric flux = " << outFlux << “ [m^3/s]” << endl;
We can calculate the total outlet flux
by summing the field phi over the patch named outlet:
 gSum() sums over all the processors in a parallel run
 If you calculate the total “inlet” flux using the above code, it takes the
negative value because the face normal vectors point in the opposite
direction from the inlet velocities.
inlet outlet
U
mesh.Sf()
4
3. How to get a boundary value of a variable
label patchID = mesh.boundaryMesh().findPatchID(“outlet");
forAll(mesh.boundary()[patchID], faceI)
{
Info<< U.boundaryField()[patchID][faceI] << endl;
}
We can get the velocity on the outlet patch using the following code:
faceI=0
faceI=1
faceI=2
U.boundaryField()[patchID][1]
outlet
U.boundaryField()[patchID][2]
U.boundaryField()[patchID][0]
5
4. How to get variable values in the cells adjacent to a patch
We can get the label list of cells adjacent to patch using faceCells():
label patchID = mesh.boundaryMesh().findPatchID(“outlet");
forAll(mesh.boundary()[patchID], faceI)
{
Info<< U[mesh.boundary()[patchID].faceCells()[faceI]] << endl;
}
faceI=0
faceI=1
faceI=2
U[mesh.boundary()[patchID].faceCells()[1]]
outlet
6
5. How to read cellZones
FoamFile
{
version 2.0;
format ascii;
class regIOobject;
location "constant/polyMesh";
object cellZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
2
(
rotor
{
type cellZone;
cellLabels List<label>
5
(
3
4
5
10
11
)
;
}
 Format of the cellZones file
stator
{
type cellZone;
cellLabels List<label>
4
(
15
17
20
21
)
;
}
)
For want of space
The number of cellzones Name of cellzones
The number of cells
that belong to the cellZone
List of cell labels
7
5. How to read cellZones
label cellZoneID = mesh.cellZones().findZoneID("stator");
const labelList& cellLabels = mesh.cellZones()[cellZoneID];
Info<< "cellZoneID: " << cellZoneID << endl;
Info<< "cellLabels: " << cellLabels << endl;
Continued from the previous page.
cellZoneID: 1
cellLabels: 4(15 17 20 21)
MRFZone.C
Example of use
8
6. Logical operators
boolList A(4);
A[0] = true;
A[1] = false;
A[2] = true;
A[3] = false;
Info<< "A: " << A << endl;
boolList B(4);
B[0] = true;
B[1] = true;
B[2] = false;
B[3] = false;
Info<< "B: " << B << endl;
boolList C = A * B;
Info<< "C: " << C << endl;
boolList D = A + B;
Info<< "D: " << D << endl;
A: 4(1 0 1 0)
B: 4(1 1 0 0)
C: 4(1 0 0 0)
D: 4(1 1 1 0)
Logical conjunction
Logical disjunction
9
7. How to use DynamicList
DynamicList<label> partA(0);
partA.append(3);
partA.append(1);
partA.append(4);
partA.append(1);
partA.append(5);
partA.append(9);
partA.append(2);
Info<< partA << endl;
DynamicList<label> partB(0);
partB.append(6);
partB.append(5);
partB.append(3);
partB.append(5);
partA.append(partB);
Info<< partA << endl;
Append an element at the end of the list
Initialization
7(3 1 4 1 5 9 2)
11(3 1 4 1 5 9 2 6 5 3 5)
Append a List(partB) at the end of partA
10
7. How to use DynamicList
labelList uniqueIndex;
uniqueOrder(partA, uniqueIndex);
Info<< uniqueIndex << endl;
DynamicList<label> uniqueList(0);
forAll(uniqueIndex, i)
{
uniqueList.append(partA[uniqueIndex[i]]);
}
partA.transfer(uniqueList);
Info<< partA << endl;
7(3 6 9 2 10 7 5)
Continued from the previous page.
Generate (sorted) indices
corresponding to unique list values
7(1 2 3 4 5 6 9)
11(3 1 4 1 5 9 2 6 5 3 5)
0 1 2 3 4 5 6 7 8 9 10
Index
Create a list of unique values
(remove duplicate values)
PartA
11
I will continuously update this slide in the future.
Kindly let me know
if you have any ideas about what topics to cover.
12
Thank
You!

Contenu connexe

Tendances

OpenFOAM の cyclic、cyclicAMI、cyclicACMI 条件について
OpenFOAM の cyclic、cyclicAMI、cyclicACMI 条件についてOpenFOAM の cyclic、cyclicAMI、cyclicACMI 条件について
OpenFOAM の cyclic、cyclicAMI、cyclicACMI 条件についてFumiya Nozaki
 
Basic Boundary Conditions in OpenFOAM v2.4
Basic Boundary Conditions in OpenFOAM v2.4Basic Boundary Conditions in OpenFOAM v2.4
Basic Boundary Conditions in OpenFOAM v2.4Fumiya Nozaki
 
OpenFOAMにおけるDEM計算の力モデルの解読
OpenFOAMにおけるDEM計算の力モデルの解読OpenFOAMにおけるDEM計算の力モデルの解読
OpenFOAMにおけるDEM計算の力モデルの解読takuyayamamoto1800
 
OpenFOAMにおける相変化解析
OpenFOAMにおける相変化解析OpenFOAMにおける相変化解析
OpenFOAMにおける相変化解析takuyayamamoto1800
 
OpenFOAMによる気液2相流解析の基礎と設定例
OpenFOAMによる気液2相流解析の基礎と設定例OpenFOAMによる気液2相流解析の基礎と設定例
OpenFOAMによる気液2相流解析の基礎と設定例takuyayamamoto1800
 
Setting and Usage of OpenFOAM multiphase solver (S-CLSVOF)
Setting and Usage of OpenFOAM multiphase solver (S-CLSVOF)Setting and Usage of OpenFOAM multiphase solver (S-CLSVOF)
Setting and Usage of OpenFOAM multiphase solver (S-CLSVOF)takuyayamamoto1800
 
OpenFOAMにおける混相流計算
OpenFOAMにおける混相流計算OpenFOAMにおける混相流計算
OpenFOAMにおける混相流計算takuyayamamoto1800
 
Customization of LES turbulence model in OpenFOAM
Customization of LES turbulence	 model in OpenFOAMCustomization of LES turbulence	 model in OpenFOAM
Customization of LES turbulence model in OpenFOAMmmer547
 
Tutorial to set up a case for chtMultiRegionFoam in OpenFOAM 2.0.0
Tutorial to set up a case for chtMultiRegionFoam in OpenFOAM 2.0.0Tutorial to set up a case for chtMultiRegionFoam in OpenFOAM 2.0.0
Tutorial to set up a case for chtMultiRegionFoam in OpenFOAM 2.0.0ARPIT SINGHAL
 
About chtMultiRegionFoam
About chtMultiRegionFoam About chtMultiRegionFoam
About chtMultiRegionFoam 守淑 田村
 
OpenFOAMに実装したS-CLSVOF法検証(静止気泡のLaplace圧)
OpenFOAMに実装したS-CLSVOF法検証(静止気泡のLaplace圧)OpenFOAMに実装したS-CLSVOF法検証(静止気泡のLaplace圧)
OpenFOAMに実装したS-CLSVOF法検証(静止気泡のLaplace圧)takuyayamamoto1800
 
OpenFOAMによる混相流シミュレーション入門
OpenFOAMによる混相流シミュレーション入門OpenFOAMによる混相流シミュレーション入門
OpenFOAMによる混相流シミュレーション入門takuyayamamoto1800
 
OpenFOAMソルバの実行時ベイズ最適化
OpenFOAMソルバの実行時ベイズ最適化OpenFOAMソルバの実行時ベイズ最適化
OpenFOAMソルバの実行時ベイズ最適化Masashi Imano
 
OpenFOAM -回転領域を含む流体計算 (Rotating Geometry)-
OpenFOAM -回転領域を含む流体計算 (Rotating Geometry)-OpenFOAM -回転領域を含む流体計算 (Rotating Geometry)-
OpenFOAM -回転領域を含む流体計算 (Rotating Geometry)-Fumiya Nozaki
 
無償のモデリングソフトウェアCAESESを使ってみた
無償のモデリングソフトウェアCAESESを使ってみた無償のモデリングソフトウェアCAESESを使ってみた
無償のモデリングソフトウェアCAESESを使ってみたFumiya Nozaki
 
Inter flowによる軸対称milkcrown解析
Inter flowによる軸対称milkcrown解析Inter flowによる軸対称milkcrown解析
Inter flowによる軸対称milkcrown解析守淑 田村
 
OpenFOAMの混相流用改造solver(S-CLSVOF法)の設定・使い方
OpenFOAMの混相流用改造solver(S-CLSVOF法)の設定・使い方OpenFOAMの混相流用改造solver(S-CLSVOF法)の設定・使い方
OpenFOAMの混相流用改造solver(S-CLSVOF法)の設定・使い方takuyayamamoto1800
 
About multiphaseEulerFoam
About multiphaseEulerFoamAbout multiphaseEulerFoam
About multiphaseEulerFoam守淑 田村
 

Tendances (20)

OpenFOAM の cyclic、cyclicAMI、cyclicACMI 条件について
OpenFOAM の cyclic、cyclicAMI、cyclicACMI 条件についてOpenFOAM の cyclic、cyclicAMI、cyclicACMI 条件について
OpenFOAM の cyclic、cyclicAMI、cyclicACMI 条件について
 
Basic Boundary Conditions in OpenFOAM v2.4
Basic Boundary Conditions in OpenFOAM v2.4Basic Boundary Conditions in OpenFOAM v2.4
Basic Boundary Conditions in OpenFOAM v2.4
 
OpenFOAMにおけるDEM計算の力モデルの解読
OpenFOAMにおけるDEM計算の力モデルの解読OpenFOAMにおけるDEM計算の力モデルの解読
OpenFOAMにおけるDEM計算の力モデルの解読
 
OpenFOAMにおける相変化解析
OpenFOAMにおける相変化解析OpenFOAMにおける相変化解析
OpenFOAMにおける相変化解析
 
OpenFOAMによる気液2相流解析の基礎と設定例
OpenFOAMによる気液2相流解析の基礎と設定例OpenFOAMによる気液2相流解析の基礎と設定例
OpenFOAMによる気液2相流解析の基礎と設定例
 
Setting and Usage of OpenFOAM multiphase solver (S-CLSVOF)
Setting and Usage of OpenFOAM multiphase solver (S-CLSVOF)Setting and Usage of OpenFOAM multiphase solver (S-CLSVOF)
Setting and Usage of OpenFOAM multiphase solver (S-CLSVOF)
 
OpenFOAMにおける混相流計算
OpenFOAMにおける混相流計算OpenFOAMにおける混相流計算
OpenFOAMにおける混相流計算
 
Customization of LES turbulence model in OpenFOAM
Customization of LES turbulence	 model in OpenFOAMCustomization of LES turbulence	 model in OpenFOAM
Customization of LES turbulence model in OpenFOAM
 
Tutorial to set up a case for chtMultiRegionFoam in OpenFOAM 2.0.0
Tutorial to set up a case for chtMultiRegionFoam in OpenFOAM 2.0.0Tutorial to set up a case for chtMultiRegionFoam in OpenFOAM 2.0.0
Tutorial to set up a case for chtMultiRegionFoam in OpenFOAM 2.0.0
 
About chtMultiRegionFoam
About chtMultiRegionFoam About chtMultiRegionFoam
About chtMultiRegionFoam
 
OpenFOAMに実装したS-CLSVOF法検証(静止気泡のLaplace圧)
OpenFOAMに実装したS-CLSVOF法検証(静止気泡のLaplace圧)OpenFOAMに実装したS-CLSVOF法検証(静止気泡のLaplace圧)
OpenFOAMに実装したS-CLSVOF法検証(静止気泡のLaplace圧)
 
OpenFOAMによる混相流シミュレーション入門
OpenFOAMによる混相流シミュレーション入門OpenFOAMによる混相流シミュレーション入門
OpenFOAMによる混相流シミュレーション入門
 
rhoCentralFoam in OpenFOAM
rhoCentralFoam in OpenFOAMrhoCentralFoam in OpenFOAM
rhoCentralFoam in OpenFOAM
 
OpenFOAMソルバの実行時ベイズ最適化
OpenFOAMソルバの実行時ベイズ最適化OpenFOAMソルバの実行時ベイズ最適化
OpenFOAMソルバの実行時ベイズ最適化
 
OpenFOAM -回転領域を含む流体計算 (Rotating Geometry)-
OpenFOAM -回転領域を含む流体計算 (Rotating Geometry)-OpenFOAM -回転領域を含む流体計算 (Rotating Geometry)-
OpenFOAM -回転領域を含む流体計算 (Rotating Geometry)-
 
無償のモデリングソフトウェアCAESESを使ってみた
無償のモデリングソフトウェアCAESESを使ってみた無償のモデリングソフトウェアCAESESを使ってみた
無償のモデリングソフトウェアCAESESを使ってみた
 
Of tutorials v1806
Of tutorials v1806Of tutorials v1806
Of tutorials v1806
 
Inter flowによる軸対称milkcrown解析
Inter flowによる軸対称milkcrown解析Inter flowによる軸対称milkcrown解析
Inter flowによる軸対称milkcrown解析
 
OpenFOAMの混相流用改造solver(S-CLSVOF法)の設定・使い方
OpenFOAMの混相流用改造solver(S-CLSVOF法)の設定・使い方OpenFOAMの混相流用改造solver(S-CLSVOF法)の設定・使い方
OpenFOAMの混相流用改造solver(S-CLSVOF法)の設定・使い方
 
About multiphaseEulerFoam
About multiphaseEulerFoamAbout multiphaseEulerFoam
About multiphaseEulerFoam
 

Similaire à OpenFOAM Programming Tips

Csphtp1 07
Csphtp1 07Csphtp1 07
Csphtp1 07HUST
 
Programming JVM Bytecode with Jitescript
Programming JVM Bytecode with JitescriptProgramming JVM Bytecode with Jitescript
Programming JVM Bytecode with JitescriptJoe Kutner
 
Exploit Research and Development Megaprimer: Win32 Egghunter
Exploit Research and Development Megaprimer: Win32 EgghunterExploit Research and Development Megaprimer: Win32 Egghunter
Exploit Research and Development Megaprimer: Win32 EgghunterAjin Abraham
 
Programming JVM Bytecode
Programming JVM BytecodeProgramming JVM Bytecode
Programming JVM BytecodeJoe Kutner
 
Return Oriented Programming, an introduction
Return Oriented Programming, an introductionReturn Oriented Programming, an introduction
Return Oriented Programming, an introductionPatricia Aas
 
SAST and Application Security: how to fight vulnerabilities in the code
SAST and Application Security: how to fight vulnerabilities in the codeSAST and Application Security: how to fight vulnerabilities in the code
SAST and Application Security: how to fight vulnerabilities in the codeAndrey Karpov
 
SequoiaDB Distributed Relational Database
SequoiaDB Distributed Relational DatabaseSequoiaDB Distributed Relational Database
SequoiaDB Distributed Relational Databasewangzhonnew
 
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуdelimitry
 
Java bytecode Malware Analysis
Java bytecode Malware AnalysisJava bytecode Malware Analysis
Java bytecode Malware AnalysisBrian Baskin
 
201913001 khairunnisa progres_harian
201913001 khairunnisa progres_harian201913001 khairunnisa progres_harian
201913001 khairunnisa progres_harianKhairunnisaPekanbaru
 
Коварный code type ITGM #9
Коварный code type ITGM #9Коварный code type ITGM #9
Коварный code type ITGM #9Andrey Zakharevich
 
Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113SOAT
 

Similaire à OpenFOAM Programming Tips (20)

Java
JavaJava
Java
 
Csphtp1 07
Csphtp1 07Csphtp1 07
Csphtp1 07
 
Programming JVM Bytecode with Jitescript
Programming JVM Bytecode with JitescriptProgramming JVM Bytecode with Jitescript
Programming JVM Bytecode with Jitescript
 
Exploit Research and Development Megaprimer: Win32 Egghunter
Exploit Research and Development Megaprimer: Win32 EgghunterExploit Research and Development Megaprimer: Win32 Egghunter
Exploit Research and Development Megaprimer: Win32 Egghunter
 
Programming JVM Bytecode
Programming JVM BytecodeProgramming JVM Bytecode
Programming JVM Bytecode
 
Return Oriented Programming, an introduction
Return Oriented Programming, an introductionReturn Oriented Programming, an introduction
Return Oriented Programming, an introduction
 
Learning Dtrace
Learning DtraceLearning Dtrace
Learning Dtrace
 
Bluespec @waseda
Bluespec @wasedaBluespec @waseda
Bluespec @waseda
 
SAST and Application Security: how to fight vulnerabilities in the code
SAST and Application Security: how to fight vulnerabilities in the codeSAST and Application Security: how to fight vulnerabilities in the code
SAST and Application Security: how to fight vulnerabilities in the code
 
Java Generics
Java GenericsJava Generics
Java Generics
 
SequoiaDB Distributed Relational Database
SequoiaDB Distributed Relational DatabaseSequoiaDB Distributed Relational Database
SequoiaDB Distributed Relational Database
 
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
 
Java bytecode Malware Analysis
Java bytecode Malware AnalysisJava bytecode Malware Analysis
Java bytecode Malware Analysis
 
Marat-Slides
Marat-SlidesMarat-Slides
Marat-Slides
 
3
33
3
 
201913001 khairunnisa progres_harian
201913001 khairunnisa progres_harian201913001 khairunnisa progres_harian
201913001 khairunnisa progres_harian
 
Fia fabila
Fia fabilaFia fabila
Fia fabila
 
Коварный code type ITGM #9
Коварный code type ITGM #9Коварный code type ITGM #9
Коварный code type ITGM #9
 
Tugas 2
Tugas 2Tugas 2
Tugas 2
 
Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113
 

Plus de Fumiya Nozaki

Boundary Conditions in OpenFOAM
Boundary Conditions in OpenFOAMBoundary Conditions in OpenFOAM
Boundary Conditions in OpenFOAMFumiya Nozaki
 
blockCoupledSwirlTestチュートリアル
blockCoupledSwirlTestチュートリアルblockCoupledSwirlTestチュートリアル
blockCoupledSwirlTestチュートリアルFumiya Nozaki
 
CAESES Free チュートリアル
CAESES Free チュートリアルCAESES Free チュートリアル
CAESES Free チュートリアルFumiya Nozaki
 
CAESES-FFW,GridPro,OpenFOAMを使用した形状最適化事例#1
CAESES-FFW,GridPro,OpenFOAMを使用した形状最適化事例#1CAESES-FFW,GridPro,OpenFOAMを使用した形状最適化事例#1
CAESES-FFW,GridPro,OpenFOAMを使用した形状最適化事例#1Fumiya Nozaki
 
OpenFOAM の境界条件をまとめよう!
OpenFOAM の境界条件をまとめよう!OpenFOAM の境界条件をまとめよう!
OpenFOAM の境界条件をまとめよう!Fumiya Nozaki
 
ParaView による可視化 Tips
ParaView による可視化 TipsParaView による可視化 Tips
ParaView による可視化 TipsFumiya Nozaki
 
CFD for Rotating Machinery using OpenFOAM
CFD for Rotating Machinery using OpenFOAMCFD for Rotating Machinery using OpenFOAM
CFD for Rotating Machinery using OpenFOAMFumiya Nozaki
 
OpenFOAM の Function Object 機能について
OpenFOAM の Function Object 機能についてOpenFOAM の Function Object 機能について
OpenFOAM の Function Object 機能についてFumiya Nozaki
 
OpenFOAMのチュートリアルを作ってみた#1 『くさび油膜効果の計算』
OpenFOAMのチュートリアルを作ってみた#1 『くさび油膜効果の計算』OpenFOAMのチュートリアルを作ってみた#1 『くさび油膜効果の計算』
OpenFOAMのチュートリアルを作ってみた#1 『くさび油膜効果の計算』Fumiya Nozaki
 
Adjoint Shape Optimization using OpenFOAM
Adjoint Shape Optimization using OpenFOAMAdjoint Shape Optimization using OpenFOAM
Adjoint Shape Optimization using OpenFOAMFumiya Nozaki
 
オープンソースの CFD ソフトウェア SU2 のチュートリアルをやってみた
オープンソースの CFD ソフトウェア SU2 のチュートリアルをやってみたオープンソースの CFD ソフトウェア SU2 のチュートリアルをやってみた
オープンソースの CFD ソフトウェア SU2 のチュートリアルをやってみたFumiya Nozaki
 
OpenFOAM を用いた Adjoint 形状最適化事例1
OpenFOAM を用いた Adjoint 形状最適化事例1OpenFOAM を用いた Adjoint 形状最適化事例1
OpenFOAM を用いた Adjoint 形状最適化事例1Fumiya Nozaki
 

Plus de Fumiya Nozaki (12)

Boundary Conditions in OpenFOAM
Boundary Conditions in OpenFOAMBoundary Conditions in OpenFOAM
Boundary Conditions in OpenFOAM
 
blockCoupledSwirlTestチュートリアル
blockCoupledSwirlTestチュートリアルblockCoupledSwirlTestチュートリアル
blockCoupledSwirlTestチュートリアル
 
CAESES Free チュートリアル
CAESES Free チュートリアルCAESES Free チュートリアル
CAESES Free チュートリアル
 
CAESES-FFW,GridPro,OpenFOAMを使用した形状最適化事例#1
CAESES-FFW,GridPro,OpenFOAMを使用した形状最適化事例#1CAESES-FFW,GridPro,OpenFOAMを使用した形状最適化事例#1
CAESES-FFW,GridPro,OpenFOAMを使用した形状最適化事例#1
 
OpenFOAM の境界条件をまとめよう!
OpenFOAM の境界条件をまとめよう!OpenFOAM の境界条件をまとめよう!
OpenFOAM の境界条件をまとめよう!
 
ParaView による可視化 Tips
ParaView による可視化 TipsParaView による可視化 Tips
ParaView による可視化 Tips
 
CFD for Rotating Machinery using OpenFOAM
CFD for Rotating Machinery using OpenFOAMCFD for Rotating Machinery using OpenFOAM
CFD for Rotating Machinery using OpenFOAM
 
OpenFOAM の Function Object 機能について
OpenFOAM の Function Object 機能についてOpenFOAM の Function Object 機能について
OpenFOAM の Function Object 機能について
 
OpenFOAMのチュートリアルを作ってみた#1 『くさび油膜効果の計算』
OpenFOAMのチュートリアルを作ってみた#1 『くさび油膜効果の計算』OpenFOAMのチュートリアルを作ってみた#1 『くさび油膜効果の計算』
OpenFOAMのチュートリアルを作ってみた#1 『くさび油膜効果の計算』
 
Adjoint Shape Optimization using OpenFOAM
Adjoint Shape Optimization using OpenFOAMAdjoint Shape Optimization using OpenFOAM
Adjoint Shape Optimization using OpenFOAM
 
オープンソースの CFD ソフトウェア SU2 のチュートリアルをやってみた
オープンソースの CFD ソフトウェア SU2 のチュートリアルをやってみたオープンソースの CFD ソフトウェア SU2 のチュートリアルをやってみた
オープンソースの CFD ソフトウェア SU2 のチュートリアルをやってみた
 
OpenFOAM を用いた Adjoint 形状最適化事例1
OpenFOAM を用いた Adjoint 形状最適化事例1OpenFOAM を用いた Adjoint 形状最適化事例1
OpenFOAM を用いた Adjoint 形状最適化事例1
 

Dernier

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Dernier (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

OpenFOAM Programming Tips

  • 1. OpenFOAM Programming Tips Keywords: • OpenFOAM • findPatchID • gSum • faceCells • DynamicList English Fumiya Nozaki Last Updated: 6 May 2015
  • 2. 2 1. How to get patch’s label from patch’s name label patchID = mesh.boundaryMesh().findPatchID("NAME_OF_PATCH"); Info << "patchID = " << patchID << endl; Example 5 ( inlet { type patch; nFaces 30; startFace 24170; } outlet { type patch; nFaces 57; startFace 24200; } upperWall { type wall; inGroups 1(wall); nFaces 223; startFace 24257; } lowerWall { type wall; inGroups 1(wall); nFaces 250; startFace 24480; } … ) label patchID = mesh.boundaryMesh().findPatchID(“upperWall"); Info << "patchID = " << patchID << endl; ⇒ patchID = 2 0 1 2 3
  • 3. 3 2. How to calculate the sum over the specified patch label outletPatchID = mesh.boundaryMesh().findPatchID(“outlet"); scalar outFlux = gSum(phi.boundaryField()[outletPatchID]); Info << “Volumetric flux = " << outFlux << “ [m^3/s]” << endl; We can calculate the total outlet flux by summing the field phi over the patch named outlet:  gSum() sums over all the processors in a parallel run  If you calculate the total “inlet” flux using the above code, it takes the negative value because the face normal vectors point in the opposite direction from the inlet velocities. inlet outlet U mesh.Sf()
  • 4. 4 3. How to get a boundary value of a variable label patchID = mesh.boundaryMesh().findPatchID(“outlet"); forAll(mesh.boundary()[patchID], faceI) { Info<< U.boundaryField()[patchID][faceI] << endl; } We can get the velocity on the outlet patch using the following code: faceI=0 faceI=1 faceI=2 U.boundaryField()[patchID][1] outlet U.boundaryField()[patchID][2] U.boundaryField()[patchID][0]
  • 5. 5 4. How to get variable values in the cells adjacent to a patch We can get the label list of cells adjacent to patch using faceCells(): label patchID = mesh.boundaryMesh().findPatchID(“outlet"); forAll(mesh.boundary()[patchID], faceI) { Info<< U[mesh.boundary()[patchID].faceCells()[faceI]] << endl; } faceI=0 faceI=1 faceI=2 U[mesh.boundary()[patchID].faceCells()[1]] outlet
  • 6. 6 5. How to read cellZones FoamFile { version 2.0; format ascii; class regIOobject; location "constant/polyMesh"; object cellZones; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 2 ( rotor { type cellZone; cellLabels List<label> 5 ( 3 4 5 10 11 ) ; }  Format of the cellZones file stator { type cellZone; cellLabels List<label> 4 ( 15 17 20 21 ) ; } ) For want of space The number of cellzones Name of cellzones The number of cells that belong to the cellZone List of cell labels
  • 7. 7 5. How to read cellZones label cellZoneID = mesh.cellZones().findZoneID("stator"); const labelList& cellLabels = mesh.cellZones()[cellZoneID]; Info<< "cellZoneID: " << cellZoneID << endl; Info<< "cellLabels: " << cellLabels << endl; Continued from the previous page. cellZoneID: 1 cellLabels: 4(15 17 20 21) MRFZone.C Example of use
  • 8. 8 6. Logical operators boolList A(4); A[0] = true; A[1] = false; A[2] = true; A[3] = false; Info<< "A: " << A << endl; boolList B(4); B[0] = true; B[1] = true; B[2] = false; B[3] = false; Info<< "B: " << B << endl; boolList C = A * B; Info<< "C: " << C << endl; boolList D = A + B; Info<< "D: " << D << endl; A: 4(1 0 1 0) B: 4(1 1 0 0) C: 4(1 0 0 0) D: 4(1 1 1 0) Logical conjunction Logical disjunction
  • 9. 9 7. How to use DynamicList DynamicList<label> partA(0); partA.append(3); partA.append(1); partA.append(4); partA.append(1); partA.append(5); partA.append(9); partA.append(2); Info<< partA << endl; DynamicList<label> partB(0); partB.append(6); partB.append(5); partB.append(3); partB.append(5); partA.append(partB); Info<< partA << endl; Append an element at the end of the list Initialization 7(3 1 4 1 5 9 2) 11(3 1 4 1 5 9 2 6 5 3 5) Append a List(partB) at the end of partA
  • 10. 10 7. How to use DynamicList labelList uniqueIndex; uniqueOrder(partA, uniqueIndex); Info<< uniqueIndex << endl; DynamicList<label> uniqueList(0); forAll(uniqueIndex, i) { uniqueList.append(partA[uniqueIndex[i]]); } partA.transfer(uniqueList); Info<< partA << endl; 7(3 6 9 2 10 7 5) Continued from the previous page. Generate (sorted) indices corresponding to unique list values 7(1 2 3 4 5 6 9) 11(3 1 4 1 5 9 2 6 5 3 5) 0 1 2 3 4 5 6 7 8 9 10 Index Create a list of unique values (remove duplicate values) PartA
  • 11. 11 I will continuously update this slide in the future. Kindly let me know if you have any ideas about what topics to cover.