源项类中的addSup函数是如何被调用的?



  • 在各种源项类的声明和实现中经常能看到addSup函数,功能为将源项加入到控制方程中,如在actuationDiskSource.H中:

     //- Source term to momentum equation
    virtual void addSup
     (
             fvMatrix<vector>& eqn,
             const label fieldi
     );
    

    那么请问这个addSup函数是在什么时候被调用的?找了很久没有找到。在网上查了一些资料,基本可以确定这个函数是在求解器形成U方程的时候被调用了,如在simpleFoam的UEqn.H中:

         tmp<fvVectorMatrix> tUEqn
         (
             fvm::div(phi, U)
           + MRF.DDt(U)
           + turbulence->divDevSigma(U)
          ==
             fvOptions(U)
         );
    

    大家都说fvOptions(U)就用到了addSup函数,可是这里addSup函数是如何被调用的?希望有大神能帮忙解答!


  • Linux讲师 OpenFOAM讲师

    这是在application里抓的,在src里抓能抓到更多,但是多是定义而不是使用。

    ./solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C:void Foam::fv::VoFSolidificationMeltingSource::addSup
    ./solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C:void Foam::fv::VoFSolidificationMeltingSource::addSup
    ./solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C:void Foam::fv::VoFSolidificationMeltingSource::addSup
    ./solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C:void Foam::fv::VoFSolidificationMeltingSource::addSup
    ./solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C:    addSup(eqn, fieldi);
    ./solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.H:            virtual void addSup(fvMatrix<scalar>& eqn, const label fieldi);
    ./solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.H:            virtual void addSup(fvMatrix<vector>& eqn, const label fieldi);
    ./solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.H:            virtual void addSup
    ./solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.H:            virtual void addSup
    
    


  • fvOptions是一个fv::options类型的一个对象,fv::options类继承自optionList类。
    optionList类中含有一个包含所有源项的指针列表PtrList<option> 。optionList类中对operator()进行了运算符重载,函数体中遍历调用PtrList<option>中的每一个addSup函数。
    相关函数体的定义在fvOptionListTemplates.C中。

     template<class Type>
     Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator()
     (
         GeometricField<Type, fvPatchField, volMesh>& field,
         const word& fieldName
     )
     {
         return source(field, fieldName, field.dimensions()/dimTime*dimVolume);
     }
     
    
     template<class Type>
     Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::source
     (
         GeometricField<Type, fvPatchField, volMesh>& field,
         const word& fieldName,
         const dimensionSet& ds
     )
     {
         checkApplied();
     
         tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds));
         fvMatrix<Type>& mtx = tmtx.ref();
     
         forAll(*this, i)
         {
             option& source = this->operator[](i);
     
             label fieldi = source.applyToField(fieldName);
     
             if (fieldi != -1)
             {
                 source.setApplied(fieldi);
     
                 if (source.isActive())
                 {
                     if (debug)
                     {
                         Info<< "Applying source " << source.name() << " to field "
                             << fieldName << endl;
                     }
     
                     source.addSup(mtx, fieldi);
                 }
             }
         }
     
         return tmtx;
     }
     
    


  • @Cr 原来是在这里啊,感谢感谢!


Log in to reply
 

CFD中文网 2016 - 2020 | 京ICP备15017992号-2