如何看流场中的加速度云图?
-
@Yu_Tian 在createFields.H文件中,添加变量声明
volVectorField js ( IOobject ( "js", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), -sigma*fvc::grad(Ue) );
在求解完Ue后,更新一下js
js=-sigma*fvc::grad(Ue);
我一般这样通过求解器实现的。
也可以用postProcess实现,但是需要具体看一下他的源码,这个我不是很熟悉
放一个我之前写过的一个求边界“axis”上的最大速度,这个是参考之前版本的calc方法写的,后来calc全部整合到postProcess中了,但是在OpenFOAM 6里面,按照calc的思虑一样可以用#include "timeSelector.H" #include "calcType.H" void calc(const argList& args, const Time& runTime, const fvMesh& mesh) { IOobject UHeader ( "U", runTime.timeName(), mesh, IOobject::MUST_READ ); if (phiHeader.headerOk()) { volVectorField U(UHeader, mesh); forAll(U.boundaryField(), patchi) { const fvPatchVectorField & pU = U.boundaryField()[patchi]; const fvPatch & pU_B = pU.patch(); if(pU_B.name() == "axis") { Foam::Info<< "mag(U) max : " << max(mag(pU)).value() << Foam::endl; break; } } } else { Foam::Info<< "No U exists!" << Foam::endl; } Info<< "\nEnd\n" << endl; } int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); #include "createNamedMesh.H" forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Foam::Info<< "Time = " << runTime.timeName() << Foam::endl; mesh.readUpdate(); calc(args, runTime, mesh); Foam::Info<< Foam::endl; } Foam::Info<< "End\n" << Foam::endl; return 0; }
-
@史浩 好的,感谢史老师,还有一个问题想请教,就是前面跟您学习了在求解器里createFields.H额外定义了一个量(电场强度E)
Info<< "Reading field E\n" << endl; volVectorField E ( IOobject ( "E", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), -fvc::grad(Ue) );
,在求解器.c文件里补充了求解梯度的方程,
E = -fvc::grad(Ue);
这样在实例中0文件里添加了一个E的初始文件,
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 1.5-dev | | \\ / A nd | Web: http://www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volVectorField; location "0"; object E; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [1 1 -3 0 0 -1 0]; //kg*m*s^(-3)*A^(-1) internalField uniform (0 0 0); boundaryField { upWall { type zeroGradient; } downWall { type zeroGradient; } rightWall { type zeroGradient; } leftWall { type symmetryPlane; } frontAndBack { type empty; } } // ************************************************************************* //
还要不要在system中的fvSchemes和fvSolution对E做一些补充设置?比如下面这个
div(rho*phi,U) Gauss upwind;
E { solver smoothSolver; smoother GaussSeidel; tolerance 1e-08; relTol 0; nSweeps 1; }