CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Parcel parallel and myProcNo problem (https://www.cfd-online.com/Forums/openfoam-programming-development/152197-parcel-parallel-myprocno-problem.html)

wenxu April 24, 2015 20:49

Parcel parallel and myProcNo problem
 
Dear Foamers,

Now I have a problem about parallel, could anyone be so kind to help me?

I want to statistic the particle's velocity in solver with parallel. However, it seems that the solver is calculated only with master processor. That's means the parcels are distributed at different processors but only some of them on the master processor. So how can I gather all of the parcels from different processors and statistics them? For example:

Quote:

label Nparcels=coalParcels.nParcels();
IDLList<coalParcel>::iterator iter=coalParcels.begin();
In fact, there are 100000 parcels in the computational domain, but when I use two processors, then only half of them can be statistics which are in the master processor. Corresponding to the code: Nparcels = 0.5 * total parcel number. (two processors)

Could anyone give me some hints?

Thank you very much!

Best regards,
Wen Xu

wenxu April 24, 2015 22:15

Briefly, how to gather all of the parcels from different processors to a single parcel List in Solver?

regards,
Xu

wenxu April 25, 2015 21:09

http://www.cfd-online.com/Forums/ope...rocessors.html

This may help.

wenxu April 25, 2015 21:38

myProcNo problem
 
Dear Foamers,

Why the output of UPstream::myProcNo() is always equal to zero even if I use 4 processors? I assume the output should be 0,1,2 then 3, then recycle this list.


Anyone can give me some hints?

Thank you in advance!

Regards,
Wen Xu

wyldckat April 26, 2015 14:12

Quick answer: Have a look into the source code folder "applications/test/parallel".
In addition, see this post: http://www.cfd-online.com/Forums/ope...tml#post378825 - post #2

jherb April 28, 2015 13:03

If you use Info<< to print out the processor number it is only printed on the first processor. Use cout<< to print it on all processors.

wenxu April 28, 2015 21:26

Thank you both Bruno and Joachim. You really help me a lot!

I have look into the test case in /application/test/parallel and already know a little about parallel.

Pout can print out the Inter-processor communications, so use "Pout<<" is a good choice to print the details of the processors communications.

I follow this method and print out the parcels number in every processor, the code like this:
Quote:

vector myVector(vector::one);
reduce(myVector, sumOp<vector>());
Pout<<"myVector: "<<myVector<<endl;
Pout<<"my processor number: "<<UPstream::myProcNo()<<endl;

label Nparcels=coalParcels.nParcels();
IDLList<coalParcel>::iterator iter=coalParcels.begin();
labelList parcelsList(Nparcels);
Pout<<"parcels number: "<<Nparcels<<endl;
Pout<<"parcels total number: "<<returnReduce(coalParcels.nParcels(), sumOp<label>())<<endl;
And the corresponding output like this:
Quote:

[1] myVector: (4 4 4)
[1] my processor number: 1
[3] myVector: (4 4 4)
[3] my processor number: 3
[2] myVector: (4 4 4)
[0] myVector: (4 4 4)
[0] my processor number: 0
[2] my processor number: 2
[0] parcels number: 1098
[1] parcels number: 1787
[2] parcels number: 2595
[3] parcels number: 3554
[1] parcels total number: 9034
[0] parcels total number: 9034
[2] parcels total number: 9034
[3] parcels total number: 9034
But how can I get every parcel's information?
Both
Quote:

Pstream::gatherList(coalParcels)
Note: coalParcels is the object of ReactingMultiPhaseCloud
and
Quote:

List<IDLList<coalParcel> > gatheredParcel(Pstream::nProcs());
gatheredParcel[Pstream::myProcNo()] = coalParcels;
Pstream::gatherList(gatheredParcel);
do not work for me.

Thank you again!

Regards,
Wen Xu

wenxu April 28, 2015 22:16

The error output like this:
Code:

/opt/openfoam230/src/OpenFOAM/lnInclude/INew.H: In member function 'Foam::autoPtr<T> Foam::INew<T>::operator()(Foam::Istream&) const [with T = Foam::ReactingMultiphaseParcel<Foam::ReactingParcel<Foam::ThermoParcel<Foam::KinematicParcel<Foam::particle> > > >]':
/opt/openfoam230/src/OpenFOAM/lnInclude/ILListIO.C:58:21:  instantiated from 'void Foam::ILList<LListBase, T>::read(Foam::Istream&, const INew&) [with INew = Foam::INew<Foam::ReactingMultiphaseParcel<Foam::ReactingParcel<Foam::ThermoParcel<Foam::KinematicParcel<Foam::particle> > > > >, LListBase = Foam::DLListBase, T = Foam::ReactingMultiphaseParcel<Foam::ReactingParcel<Foam::ThermoParcel<Foam::KinematicParcel<Foam::particle> > > >]'
/opt/openfoam230/src/OpenFOAM/lnInclude/ILListIO.C:151:5:  instantiated from 'Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::ILList<LListBase, T>&) [with LListBase = Foam::DLListBase, T = Foam::ReactingMultiphaseParcel<Foam::ReactingParcel<Foam::ThermoParcel<Foam::KinematicParcel<Foam::particle> > > >]'
/opt/openfoam230/src/OpenFOAM/lnInclude/gatherScatterList.C:103:17:  instantiated from 'static void Foam::Pstream::gatherList(const Foam::List<Foam::UPstream::commsStruct>&, Foam::List<T>&, int, Foam::label) [with T = Foam::IDLList<Foam::ReactingMultiphaseParcel<Foam::ReactingParcel<Foam::ThermoParcel<Foam::KinematicParcel<Foam::particle> > > > >, Foam::label = int]'
/opt/openfoam230/src/OpenFOAM/lnInclude/gatherScatterList.C:197:9:  instantiated from 'static void Foam::Pstream::gatherList(Foam::List<T>&, int, Foam::label) [with T = Foam::IDLList<Foam::ReactingMultiphaseParcel<Foam::ReactingParcel<Foam::ThermoParcel<Foam::KinematicParcel<Foam::particle> > > > >, Foam::label = int]'
ParticleStatistics.H:19:39:  instantiated from here
/opt/openfoam230/src/OpenFOAM/lnInclude/INew.H:62:25: error: 'New' is not a member of 'Foam::ReactingMultiphaseParcel<Foam::ReactingParcel<Foam::ThermoParcel<Foam::KinematicParcel<Foam::particle> > > >'
/opt/openfoam230/src/OpenFOAM/lnInclude/INew.H:63:5: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [Make/linuxGccDPOpt/coalChemistryFoam.o] Error 1

The letter "p" is somehow replaced by smile token.

wyldckat May 3, 2015 13:40

Greetings to all!

@Wen Xu: Before I forget to mention this, for posting code and output here on the forum, you can find instructions here: Posting code and output with [CODE]

As for the problem you are dealing with right out, I need more details:
  1. Where exactly are you trying to consolidate this information? Is it in a solver or library? And in which one?
  2. Why do you need the details for all particles?
  3. Why do you need all particles to be located at the master processor/application?
Best regards,
Bruno

wenxu May 3, 2015 20:51

Thank you for your suggestions, Bruno. I messed up with quoting text and code tags.
  1. Quote:

    Where exactly are you trying to consolidate this information? Is it in a solver or library? And in which one?
I want to get all of the particles' velocity to calculate RMS. First, I want to put my code at /src/lagrangian/intermediate/submodels/CloudFunctionObject and then transfer them to slover because compile code in intermediate is time consuming. The two places will have the same problem that I can only get the parcels' information in the every processor, but can not gather them with the code:
Code:

List<IDLList<coalParcel> > gatheredParcel(Pstream::nProcs());
    gatheredParcel[Pstream::myProcNo()] = coalParcels;
    Pstream::gatherList(gatheredParcel);

Now I solve this in reconstruct solver and it works since this solver can "gather" all of the data from different processors. But I still want to know how to gather particles from different processors in lagrangian solver.
  1. Quote:

    Why do you need the details for all particles?
Because I want to statistics them, I need know velocity, position for every parcel.

  1. Quote:

    Why do you need all particles to be located at the master processor/application?
As my description above, any processor ( myProc) can gather the parcels, usually we gather them at master processor.


Now, after have answered your questions, I think whether we can get the parcels' velocity and positions in every processor and write them out with a subList, then we can link these subList together?

Thank you in advance!

Best regards,
Wen Xu

wyldckat September 21, 2015 15:43

Greetings Wen Xu,

Sorry for the late reply. I've had these questions on my to-do list for quite sometime now and only today did I finally manage to take a look into this.
Besides the thread you found: http://www.cfd-online.com/Forums/ope...rocessors.html - I also found this one: http://www.cfd-online.com/Forums/ope...ion-array.html

The first problem that I could figure out from one of your posts is that the list you're trying to transfer doesn't have the necessary hook-ups needed for the gather method to work. The main one missing is the "New" method, which means that each particle would be re-created on each processor.

The second problem is that it seems to be a lot easier if you gather the data you need from each particle onto an independent list and then gather all of the lists. For example, gather the masses of all particles into a scalar list and then place that scalar list in another list for each processor. Then do the same for the other properties.

Either way, I don't know if you've solved this problem since then.

Best regards,
Bruno

wenxu September 21, 2015 21:19

Dear Bruno,

I do not solve the problem directly, but I implement this use another method---I implement a post-processing solver to statistics the particles. That means after the simulation finished, I use this solver the gather the particle properties into one scalar list for every write out time. The I statistics the gathered List of the particles. But I believe there is a convenient method to do this at run time.

Thank you for you very kind help. Many thanks!

Best regards,
Wen


All times are GMT -4. The time now is 07:00.