怎么获取边界上一点的压力值
-
可以,但是会比较乱七八糟。对于输出的功能,最好通过controlDict里面的function来调用,比如下面这些代码
functions { extraInfo { type coded; functionObjectLibs ("libutilityFunctionObjects.so"); name dummy; codeExecute #{ const volVectorField& U = mesh().lookupObject<volVectorField>("U"); Info<< "max U = " << max(mag(U)).value() << nl; const volScalarField& epsilon = mesh().lookupObject<volScalarField>("epsilon"); Info<< "min/max epslion = " << min(epsilon).value() << ", " << max(epsilon).value() << endl; const volScalarField& k = mesh().lookupObject<volScalarField>("k"); Info<< "min/max k = " << min(k).value() << ", " << max(k).value() << endl; const volScalarField& p = mesh().lookupObject<volScalarField>("p"); Info<< "min/max p = " << min(p).value() << ", " << max(p).value() << endl; #}; } }
-
这是我根据网上的模板修改的一个喷口边界条件(jet),喷口的速度随时间和空间位置变化,可以正常使用。请问一下,如果我想输出网格ID为faceI0的格心的压力,应该怎么实现呢? 再进一步,如果这个网格点不在jet边界上(比如在hump边界上),那么在这里可以获得该点的压力吗?
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 5.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volVectorField; location "11012"; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField uniform (0 0 0); boundaryField { backfront { type empty; } hump { type noSlip; } inlet { type timeVaryingMappedFixedValue; offset constant (0 0 0); value nonuniform List<vector> 216 (..... ) ; } jet { type codedFixedValue; name nouse; value (0 0 0); redirectType jeton; codeOptions #{ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude #}; codeInclude #{ #include "fvCFD.H" #include <cmath> #include <iostream> #}; code #{ const fvPatch& boundaryPatch = patch(); const vectorField& Cf = boundaryPatch.Cf(); vectorField& field = *this; const scalar pi = constant::mathematical::pi; scalar x0=0.654157, z0=0.115013, d=0.004554; scalar umax=26.6, fjet=138.5; scalar theta = 18.31163/pi; forAll(Cf, faceI) { scalar x = Cf[faceI].x(); scalar z = Cf[faceI].z(); scalar t = this->db().time().value(); scalar kesi = pow( (x-x0)*(x-x0)+(z-z0)*(z-z0),0.5); scalar ujmag = 6*umax*( (kesi/d)-pow(kesi/d,2) )*sin(2*pi*fjet*t); scalar ujet = ujmag*sin(theta); scalar vjet = ujmag*cos(theta); field[faceI] = vector(ujet,0,vjet); } #}; } lowWall { type noSlip; } outlet { type zeroGradient; } top { type zeroGradient; } }