编写一个只提供边界条件即可以监测受力大小的函数
-
请教大家一个编程问题,如何将这个监测受力的文件编写成一个函数,并且只提供边界名称作为参数,以后受力监测只需要调用该函数,并且提供边界名称即可,希望能得到大家的帮助。
forces_object { type forces; functionObjectLibs ("libforces.so"); //writeControl outputTime; writeControl timeStep; writeInterval 1; //// Patches to sample //patches ("body1" "body2" "body3"); patches ("cylinder"); //// Name of fields pName p; Uname U; //// Density rho rhoInf; rhoInf 1.; //// Centre of rotation CofR (0 0 0); }
-
@BlookCFD 解决了,受到下面代码的启发,即重复利用代码,更新边界名称即可
p { solver GAMG; tolerance 1e-6; relTol 0; smoother GaussSeidel; nPreSweeps 0; nPostSweeps 2; cacheAgglomeration on; agglomerator faceAreaPair; nCellsInCoarsestLevel 100; mergeLevels 1; } pFinal { $p; relTol 0; } 最后的要实现结果如下图: forceCoeffs_object { // rhoInf - reference density // CofR - Centre of rotation // dragDir - Direction of drag coefficient // liftDir - Direction of lift coefficient // pitchAxis - Pitching moment axis // magUinf - free stream velocity magnitude // lRef - reference length // Aref - reference area type forceCoeffs; functionObjectLibs ("libforces.so"); //patches ("body1" "body2" "body3"); patches (C0); pName p; Uname U; rho rhoInf; rhoInf 1.0; //// Dump to file log true; CofR (0.0 0 0); liftDir (0 1 0); dragDir (1 0 0); pitchAxis (0 0 1); magUInf 1.0; lRef 1.0; // reference lenght for moments!!! Aref 2.0; // reference area 1 for 2d writeControl timeStep; writeInterval 1; } //监测新的边界条件,只需要重复利用代码,更新边界名称即可 C1 { $forceCoeffs_object patches (C1); }