|
[Sponsors] |
May 1, 2020, 05:28 |
error with reduce in Parallel run
|
#1 |
Senior Member
Nguyen Duy Trong
Join Date: Apr 2014
Posts: 124
Rep Power: 12 |
Hi everyone,
I am writing a sort code to compute angle of cylinder surface. It can run well in serial mode however, it show error when I run with parallel as: I have checked and the error maybe comes from using reduce operator, but I donot know how to correct it. Could someone help me. It is appreciate if you can correct me with this error. My source is as below. Thanks Code:
{ const polyBoundaryMesh& boundaryMesh = mesh.boundaryMesh();// boundary mesh forAll(mesh.boundary(), patch) { const word& patchName = mesh.boundary()[patch].name(); // Boundary patch name if(patchName == "hull") { const polyPatch& pp = boundaryMesh[patch]; // Info <<"size of pp = " <<pp.size() <<endl; vector hullCenter (0, 0.01, 0); scalar xHull = hullCenter.x(); scalar yHull = hullCenter.y(); // scalar zHull = hullCenter.z(); dimensionedScalar delX("delX", dimless, scalar(0)); dimensionedScalar delY("delY", dimless, scalar(0)); dimensionedScalar angle("angle", dimless, scalar(0)); scalarField alpha(pp.size(), 0.0); scalarField pressure(pp.size(), 0.0); forAll(mesh.boundary()[patch], facei) { const label& bCell = boundaryMesh[patch].faceCells()[facei]; // Boundary cellID const label& face = boundaryMesh[patch].start() + facei; // FaceID //get face coordinate scalar xF = pp.faceCentres()[facei].x(); scalar yF = pp.faceCentres()[facei].y(); // scalar zF = pp.faceCentres()[facei].z(); // to compute angle delX.value() = xF - xHull; delY.value() = yF - yHull; // scalar tan = delY/delX; angle = atan2(delY,delX); angle.value() = angle.value()*180/M_PI; // Pout <<"go here" <<endl; alpha[facei] = angle.value(); //to get presure value in current cell pressure [facei] = p[bCell];// } reduce(alpha, sumOp<scalarField>()); reduce(pressure, sumOp<scalarField>()); Info <<"alpha = " <<alpha <<endl; Info <<"pressure = " <<pressure <<endl; } } } |
|
May 2, 2020, 20:13 |
|
#2 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
A shot in the dark: Are you sure, that your files pressure and alpha have the right size? The are created with size pp.size() but used with facei (which loops over the size of the face fields).
Segmentation error means you try to access part of the memory which do not belong to the program. |
|
May 3, 2020, 21:11 |
|
#3 | |
Senior Member
Nguyen Duy Trong
Join Date: Apr 2014
Posts: 124
Rep Power: 12 |
Quote:
Thanks for your comment and suggestion. I have checked and found that they have same size of element since it works only on boundary path named as "hull". Do you have other idea? |
||
May 4, 2020, 15:34 |
|
#4 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40 |
Quote:
Joachim's point is that you should first check if the boundary patch "hull" has exactly the same number of faces on each processor. Even if they actually did have the exactly the same values for each processor, you should think about what you are actually asking the system to do. I can't really figure out what this could possibly mean. In many cases you want to sum all the values in a field (local to that processor) to create a single value (eg, a scalar) and than use sumOp to reduce that across all processors. But perhaps you need something else entirely - can't really tell from your code what are trying to do. /mark |
||
May 9, 2020, 17:02 |
|
#5 | |
Senior Member
Nguyen Duy Trong
Join Date: Apr 2014
Posts: 124
Rep Power: 12 |
Quote:
Thanks Mark for your suggestion. Finally I could do that by using list and gather operator, not sumOp. SumOp always give error while gatherList can do well. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
SimpleFoam cannot open include file | Marija | OpenFOAM Running, Solving & CFD | 1 | October 28, 2020 10:35 |
The problem when i use parallel computation for mesh deforming. | Hiroaki Sumikawa | OpenFOAM Running, Solving & CFD | 0 | November 20, 2018 02:58 |
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' | muth | OpenFOAM Running, Solving & CFD | 3 | August 27, 2018 04:18 |
Can not run OpenFOAM in parallel in clusters, help! | ripperjack | OpenFOAM Running, Solving & CFD | 5 | May 6, 2014 15:25 |
parallel Grief: BoundaryFields ok in single CPU but NOT in Parallel | JR22 | OpenFOAM Running, Solving & CFD | 2 | April 19, 2013 16:49 |