CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

error with reduce in Parallel run

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By jherb
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 1, 2020, 05:28
Default error with reduce in Parallel run
  #1
Senior Member
 
Nguyen Duy Trong
Join Date: Apr 2014
Posts: 124
Rep Power: 12
ndtrong is on a distinguished road
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:

at ??:?
[2] #1 Foam::sigSegv::sigHandler(int) at ??:?
[2] #2 ? in /lib/x86_64-linux-gnu/libc.so.6
[2] #3 ? at ??:?
[2] #4 ? at ??:?
[2] #5 ? at ??:?
[2] #6 __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
[2] #7 ? at ??:?
[DESKTOP-1SJKL58:09310] *** Process received signal ***
[DESKTOP-1SJKL58:09310] Signal: Segmentation fault (11)
[DESKTOP-1SJKL58:09310] Signal code: (-6)
[DESKTOP-1SJKL58:09310] Failing at address: 0x3e80000245e
[DESKTOP-1SJKL58:09310] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20)[0x7f35a5abef20]
[DESKTOP-1SJKL58:09310] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f35a5abee97]
[DESKTOP-1SJKL58:09310] [ 2] /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20)[0x7f35a5abef20]
[DESKTOP-1SJKL58:09310] [ 3] CyinterFoam[0x4a3c54]
[DESKTOP-1SJKL58:09310] [ 4] CyinterFoam[0x4a416c]
[DESKTOP-1SJKL58:09310] [ 5] CyinterFoam[0x4511e6]
[DESKTOP-1SJKL58:09310] [ 6] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7f35a5aa1b97]
[DESKTOP-1SJKL58:09310] [ 7] CyinterFoam[0x454d1a]
[DESKTOP-1SJKL58:09310] *** End of error message ***
--------------------------------------------------------------------------
mpirun noticed that process rank 2 with PID 9310 on node DESKTOP-1SJKL58 exited on signal 11 (Segmentation fault).
--------------------------------------------------------------------------
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;
        }
    }
}
ndtrong is offline   Reply With Quote

Old   May 2, 2020, 20:13
Default
  #2
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21
jherb is on a distinguished road
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.
ndtrong likes this.
jherb is offline   Reply With Quote

Old   May 3, 2020, 21:11
Default
  #3
Senior Member
 
Nguyen Duy Trong
Join Date: Apr 2014
Posts: 124
Rep Power: 12
ndtrong is on a distinguished road
Quote:
Originally Posted by jherb View Post
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.
Dear Joachim

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?
ndtrong is offline   Reply With Quote

Old   May 4, 2020, 15:34
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by ndtrong View Post
Dear Joachim

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?

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
ndtrong likes this.
olesen is offline   Reply With Quote

Old   May 9, 2020, 17:02
Default
  #5
Senior Member
 
Nguyen Duy Trong
Join Date: Apr 2014
Posts: 124
Rep Power: 12
ndtrong is on a distinguished road
Quote:
Originally Posted by olesen View Post
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


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.
ndtrong is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 23:48.