@李东岳 这台电脑的CPU有点年头了,虽然支持4通道,但是插了两条内存。
huiCfd
帖子
-
200万网格并行算力测试(OpenFOAM版本) -
200万网格并行算力测试(OpenFOAM版本)CPU型号: Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz 系统:Linux mint 19.3 版本:openfoam-6 # cores Wall time (s): ------------------------ 8 552.63 4 623.67 2 814.52 1 1419.05
-
并行时函数只能在processor0执行@东岳 感谢东岳老师回复,请问应该用何种循环 才能在并行时 对所有的cell进行计算呢?
因为并行计算时,函数只在第一个processor里面的domain进行了循环,而所求观测点不在第一个processor的domain里,所以该函数无法返回符合要求的速度。如果要让该函数在其他proessor下也进行循环的话我应该如何修改?或者我应该看哪方面的资料来解决这个问题。
谢谢 -
并行时函数只能在processor0执行processor零,不是o。因为字体原因,0和o看起来很像。
-
并行时函数只能在processor0执行Hello,各位大神,
我在用我自己写的一个求解器并行计算时出现了一个奇怪的问题。这个问题只有在并行计算的时候才会出来,当不并行时没事。问题的具体描述如下:
在我的solver中有一个名为 updateVelocity 的成员函数来获取计算域中某观察点(这个观察点的位置可能会随着时间改变)的速度。
具体如下:while (runTime.loop()) { Info << "Time = " << runTime.timeName() << nl << endl; #include "CourantNo.H" // Pressure-velocity PISO corrector { #include "UEqn.H" // --- PISO loop while (piso.correct()) { #include "pEqn.H" } } laminarTransport.correct(); turbulence->correct(); //>>>>>>>>>>>>>Below>>>>>>> Nettings.updateVelocity(U,mesh); //<<<<<<<<<<<<<Above<<<<<< runTime.write(); Info << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info << "End\n" << endl; return 0; }
这个函数的源代码如下,具体实现形式就是判断每个cell的中心到观察点的距离,然后取出距离观察点距离最近的cell的速度
void Foam::netPanel::updateVelocity( const volVectorField &U, const fvMesh &mesh) { const vectorField ¢res(mesh.C()); List<vector> fluidVelocities(structuralElements_memb.size(), vector::zero); Info << "In updateVelocity, number of mesh is " << centres.size() << endl; Info << "In updateVelocity, number of U is " << U.size() << endl; scalar maxDistance(1); forAll(EPcenter, Elemi) { maxDistance = 1; vector nearestCell(vector::zero); scalar loops(0); forAll(centres, cellI) // loop through all the cells, { scalar k1(calcDist(centres[cellI], EPcenter[Elemi])); if (k1 < maxDistance) { maxDistance = k1; fluidVelocities[Elemi] = U[cellI]; nearestCell = centres[cellI]; loops += 1; Info << "After " << loops << " times of loop, the nearest cell is " << nearestCell << "to point " << EPcenter << "\n" << endl; } } } fluidVelocity_memb = fluidVelocities; // only assige onece Info << "the velocity on nodes are " << fluidVelocity_memb << endl; }
就是这样的一个简单的函数,但是在并行时却出现了问题。
首先我们来看串行计算的情况:Starting time loop Time = 0.01 Courant Number mean: 0.000565 max: 0.0904 smoothSolver: Solving for Ux, Initial residual = 1, Final residual = 2.4007e-06, No Iterations 1 smoothSolver: Solving for Uy, Initial residual = 0.891308, Final residual = 1.23902e-06, No Iterations 1 smoothSolver: Solving for Uz, Initial residual = 0.895257, Final residual = 1.31102e-06, No Iterations 1 GAMG: Solving for p, Initial residual = 1, Final residual = 8.40918e-07, No Iterations 35 time step continuity errors : sum local = 9.50237e-10, global = 1.27782e-10, cumulative = 1.27782e-10 smoothSolver: Solving for epsilon, Initial residual = 1, Final residual = 0.00445555, No Iterations 1 smoothSolver: Solving for k, Initial residual = 1, Final residual = 0.004493, No Iterations 1 In updateVelocity, number of mesh is 184320 In updateVelocity, number of U is 184320 After 1 times of loop, the nearest cell is (-0.49375 -0.21875 -0.39375)to point (0 0.05 -0.1) ... ... After 45 times of loop, the nearest cell is (-0.00625 0.05625 -0.20625)to point (0 0.05 -0.2) the velocity on nodes are 4((0.226059 -2.8946e-08 -3.59708e-08) (0.226059 3.97379e-08 -4.07855e-08) (0.226059 2.65165e-08 -2.22689e-08) (0.226059 -4.12251e-08 -1.8172e-08)) ExecutionTime = 2.31 s ClockTime = 2 s
计算的结果没有任何问题,上面的updateVelocity函数也能够顺利的找到4个特定观察点的速度。
但是问题来啦,如果并行计算的话,updateVelocity就没法找到这4个特定观察点的速度了。
Starting time loop Time = 0.01 Current Number means: 0.000565 max: 0.0904 smoothSolver: Solving for Ux, Initial residual = 1, Final residual = 2.4007e-06, No Iterations 1 smoothSolver: Solving for Uy, Initial residual = 0.892185, Final residual = 1.24606e-06, No Iterations 1 smoothSolver: Solving for Uz, Initial residual = 0.895991, Final residual = 1.31577e-06, No Iterations 1 GAMG: Solving for p, Initial residual = 1, Final residual = 9.93486e-07, No Iterations 34 time step continuity errors : sum local = 1.12264e-09, global = -1.18173e-10, cumulative = -1.18173e-10 smoothSolver: Solving for epsilon, Initial residual = 1, Final residual = 0.0107252, No Iterations 1 smoothSolver: Solving for k, Initial residual = 1, Final residual = 0.0106817, No Iterations 1 In updateVelocity, number of mesh is 23177 In updateVelocity, number of U is 23177 the velocity on nodes are 4{(0 0 0)} ExecutionTime = 0.57 s ClockTime = 1 s
并行和串行用的是同统一套网格,并行是用 scotch方法分成了八个subdomains
值得注意的是:
在串行计算中:In updateVelocity, number of mesh is 184320
在并行计算中:In updateVelocity, number of mesh is 23177
其中23177就是在processor0中的cell数,下面的是在processor0内的U文件FoamFile { version 2.0; format ascii; class volVectorField; location "0.1"; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField nonuniform List<vector> 23177 ( (0.225112 5.13224e-05 2.5452e-05)
也就是说,在并行时这个函数只读入梁processor0里面的速度和网格,其他processor1、2、3... 均没有放进来。
请问各位大神有没有人遇到过类似的情况?
-
关于读取文件的错误问题解决了。将1.0 改为dimless,就可以啦。
具体可以参考这里 -
关于读取文件的错误@东岳 请问是指的openfoam 的编译问题吗?我注意到在程序开始的时候有一个warning,师兄说一般warning都没啥事。但是我看这个warning也是跟IO的控制相关的。感觉有可能在这里就有问题了。
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time --> FOAM Warning : From function static Foam::IOstreamOption::compressionType Foam::IOstreamOption::compressionEnum(const Foam::word&) in file db/IOstreams/IOstreams/IOstreamOption.C at line 86 Unknown compression specifier 'uncompressed', assuming no compression Create mesh for time = 0 PISO: Operating solver in PISO mode
-
关于读取文件的错误各位大神好,
在运行我自己写的solver时,遇到了一个关于读取文件的问题。我需要在一开始的creatField 时,根据我具体的研究对象,写一个名字为 porosityField的volScalarField到"0" 文件夹。我的具体代码如下:
Info<< "Before read porosity field " << "\n" << endl; volScalarField porosityField ( IOobject ( "porosityField", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, //NO_READ, IOobject::AUTO_WRITE ), mesh, 1.0 ); Info<< "After read porosity field " << "\n" << endl; //- update the porosity field porousZones.updatePoroField(porosityField, mesh); //- write the porosity field porosityField.write();
当运行的时候出现了如下的错误:
Before read porosity field --> FOAM FATAL ERROR: cannot find file "/home/hui/OpenFOAM/hui-v1906/run/Te1/0/porosityField" From function virtual Foam::autoPtr<Foam::ISstream> Foam::fileOperations::uncollatedFileOperation::readStream(Foam::regIOobject&, const Foam::fileName&, const Foam::word&, bool) const in file global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C at line 548. FOAM exiting
根据错误信息可以看出,这一行“Info<< "After read porosity field " << "\n" << endl;” 还没有运行到。所以就是这个读入这个文件的错误,我将 IOobject::READ_IF_PRESENT, 改为IOobject::NO_READ 后再次尝试,但是给出的是同样的错误信息。另外mesh后面的那个1 .0是默认值,去掉后再编译运行也是跟上面同样错误信息。
然而根据这一页的openfoamwiki , 我这样生成的volScalarField 应该没有问题。而且如果用READ_IF_PRESENT 或者NO_READ ,不应该给出找不到文件的错误提示。
- MUST_READ – The object must be read from Istream on construction. An error message is produced if Istream does not exist or can't be read.
- READ_IF_PRESENT – It reads the object from Istream if Istream exists, otherwise doesn't. An error message is produced only if Istream exists but can't be read.
- NO_READ – Don't read the object.
不知道大家有没有类似的经验,帮忙解决一下。
在此提前感谢! -
关于OpenFOAM的输入输出@nbyjn hello,我最近也在做这样一件事,将参数传入到求解器。 我想将一个矩阵[100*3]左右的数据传入,不知道您这里可以给我一些提示吗?
-
编译自己的求解器遇到问题“undefined reference”@wwzhao 非常感谢指点迷津!
-
编译自己的求解器遇到问题“undefined reference”@huiCfd 可能这个适用于of1906
-
编译自己的求解器遇到问题“undefined reference”@wwzhao
成功了啊! 非常感谢。。
是不可以总结如下经验:- 自己编写的类在编译时一定要以lib开头,
- 然后在编译主程序时,$(FOAM_USER_LIBBIN)后面不能有换行符,
- -l之后直接跟自己编译的东西但是要去掉lib
-
编译自己的求解器遇到问题“undefined reference”@wwzhao 是的,去掉何不去掉都试过了,
去掉后显示的错误是-lm -o /home/hui/OpenFOAM/hui-v1906/platforms/linux64GccDPInt32Opt/bin/dynaPorousNetFoam /usr/bin/ld: cannot find -llibnetPanel collect2: error: ld returned 1 exit status /opt/OpenFOAM/OpenFOAM-v1906/wmake/makefiles/general:140: recipe for target '/home/hui/OpenFOAM/hui-v1906/platforms/linux64GccDPInt32Opt/bin/dynaPorousNetFoam' failed make: *** [/home/hui/OpenFOAM/hui-v1906/platforms/linux64GccDPInt32Opt/bin/dynaPorousNetFoam] Error 1
没去掉的话跟原来的错误一样,都是undefined reference
-
编译自己的求解器遇到问题“undefined reference”@wwzhao 不行。。
-
编译自己的求解器遇到问题“undefined reference”@wwzhao
定义也是有的。如下Foam::netPanel::netPanel ( const dictionary& netDict ) : // initial components netDict_(netDict), porousPropertiesDict_(netDict_.subDict("porousProperties")), porosity_(readScalar(porousPropertiesDict_.lookup("porosity"))), thickness_(readScalar(porousPropertiesDict_.lookup("halfthickness"))) // D_(readVector(porousPropertiesDict_.lookup("D"))), // initial as zeros // F_(readVector(porousPropertiesDict_.lookup("D"))) // initial as zeros { dimensionedVector D_(porousPropertiesDict_.lookup("D")); dimensionedVector F_(porousPropertiesDict_.lookup("F")); }
-
编译自己的求解器遇到问题“undefined reference”@huiCfd
这个函数后面的const 是用来保护类的成员数据不发生改变。 -
编译自己的求解器遇到问题“undefined reference”@wwzhao 赵教授,这两个函数我记得定义了,
// Constructors netPanel ( const dictionary& netDict ); //- Destructor ~netPanel();
但是我有一点不太明白,为什么有的函数后面有一个const,有的没有。例如:
这个虚函数是void funname() const;void addResistance ( fvVectorMatrix& UEqn, const volScalarField& nu, const fvMesh& mesh, const matrix& structuralPositions, const matrix& structuralElements )const;
而这个函数是 bool funname(); 就没有const了。
bool isInPorousZone ( const point x, const volVectorField& structuralPositions, const vector& structuralElementi );
const 在括号里面我知道是可以保证传入的参数不变,但是在外边是啥意思啊?
-
编译自己的求解器遇到问题“undefined reference”@东岳 感谢东岳老师回复,我又看了一下错误提示,出现问题的都是我写的虚函数。
-
编译自己的求解器遇到问题“undefined reference”我在想是不是 我的这个option里买有格式错误。
我试过将EXE_LIBS = \ -L$(FOAM_USER_LIBBIN)\ -lnetPanel \
改为
EXE_LIBS = \ -L$(FOAM_USER_LIBBIN) -lnetPanel \
结果感觉更错啦
-lm -o /home/hui/OpenFOAM/hui-v1906/platforms/linux64GccDPInt32Opt/bin/dynaPorousNetFoam /usr/bin/ld: cannot find -lnetPanel collect2: error: ld returned 1 exit status /opt/OpenFOAM/OpenFOAM-v1906/wmake/makefiles/general:140: recipe for target '/home/hui/OpenFOAM/hui-v1906/platforms/linux64GccDPInt32Opt/bin/dynaPorousNetFoam' failed make: *** [/home/hui/OpenFOAM/hui-v1906/platforms/linux64GccDPInt32Opt/bin/dynaPorousNetFoam] Error 1
-
编译自己的求解器遇到问题“undefined reference”@yfclark
这个function, 我已经写到我的class中了,但是问题是在编译求解器时遇到问题“undefined reference”void Foam::netPanel::addResistance ( fvVectorMatrix& UEqn, const volScalarField& nu, const fvMesh& mesh_, const volVectorField& structuralPositions, const volVectorField& structuralElements ) { const vectorField& centres(mesh_.C()); forAll(structuralElements,Elementi) { dimensionedTensor d_(tensor::zero); dimensionedTensor f_(tensor::zero); transformCoeffs(D_,d_,structuralPositions,structuralElements[Elementi]); transformCoeffs(F_,f_,structuralPositions,structuralElements[Elementi]); tensor& dvalue = d_.value(); tensor& fvalue = f_.value(); const scalarField V = mesh_.V(); vectorField& Usource = UEqn.source(); const vectorField& U = UEqn.psi(); forAll(centres, cellI) { if(isInPorousZone(centres[cellI],structuralPositions,structuralElements[Elementi])) { tensor dragCoeff = nu[cellI]*dvalue + 0.5*mag(U[cellI])*fvalue; Usource[cellI] -=V[cellI]*dragCoeff & (U[cellI] ); } } } }