关于lagrangian求解器里preEvolve()的实现
-
在研究sprayFoam求解器整个运行机制的时候,遇到了这样一个问题,
在KinematicCloud.C中运行了这样一句话:functions_.preEvolve();
而functions_是CloudFunctionObjectList<KinematicCloud<CloudType>>这个类的数据成员。那么在CloudFunctionObjectList类中,preEvolve函数被下面语句定义。
template<class CloudType> void Foam::CloudFunctionObjectList<CloudType>::preEvolve() { forAll(*this, i) { this->operator[](i).preEvolve(); } }
在这里有两个疑问:
1.关于operator[]重载的说明:首先,this指针指向了functions_对象,属于类CloudFunctionObjectList,而类CloudFunctionObjectList继承于PtrList,PtrList继承于UPtrList,故调用了UPtrList里的operator函数。那么this->operator.preEvolve()就等价于functions_[i].preEvolve()(但这里的operator[](cosnt label i)不是virtual,而是inline,这样子类CloudFunctionObjectList可以调用UPtrList的operator吗?)
template<class T> inline const T& Foam::UPtrList<T>::operator[](const label i) const { if (!ptrs_[i]) { FatalErrorInFunction << "hanging pointer at index " << i << " (size " << size() << "), cannot dereference" << abort(FatalError); } return *(ptrs_[i]); }
请问这样理解正确吗?
2.this->operator.preEvolve();里的preEvolve()函数又在执行哪个preEvolve()函数呢?
this->operator.preEvolve()就等价于functions_[i].preEvolve(),在调用KinematicCloud的对象时会调用KinematicCloud的构造函数,实现对functions_的初始化,通过初始化的结果选择用哪个preEvolve函数
template<class CloudType> Foam::KinematicCloud<CloudType>::KinematicCloud ( const word& cloudName, const volScalarField& rho, const volVectorField& U, const volScalarField& mu, const dimensionedVector& g, bool readFields ) : CloudType(rho.mesh(), cloudName, false), kinematicCloud(), cloudCopyPtr_(nullptr), mesh_(rho.mesh()), particleProperties_ ( IOobject ( cloudName + "Properties", // 若为sprayFoam的程序,则为sprayCloudProperties rho.mesh().time().constant(), rho.mesh(), IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ), outputProperties_ ( IOobject ( cloudName + "OutputProperties", mesh_.time().timeName(), "uniform"/cloud::prefix/cloudName, mesh_, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ) ), solution_(mesh_, particleProperties_.subDict("solution")), constProps_(particleProperties_), subModelProperties_ ( particleProperties_.subOrEmptyDict("subModels", solution_.active()) ), ... functions_ ( *this, particleProperties_.subOrEmptyDict("cloudFunctions"), // 通常在*CloudProperties文件最下面,会有cloudFunctions{}的内容,functions_则读取里面的信息 solution_.active() ),
但经搜索,在lagrangian/intermediate/submodels/CloudFunctionObjects/文件夹下只有VoidFraction,ParticleTrap,ParticleTracks,ParticleErosion这几个类里定义了preEvolve函数,而of自带tut里并非只用到了这几个fucntion,例如在lagrangian/reactingParcelFoam/verticalChannelLTS/constant/reactingCloud1Properties里,既有particleTracks1,又有patchPostProcessing1,那么patchPostProcessing1是如何实现的呢?