模型报错: `request for surfaceScalarField phi...failed`
-
各位老师好,我最近在尝试定义一个新的边界条件,结合
timeVaryingMappedFixedValue
和inletOutelt
边界。在每个时间步对边界插值赋值之后,再根据边界上的通量判断入流/出流,将出流的区域设置zeroGradient,而入流区域仍采用插值结果。下面是我参考inletOutlet边界文件修改的updateCoeffs()函数:
template<class Type> void Foam::timeVaryingInletOutletFvPatchField<Type>::updateCoeffs() { if (this->updated()) { return; } this->operator==(fieldMapper_.map()); // 拷贝于‘inletOutlet’边界源文件,用于判断方向并对系数赋值 const Field<scalar>& phip = this->patch().template lookupPatchField<surfaceScalarField, scalar> ( phiName_ ); this->valueFraction() = 1.0 - pos0(phip); // fixedValueFvPatchField<Type>::updateCoeffs(); }
新的边界条件能够成功编译。但在进行测试case(pimpleFoam)时,会在
decomposePar
分解并行区域步骤报错(直接进行单核计算也会出现相同错误):--> FOAM FATAL ERROR: request for surfaceScalarField phi from objectRegistry region0 failed available objects of type surfaceScalarField are 0() From function const Type& Foam::objectRegistry::lookupObject(const Foam::word&) const [with Type = Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>] in file /home/gareth/OpenFOAM/OpenFOAM-8/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 211.
以下是
objectRegistryTemplates.C
文件的对应内容:FatalErrorInFunction << nl << " request for " << Type::typeName << " " << name << " from objectRegistry " << this->name() << " failed\n available objects of type " << Type::typeName << " are" << nl << names<Type>(); if (cacheTemporaryObject(name)) { FatalErrorInFunction << nl << " request for " << name << " from objectRegistry " << this->name() << " to be cached failed" << nl << " available temporary objects are" << nl << temporaryObjects_; } FatalErrorInFunction // line 211 << abort(FatalError); // line 212 } return NullObjectRef<Type>();
根据错误信息,似乎是没有找到
surfaceScalarField
类型的对象phi
,但我只是结合inletOutlet
边界,对原始的timeVaryingMappedFixedValue
边界代码进行修改,并未改变其他源代码部分。并且我检查了求解器createFields.H
,包含对通量phi
的创建。所以我很困惑这个问题是如何产生的?我是刚开始接触OpenFOAM的源代码,可能犯了一些愚蠢的错误。希望各位大佬能对该问题给出一些建议。 谢谢!