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

access parcels in cloud object

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 17, 2023, 07:48
Default access parcels in cloud object
  #1
New Member
 
Martin
Join Date: Jul 2022
Posts: 16
Rep Power: 4
skaal is on a distinguished road
I want to collect collision statistics from a lagrangian cloud. For that purpose I need to access the individual parcels in that cloud.



In OpenFOAM-8 I would just create the cloud object and iterate over the parcels:

Code:
// openFOAM-8

basicReactingMultiphaseCloud parcels("cloudName", rho, U, g, slgThermo);
forAllIter(basicReactingMultiphaseCloud, parcels, iter)
{ ... }

Since, in OF-10, the cloud object is created by the corresponding fvModel, I do not need create it in the solver myself but can look it up from the object registry. As a side note: I want to do this because the cloud constructor otherwise tries to read the corresponting properties dict from constant -- and all entries must be defined in there, there is no longer an active flag to just switch the cloud off.



Code:
// OpenFOAM-10

reactingMultiphaseCloud& parcels = mesh.template lookupObjectRef<reactingMultiphaseCloud>("cloudName");
forAllIter(typename reactingMultiphaseCloud, parcels, iter)
{ ... }

This fails to compile with the error message:

Code:
/home/user/OpenFOAM/OpenFOAM-10/src/OpenFOAM/lnInclude/objectRegistryTemplates.C:182:61:error: reference to ‘Foam::ParcelCloud<Foam::ReactingMultiphaseClou
d<Foam::ReactingCloud<Foam::ThermoCloud<Foam::MomentumCloud<Foam::ParcelCloudBase<Foam::ReactingMultiphaseParcel<Foam::ReactingParcel<Foam::ThermoParcel<Foa
m::MomentumParcel<Foam::particle> > > > > > > > > >::typeName’ is ambiguous 
  182 |             << " successful\n    but it is not a " << Type::typeName



I dug around a bit and found a code snipped in
Code:
src/lagrangian/parcel/submodels/ReactingMultiphase/StochasticCollision/SuppressionCollision/Suppression
Collision.C
which would use the parcelCloud as data type. Doing this


Code:
// OpenFOAM-10

parcelCloud& parcels = mesh.template lookupObjectRef<parcelCloud>("cloudName");
forAllIter(typename reactingMultiphaseCloud, parcels, iter)
{ ... }

I do not have access to various member functions, e.g.:

Code:
error: class Foam::parcelCloud’ has no member named ‘composition
  151 |             label idSolid =  parcels.composition().idSolid();



I found this post using the object registry to access a particle cloud with a very similar issue in an old(er) OpenFOAM version. However, I have no idea how to adapt the solution in my case.
Since reactingMultiphaseCloud is just a typedef, inserting the full template does not make a difference.


Does anyone have an idea on how to solve this?
skaal is offline   Reply With Quote

Old   February 27, 2023, 10:10
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
I did not check with any of the .org versions, but in the openfoam.com versions I know that it is no problem to just use the forAllIters and forAllConstIters macros (note the additional trailing 's' ) and traverse the cloud parcels.


You could try just using the equivalent of what the forAllConstIters does and simply use a range-for. Eg,
Code:
for (const auto& p : parcels)
 {
    // do something
 }
olesen is offline   Reply With Quote

Old   March 1, 2023, 06:55
Default
  #3
New Member
 
Martin
Join Date: Jul 2022
Posts: 16
Rep Power: 4
skaal is on a distinguished road
Thanks for the ideas but sadly neither of your suggestions solves the issue:
  • forAllIters is not available in the .org version
  • the for (const auto& p : parcel) indeed does the same thing as for forAllIter, and thus throws the same error message...
skaal is offline   Reply With Quote

Old   March 1, 2023, 10:16
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
which error messages exactly?
olesen is offline   Reply With Quote

Old   March 10, 2023, 09:09
Default
  #5
New Member
 
Martin
Join Date: Jul 2022
Posts: 16
Rep Power: 4
skaal is on a distinguished road
Hi Mark, sorry for the late reply.


To summarize things more thoroughly:
  • forAllIters is not available:
    error:
    forAllIters’ was not declared in this scope; did you mean ‘forAllIter’?
    15 | forAllIters(reactingMultiphaseCloud, parcels, iter)
  • creating the cloud as reactingMultiphaseCloud:
    reactingMultiphaseCloud& parcels = mesh.template lookupObjectRef<reactingMultiphaseCloud>("cloudNam e");

    I get the already mentioned issue with ambiguous typeNames:
    OpenFOAM/OpenFOAM-10/src/OpenFOAM/lnInclude/objectRegistryTemplates.C:182:61:error: reference to ‘Foam::ParcelCloud<Foam::ReactingMultiphaseClou
    d<Foam::ReactingCloud<Foam::ThermoCloud<Foam::Mome ntumCloud<Foam::ParcelCloudBase<Foam::ReactingMult iphaseParcel<Foam::ReactingParcel<Foam::ThermoParc el<Foa
    m::MomentumParcel<Foam:article> > > > > > > > > >::typeName’ is ambiguous
    182 | << " successful\n but it is not a " << Type::typeName

    It does not matter, if I loop over the parcels using forAllIter or via a for each loop as you suggested, the error message is the same.
  • The only variant that seems to work is to create the cloud directly via calling the constructor:
    reactingMultiphaseCloud parcels("cloudName", rho, U, g, thermo);
skaal is offline   Reply With Quote

Old   April 3, 2023, 12:05
Default
  #6
New Member
 
Martin
Join Date: Jul 2022
Posts: 16
Rep Power: 4
skaal is on a distinguished road
Just for reference: I solved this issue now by wrapping the collision statistics in an extra model which reads the cloudProperties file only when it is present.
Internally that model wraps the reactingMultiphaseCloud in an autoPtr and exposes functions for the source terms to be called when assembling the equations.


In the end, this approach is similar to what the fvModels do.
I did not find a solution that creates less overhead.
skaal is offline   Reply With Quote

Reply

Tags
openfoam-10


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
can I access to the "dict" object from codeWrite in a coded function object? NotOverUnderated OpenFOAM Programming & Development 2 October 28, 2021 19:46
Access the Time object in sixDoFRigidBodyMotionRestraints SailorLiu OpenFOAM Programming & Development 14 March 3, 2019 04:17
problem with solving lagrange reaction cloud Polli OpenFOAM Running, Solving & CFD 0 April 30, 2014 08:53
[General] 2 datas on one plot Akuji ParaView 46 December 1, 2013 15:06
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 keepfit ParaView 60 September 18, 2013 04:23


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