|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
createFields.H
//提示读入温度场
Info<< "Reading field T\n" << endl;
//温度场创建,标量场,需要初始化文件,下面各项具体含义,参看以前solver的说明
volScalarField T
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
//提示读入速度场
Info<< "Reading field U\n" << endl;
//速度场创建,各项意义,前面solver说明中已经给出
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
//读入参数提示
Info<< "Reading transportProperties\n" << endl;
//根据名字为transportProperties的参数文件构建参数字典,以便查找。
IOdictionary transportProperties
(
IOobject
(
"transportProperties",//参数字典文件名字
runTime.constant(),//参数字典文件位置
mesh, //网格对象
IOobject::MUST_READ,//需要读入文件
IOobject::NO_WRITE //不对文件进行重写
)
);
//查询参数字典提示
Info<< "Reading diffusivity D\n" << endl;
//参数字典查询,初始化带单位标量DT(温度扩散率)
dimensionedScalar DT
(
transportProperties.lookup("DT")
);
//创建表面流率场,该文件位于
//src » finiteVolume » cfdTools » incompressible
# include "createPhi.H"
scalarTransportFoam.C
#include "fvCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//主程序入口
int main(int argc, char *argv[])
{
//设置case目录相关,位于src » OpenFOAM » include
# include "setRootCase.H"
//创建time对象runTime,位于 src » OpenFOAM » include
# include "createTime.H"
//创建网格对象mesh,位于src » OpenFOAM » include
# include "createMesh.H"
//创建场对象,前面已经详述
# include "createFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//提示计算标量传输方程
Info<< "\nCalculating scalar transport\n" << endl;
//显示当前courant数,位于src » finiteVolume » cfdTools » incompressible
# include "CourantNo.H"
//计算主流程
for (runTime++; !runTime.end(); runTime++)
{
//显示当前时间(物理时间,非cpu耗时)
Info<< "Time = " << runTime.timeName() << nl << endl;
//读入simple算法控制参数,位于src » finiteVolume » cfdTools » general » include
# include "readSIMPLEControls.H"
//网格非正交循环
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
//构造并求解方程
solve
(
fvm::ddt(T) //非稳态项,隐式离散
+ fvm::div(phi, T) //对流项,隐式离散
- fvm::laplacian(DT, T) //扩散项,隐式离散
);
}
runTime.write(); //求解结果输出,由于采用了注册机制,所有AUTO_WRITE声明的变量,
//都会输出
}
Info<< "End\n" << endl; //提示程序结束
return(0); //返回0
}
转自OpenFOAM研究:http://blog.sina.com.cn/openfoamresearch
[ 本帖最后由 su_junwei 于 2009-5-2 18:31 编辑 ] |
|