OPENFOAM中有些后处理工具是否只能在计算时运行,计算完毕后无法运行?



  • 今天在一个算例算完之后试图用fieldAverage工具计算UMean,发现openfoam4.x中提供的模板是把它全部写在了controlDict文件下的functions下面了。。由于我已经计算完毕,所以在system下建了一个fieldAverage文件,controlDict下用#includeFunc fieldAverage挂载,如下:

         // Type of functionObject
            type            fieldAverage;
    
            // Where to load it from (if not already in solver)
            libs ("libfieldFunctionObjects.so");
    
            // Function object enabled flag
            enabled         true;
    
            // When to output the average fields
    	writeControl    adjustableRunTime;
    	writeInterval 0.001; 
    
            // Fields to be averaged - runTime modifiable
            fields
            (
    		U
    		{
    		mean        on;
                    prime2Mean  off;
                    base        time;
                    window      20; // 当设定window为一正整数w时,输出的时均值是当前时间步以及其之前w-1步,这w步内Field的时均值
    }
    	);
    

    而此时输入postProcess -func fieldAverage时会报这种错误(PS:采用#includeFunc挂载的方式即使边算边输出也会出现这个错误):

    --> FOAM FATAL IO ERROR: 
    wrong token type - expected word, found on line 18 the punctuation token '{'
    
    file: /home/dyfluid/tutorials/incompressible/pimpleFoam/pitzDaily/system/fieldAverage.fields at line 18.
    
        From function Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::word&)
        in file primitives/strings/word/wordIO.C at line 74.
    
    FOAM exiting
    
    

    看上去是说U后面不应该是{ ,但事实上,openfoam给出的模板里这个地方就是这么写的,并且我把system下面的fieldAverage文件中的code复制到controlDict下面,边算边处理的话,完美运行。。但是如果再用postProcess -func fieldAverage的方式,这段程序不会被运行,原因是:

    --> FOAM Warning : 
        From function static bool Foam::functionObjectList::readFunctionObject(const Foam::string&, Foam::dictionary&, Foam::HashSet<>&, const Foam::word&)
        in file db/functionObjects/functionObjectList/functionObjectList.C at line 245
        Cannot find functionObject file fieldAverage
    
    

    那么,是否表明这个后处理工具不能在计算完成后运行?:xinlei:
    如果可以,那应该怎么做呢。。
    跪求大神指教!



  • 你试试下面这个

    functions
    {
        fieldAverage1
        {
            type            fieldAverage;
            libs ( "libfieldFunctionObjects.so" );
            writeControl    writeTime;
     	timeStart             3;
            timeEnd               10;
            resetOnOutput     false;
            fields
            (
                U.water
                {
                     mean        on;
                     prime2Mean  off;
                     base        time;
                }
            );
        }
    }
    


  • @东岳 东岳前辈,这样貌似没有用,还是之前的错误



  • 请问您现在这个问题搞明白了吗?



  • 不清楚,我贴的那个代码我用没错误啊
    @OF初学者周 你什么错误



  • @东岳 东岳前辈您好,现在的情况是程序(twoPhaseEulerFoam)已经运行结束,我想对整个床层计算孔隙率,在system文件下system下建了一个volFieldValue文件,controlDict下用#includeFunc volFieldValue挂载,运行postProcess -func volFieldValue后提示:
    --> FOAM Warning :
    From function static bool Foam::functionObjectList::readFunctionObject(const Foam::string&, Foam::dictionary&, Foam::HashSet<>&, const Foam::word&)
    in file db/functionObjects/functionObjectList/functionObjectList.C at line 278
    Cannot find functionObject file volFieldValue
    但是如果在controlDIct中按照上述您写的进行添加,并重新运行算例,可以得到想要的结果。
    所以问题是如果程序运行结束后,如何通过postProcess处理得到床层平均空隙率?


 

Forest
Mountains