ソース項の設定2012年5月13日 | |
はじめにソース項の設定について。 使用バージョンOpenFOAM 1.7.1/2.1.0 swak4Foamswak4Foam を使う。まず、ソルバーを修正する。たとえば icoFoam の場合、つぎのように修正する。 createFields.H に以下を追加。
expressionSource<vector> momentumSource
(
IOdictionary
(
IOobject
(
"momentumSourceDict",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
mesh
);
icoFoam.C に以下をのように修正。
#include "expressionSource.H"
...
fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
==
momentumSource()
);
...
if(runTime.write())
{
volVectorField momSrc = momentumSource();
momSrc.rename("momSrc");
momSrc.write();
}
Make/options にインクルードパス (swak4Foam のソース内) とライブラリパスを追加。
-I$(HOME)/build/swak4Foam-1.7/Libraries/swak4FoamParsers/lnInclude/ \
-I$(HOME)/build/swak4Foam-1.7/Libraries/swakSourceFields/lnInclude/
...
-L$(FOAM_USER_LIBBIN) \
-lswak4FoamParsers \
-lswakSourceFields
ソース項の設定はケースの constant/momentumSourceDict で行う。 constant/momentumSourceDict
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7.1 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object momentumSourceDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
variables (
"s=1e4;"
"xmin=0.045;"
"xmax=0.055;"
"ymin=0.045;"
"ymax=0.055;"
"direction=vector(0, 1, 0);"
);
expression "((xmin < pos().x && pos().x < xmax) && (ymin < pos().y && pos().y < ymax) ? s : 0)*direction";
dimensions [0 1 -2 0 0 0 0];
// ************************************************************************* //
上記は、ある範囲の Y 方向の流速を 0 にする例である。 OpenFOAM 2.1.0OpenFOAM 2.1.0 にはソース項設定のための仕組みが存在する。たとえば icoFoam でそれを使う場合、つぎのように修正する。 createFields.H
IObasicSourceList sources(mesh);
icoFoam.C
#include "IObasicSourceList.H"
...
tmp<fvVectorMatrix> UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
==
sources(U)
);
sources.constrain(UEqn());
Make/options
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools
上記の修正は、ソルバーによってはすでに行われている (simpleFoam など)。 ソース項の設定はケースの constant/sourcesProperties で行う。
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object sourcesProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
source1
{
type vectorExplicitSource;
active true;
timeStart 0;
duration 1;
selectionMode cellSet;
cellSet source;
vectorExplicitSourceCoeffs
{
volumeMode absolute;
injectionRate
{
U (0 1e-2 0);
}
}
}
セルセット source にソース項を設定している。swak4Foam の例に合わせたつもり。ソースの 1e-2 は、体積 1e-6 として 1e-6 * 1e-4 = 1e-2 か? | |
| PENGUINITIS | |