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

Make a particles list in MomentumCloud

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 11, 2022, 14:38
Default Make a particles list in MomentumCloud
  #1
New Member
 
Yves Robert
Join Date: May 2019
Posts: 4
Rep Power: 7
yv3s95 is on a distinguished road
Hi,

I would like to make a list of parcels in MomentumCloud objects.
Basically, I want to populate a list (DynamicList) of parcels, which is stored for the whole iteration (injection of new parcels and cloud motion). Just for context, the list should contain parcels that are below a certain Zmin.

I am quite new to OpenFOAM development.

So first, how to create a new field in momentum clouds? This field should be a DynamicList of parcels.
Then, how to populate the list?

Here is what I tried to do.
In MomentumCloud.H, I added
Code:
void populate_parcels_of_interest(const double);
inline DynamicList<parcelType*> parcels_of_interest();
DynamicList<parcelType*> parcels_of_interest_;
In MomentumCloud.C, I added:
Code:
parcels_of_interest_(DynamicList<parcelType*>(0)),
in the constructor


Code:
template<class CloudType>
void Foam::MomentumCloud<CloudType>::populate_parcels_of_interest
(
    const scalar Z_min
)
{
    DynamicList<parcelType*>& parcels_of_interest = parcels_of_interest_;
    int i = 0;
    forAllConstIter(typename MomentumCloud<CloudType>, *this, pIter)
    {
        const parcelType p = pIter();
        scalar z = p.position().z();
        Info << "Pos: " << p.position() << nl;
        if (z < Z_min)
        {
            parcels_of_interest.append(&p);
            i ++;
            int j = 0;
            while  (j < i)
            {
                Info << "\tPos " << j << ": " << parcels_of_interest[j]->position() << nl;
                j++;
            }
        }
    }

    forAll(parcels_of_interest, i)
    {
        parcelType p = *parcels_of_interest[i];
        scalar z = p.position().z();
        Info << i << "-> Z_min: " << Z_min << " Z: " << z << " test: " << (z >= Z_min) << nl;
    }  
}
When I run the code for 1 step and look at the output (4 parcels injected):
Code:
Pos: (0.241657 -0.250083 0.395233)
        Pos 0: (0.241657 -0.250083 0.395233)
Pos: (-0.327668 -0.248501 0.42311)
        Pos 0: (-0.327668 -0.248501 0.42311)
        Pos 1: (-0.327668 -0.248501 0.42311)
Pos: (-0.49028 0.00792265 0.43253)
        Pos 0: (-0.49028 0.00792265 0.43253)
        Pos 1: (-0.49028 0.00792265 0.43253)
        Pos 2: (-0.49028 0.00792265 0.43253)
Pos: (-0.346966 -0.0428658 0.428971)
        Pos 0: (-0.346966 -0.0428658 0.428971)
        Pos 1: (-0.346966 -0.0428658 0.428971)
        Pos 2: (-0.346966 -0.0428658 0.428971)
        Pos 3: (-0.346966 -0.0428658 0.428971)
0-> Z_min: 1e+30 Z: 0.428971 test: 0
1-> Z_min: 1e+30 Z: 0.428971 test: 0
2-> Z_min: 1e+30 Z: 0.428971 test: 0
3-> Z_min: 1e+30 Z: 0.428971 test: 0
It seems like the element I add to the list is getting updated every time, instead of storing the parcel of interest.

I would greatly appreciate help on this matter, as I am really stuck on this problem to go forward in my project.

Thank you.
yv3s95 is offline   Reply With Quote

Old   March 12, 2022, 04:37
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Since you have a DynamicList of pointers to your "particles of interest", it would be a bug if their values did not change. If you want a copy of their values, you can't be storing their pointers.
olesen is offline   Reply With Quote

Reply

Tags
dem, dynamiclist, lagrangian, momentum cloud, parcels


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.com] swak4foam compiling issues on a cluster saj216 OpenFOAM Installation 5 January 17, 2023 17:05
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 ordinary OpenFOAM Installation 19 September 3, 2019 19:13
Problem compiling a custom Lagrangian library brbbhatti OpenFOAM Programming & Development 2 July 7, 2014 12:32
Help for the small implementation in turbulence model shipman OpenFOAM Programming & Development 25 March 19, 2014 11:08
a way to make lots of money quick and easy no lies Dob Main CFD Forum 0 October 10, 2006 17:45


All times are GMT -4. The time now is 13:52.