|
[Sponsors] |
March 11, 2022, 14:38 |
Make a particles list in MomentumCloud
|
#1 |
New Member
Yves Robert
Join Date: May 2019
Posts: 4
Rep Power: 7 |
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_; Code:
parcels_of_interest_(DynamicList<parcelType*>(0)), 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; } } 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 I would greatly appreciate help on this matter, as I am really stuck on this problem to go forward in my project. Thank you. |
|
March 12, 2022, 04:37 |
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
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.
|
|
Tags |
dem, dynamiclist, lagrangian, momentum cloud, parcels |
|
|
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 |