求解器adv121Foam.C
/*---------------------------------------------------------------------------*\
Changed from scalarTransportFoam to adv121Foam
Application
adv121Foam
Description
Solves training examples 1.2.1 problem.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "fvOptions.H"
#include "simpleControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createMesh.H"
simpleControl simple(mesh);
#include "createFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nCalculating scalar transport\n" << endl;
#include "CourantNo.H"
while (simple.loop(runTime))
{
Info<< "Time = " << runTime.timeName() << nl << endl;
while (simple.correctNonOrthogonal())
{
fvScalarMatrix TEqn
(
fvm::ddt(T)
+ fvm::div(phi, T)
==
fvOptions(T)
);
TEqn.relax();
fvOptions.constrain(TEqn);
TEqn.solve();
fvOptions.correct(T);
}
runTime.write();
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //
createFields.H
Info<< "Reading field T\n" << endl;
volScalarField T
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading transportProperties\n" << endl;
IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
Info<< "Reading diffusivity DT\n" << endl;
dimensionedScalar DT
(
transportProperties.lookup("DT")
);
const scalar pi(M_PI);
using std::sin;
forAll(T,celli)
{
scalar xx = mesh.C()[celli].x();
scalar yy = mesh.C()[celli].y();
T[celli] = sin(2*pi*(xx+yy));
}
T.correctBoundaryConditions();
T.write();
#include "createPhi.H"
#include "createFvOptions.H"
算例blockMeshDict
adv121Foam求解器解析

本文介绍了一个名为adv121Foam的求解器,该求解器用于解决训练示例1.2.1问题,并详细展示了其源代码实现,包括主要的计算流程和边界条件设置。
最低0.47元/天 解锁文章
813

被折叠的 条评论
为什么被折叠?



