OpenFOAM手動網(wǎng)格分塊
1.?通過OpenFOAM的格式自編程來對各個cell命名,確定他們所屬的processor
/*---------------------------------------------------------------------------*\
??========= ????????????????|
??\\ ?????/ ?F ield ????????| OpenFOAM: The Open Source CFD Toolbox
???\\ ???/ ??O peration ????|
????\\ ?/ ???A nd ??????????| Copyright (C) 2011-2013 OpenFOAM Foundation
?????\\/ ????M anipulation ?|
-------------------------------------------------------------------------------
License
????This file is part of OpenFOAM.
?
????OpenFOAM is free software: you can redistribute it and/or modify it
????under the terms of the GNU General Public License as published by
????the Free Software Foundation, either version 3 of the License, or
????(at your option) any later version.
?
????OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
????ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
????FITNESS FOR A PARTICULAR PURPOSE. ?See the GNU General Public License
????for more details.
?
????You should have received a copy of the GNU General Public License
????along with OpenFOAM. ?If not, see <http://www.gnu.org/licenses/>.
?
Application
????scalar2Label
????codeBy CloudBird, HIT,cloudbird7@foxmail.com
?
\*---------------------------------------------------------------------------*/
?
#include?"fvCFD.H"
?
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
?
?
int?main(int?argc, char?*argv[])
{
????#include?"setRootCase.H"
????#include?"createTime.H"
????#include?"createMesh.H"
?
????const?volVectorField& center = mesh.C();
?
????labelIOList finalDecomp
????(
????????IOobject
????????(
????????????"manualDecomposition",
????????????mesh.facesInstance(),
????????????mesh,
????????????IOobject::NO_READ,
????????????IOobject::AUTO_WRITE,
????????????false
????????),
????????labelList (center.size())
????);
?
????Info<< "Making manualDecomposition file\n"?<< endl;
????scalar x_=0,y_=0;
label num0 = 0, num1 = 0, num2 = 0, num3 = 0;
//這里是將網(wǎng)格分為四塊,分塊的依據(jù)是下邊if的判斷語句,也就是先挖一個小方框出來,然后對剩下的部分分成三塊,并輸出分塊之后每一塊的cell的數(shù)量。
forAll(center, cellID)
????{
x_ = center[cellID].x();
y_ = center[cellID].y();
if?(x_ > -0.75 && x_ < 0.75 &&y_>-0.75&&y_ < 0.75)
{
finalDecomp[cellID] = 0;
num0++;
}
else
{
if?(x_ < 0)
{
finalDecomp[cellID] = 1;
num1++;
}
else?if?(x_ < 3)
{
finalDecomp[cellID] = 2;
num2++;
}
?
else
{
finalDecomp[cellID] = 3;
num3++;
}
}
?
????}
Info << "num0 = "?<< num0 << nl << "num1 = "?<< num1 << nl << "num2 = "?<< num2 << nl << "num3 = "?<< num3 << nl;
????finalDecomp.write();
?
????Info<< "Done\n"?<< endl;
?
????return?0;
}
?
?
// ************************************************************************* //
這樣會在constant文件夾下邊生成一個名為manualDecomposition的文件,這個文件本質(zhì)上是一個標(biāo)量文件,用于標(biāo)記各個cell所屬的processor。
?
2.?在system文件夾下的decomposeParDict中修改分割方式
numberOfSubdomains 4;
?
method ??????????manual;
?
manualCoeffs
{
????dataFile ???????"manualDecomposition";
}
其中dataFile的名字要改成我們生成的文件的名字,也就是maualDecomposition,還需要注意的一點是numberOfSubdomains的數(shù)量要和你在maulDecomposition中定義的數(shù)量一致。
?
3.之后直接decomposePar就是按照手動分割網(wǎng)格的方式對你定義的網(wǎng)格進(jìn)行分割。




文件的編譯按照一般OpenFOAM文件編譯的方式進(jìn)行,參考http://dyfluid.com/docs/book/_book/
參考文章:
https://blog.csdn.net/CloudBird07/article/details/105349031
https://www.dazhuanlan.com/2019/08/16/5d55fc7975c16/