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

How to loop over parcels in OpenFOAM 9

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By yv3s95

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 8, 2021, 09:32
Post How to loop over parcels in OpenFOAM 9
  #1
New Member
 
Anders Simonsen
Join Date: Sep 2013
Posts: 18
Rep Power: 12
ASimonsen is on a distinguished road
Hi

I'm in the process of switching from OF8 to OF9, where I'm currently updating my main solver. It is a lagrangian solver, where I in OF8 looped over all parcels by:

Code:
forAllIter(decltype(parcels),parcels,p)
{
    vector position = p().position();
}
The thing is that the variable "parcels" was previously defined in createClouds.H:

Code:
basicSprayCloud parcels
(
    "sprayCloud",
    rho,
    U,
    g,
    slgThermo
);
In OF9 the clouds/parcels have moved to fvModels, so now I do not have access to the variable "parcels" in my solver code anymore (as there is no createClouds.H anymore), and I can't seem to figure out how to get it from the fvModels variable.

I am able to loop over all the models in my simulation by:
Code:
PtrListDictionary<fvModel>& modelList(fvModels);
forAll(modelList, i)
{
    Info << "Name: " << modelList[i].name() << endl;
}
I have three different models applied in my simulation, and the cloud is the second on. So I guess it is something like:

Code:
autoPtr<???>& parcels = modelList[1];
Can anyone help me with my problem, such that I again can loop over parcels in OF9?

Kind regards Anders
ASimonsen is offline   Reply With Quote

Old   September 20, 2021, 09:21
Default
  #2
New Member
 
Anders Simonsen
Join Date: Sep 2013
Posts: 18
Rep Power: 12
ASimonsen is on a distinguished road
Hi again

I still haven't succeeded in looping over the parcels in OF9. However, I've made some progress, which I'll share here:

Via the object registry, I was able to get a pointer to the parcelCloud object:
Code:
Foam::parcelCloud& Obj_ParcelCloud = mesh.lookupObjectRef<Foam::parcelCloud>("cloud");
Using this object, I'm able to evolve the cloud:
Code:
runTime++;
Info << "Time = " << runTime.timeName() << nl << endl;
Obj_ParcelCloud.evolve();
However, I'm still not able to loop over the parcels - I simply do not know how to access it.
The iterator methods are defined in "Cloud.H":
Code:
    // Member Functions

        // Access

            //- Return the polyMesh reference
            const polyMesh& pMesh() const
            {
                return polyMesh_;
            }

            //- Return the number of particles in the cloud
            label size() const
            {
                return IDLList<ParticleType>::size();
            };


            // Iterators

                const const_iterator begin() const
                {
                    return IDLList<ParticleType>::begin();
                };

                const const_iterator cbegin() const
                {
                    return IDLList<ParticleType>::cbegin();
                };

                const const_iterator end() const
                {
                    return IDLList<ParticleType>::end();
                };

                const const_iterator cend() const
                {
                    return IDLList<ParticleType>::cend();
                };

                iterator begin()
                {
                    return IDLList<ParticleType>::begin();
                };

                iterator end()
                {
                    return IDLList<ParticleType>::end();
                };
However, the methods .begin, .cbegin, .end, .cend are not members of the "Obj_ParcelCloud" object, which I have available in my solver as shown above.

Can someone help me further, such that I can loop over all parcels? Or give me a hint/tip, as I seem to be stuck!

Kind regards Anders
ASimonsen is offline   Reply With Quote

Old   October 4, 2021, 03:42
Default
  #3
New Member
 
Anders Simonsen
Join Date: Sep 2013
Posts: 18
Rep Power: 12
ASimonsen is on a distinguished road
Hi again

I still haven't figured it out - can anyone give a hint or a suggestion?

Kind regards Anders
ASimonsen is offline   Reply With Quote

Old   November 1, 2021, 18:38
Default
  #4
New Member
 
Yves Robert
Join Date: May 2019
Posts: 4
Rep Power: 6
yv3s95 is on a distinguished road
I am actually wondering the same, if anybody has a suggestion.
ASimonsen likes this.
yv3s95 is offline   Reply With Quote

Old   November 10, 2021, 02:30
Default
  #5
Member
 
David GISEN
Join Date: Jul 2009
Location: Germany
Posts: 68
Rep Power: 16
David* is on a distinguished road
just a wild guess, if you are using a pointer to object, do you have to access the member functions with a dereference operator like "->" ?
https://www.decodejava.com/cpp-point...-functions.htm
David* is offline   Reply With Quote

Old   March 9, 2022, 15:38
Unhappy
  #6
Member
 
Rishikesh
Join Date: Apr 2016
Posts: 63
Rep Power: 9
mrishi is on a distinguished road
Hi,
I am having the same issue with OF9 (To be honest, I have been feeling quite frustrated with the recent Foundation releases). Did you manage to fix the issue? I too am trying to loop over parcels from the main solver.


Thanks,
mrishi
mrishi is offline   Reply With Quote

Old   March 10, 2022, 04:50
Default
  #7
New Member
 
Anders Simonsen
Join Date: Sep 2013
Posts: 18
Rep Power: 12
ASimonsen is on a distinguished road
Quote:
Originally Posted by mrishi View Post
Hi,
I am having the same issue with OF9 (To be honest, I have been feeling quite frustrated with the recent Foundation releases). Did you manage to fix the issue? I too am trying to loop over parcels from the main solver.


Thanks,
mrishi
Hi mrishi

No, I haven't found a solution to this, and I haven't been looking more into it recently.

Kind regards Anders
ASimonsen is offline   Reply With Quote

Reply

Tags
fvmodel, loop, of9, parcels

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
OpenFOAM Training Jan-Jul 2017, Virtual, London, Houston, Berlin CFDFoundation OpenFOAM Announcements from Other Sources 0 January 4, 2017 07:15
UNIGE February 13th-17th - 2107. OpenFOAM advaced training days joegi.geo OpenFOAM Announcements from Other Sources 0 October 1, 2016 20:20
New OpenFOAM Forum Structure jola OpenFOAM 2 October 19, 2011 07:55
[CAD formats] my stl surface is seen as just a line rcastilla OpenFOAM Meshing & Mesh Conversion 2 January 6, 2010 02:30
NACA0012 geometry/design software needed Franny Main CFD Forum 13 July 7, 2007 16:57


All times are GMT -4. The time now is 06:16.