关于调用 PtrDictionary<phaseModel> 类储存的场的数据
-
自己顶一下,
个人认为,最好的方法应该是用 .db().lookupObject<volScalarField>("xxxxx") ,比如要求水的体积分数,就在括号在填"alpha.water"。但有时不知道物理量被命名为什么,也就是说不知道"xxxxx"该填什么,比如compressibleMultiphaseInterFoam中的密度,填"rho.water"是无效的,这种情况下,可以用下面的代码:Foam::tmp<Foam::volScalarField> Foam::multiphaseMixtureThermo::rho3() const { PtrDictionary<phaseModel>::const_iterator phasei = phases_.begin(); ++phasei; ++phasei; tmp<volScalarField> trho(phasei().thermo().rho()); //换成 tmp<volScalarField> talpha(phasei()); 也可以求体积分数alpha return trho; }
该代码是用来第3相密度的成员函数。如果想求第n相的话,就进行n-1次++phasei。调用该函数,即可返回密度。虽然方法比较丑陋,但确实能用。
不知道大家还有什么更好的方法? -
@李东岳 李老师我想请教一个问题,最近在多项欧拉Foam里植入了一个曳力模型,编译成功了但是求解动量方程的时候就会报错,我想请问这个报错的意思是我这pow函数没有用对吗?报错如下
PIMPLE: Iteration 1 MULES: Solving for alpha.air air fraction, min, max = 0.293333 0 1 MULES: Solving for alpha.air air fraction, min, max = 0.293333 0 1 Constructing momentum equations #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::sigFpe::sigHandler(int) at ??:? #2 ? in "/lib/x86_64-linux-gnu/libc.so.6" #3 ? in "/lib/x86_64-linux-gnu/libm.so.6" #4 powf64 in "/lib/x86_64-linux-gnu/libm.so.6" #5 Foam::pow(Foam::Field<double>&, Foam::UList<double> const&, double const&) at ??:? #6 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::pow<Foam::fvPatchField, Foam::volMesh>(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, Foam::dimensioned<double> const&) at ??:? #7 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::pow<Foam::fvPatchField, Foam::volMesh>(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, double const&) at ??:? #8 Foam::dragModels::bubbleDrag::CdRe() const at ??:? #9 Foam::dragModels::dispersedDragModel::Ki() const at ??:? #10 Foam::dragModels::dispersedDragModel::K() const at ??:? #11 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::BlendedInterfacialModel<Foam::dragModel>::evaluate<double, Foam::fvPatchField, Foam::volMesh>(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > (Foam::dragModel::*)() const, Foam::word const&, Foam::dimensionSet const&, bool) const at ??:? #12 Foam::blendedDragModel::K() const at ??:? #13 Foam::MomentumTransferPhaseSystem<Foam::phaseSystem>::momentumTransfer() at ??:? #14 Foam::PhaseTransferPhaseSystem<Foam::OneResistanceHeatTransferPhaseSystem<Foam::MomentumTransferPhaseSystem<Foam::phaseSystem> > >::momentumTransfer() at ??:? #15 ? in "/home/gzy/OpenFOAM/OpenFOAM-10/platforms/linux64GccDPInt32Opt/bin/multiphaseEulerFoam" #16 ? in "/lib/x86_64-linux-gnu/libc.so.6" #17 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" #18 ? in "/home/gzy/OpenFOAM/OpenFOAM-10/platforms/linux64GccDPInt32Opt/bin/multiphaseEulerFoam" Floating point exception (core dumped)
我目前的想法是在主函数里输出一下这些场,然后逐个排查下哪里出了问题,请问这些场该怎么调用呢?直接info+场名行不通,我不大清楚这样的语句要怎么写,麻烦您指导一下,非常感谢,例如
Foam::dragModels::bubbleDrag::bubbleDrag ( const dictionary& dict, const phaseInterface& interface, const bool registerObject ) : dispersedDragModel(dict, interface, registerObject), residualRe_("residualRe", dimless, dict) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::dragModels::bubbleDrag::~bubbleDrag() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::tmp<Foam::volScalarField> Foam::dragModels::bubbleDrag::CdRe() const { volScalarField TTT(interface_.continuous().thermo().T());:xiexie: TTT.dimensions().reset(dimless); const volScalarField g1(1-TTT/647); const volScalarField g2(max(g1, residualRe_)); const volScalarField g3(pow(g2, 0.98)); volScalarField ddd(interface_.dispersed().d()); ddd.dimensions().reset(dimless);