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

about parcel evolve function

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

Like Tree2Likes
  • 1 Post By cnsidero
  • 1 Post By cnsidero

Reply
 
LinkBack Thread Tools Display Modes
Old   January 17, 2016, 18:07
Default about parcel evolve function
  #1
Senior Member
 
Join Date: Jan 2013
Posts: 297
Rep Power: 6
openfoammaofnepo is on a distinguished road
Hi,

In some OpenFOAM lagrangian solver, such as coalChemistryFOAM, the link for this solver is
Code:
https://github.com/OpenFOAM/OpenFOAM-2.3.x/blob/master/applications/solvers/lagrangian/coalChemistryFoam/createClouds.H#L16
There is the following lines:
Code:
        coalParcels.evolve();

        limestoneParcels.evolve();
The objects of coalParcels and limestoneParcels are defined in "createClouds.H":
Code:
Info<< "\nConstructing coal cloud" << endl;
coalCloud coalParcels
(
    "coalCloud1",
    rho,
    U,
    g,
    slgThermo
);

Info<< "\nConstructing limestone cloud" << endl;
basicThermoCloud limestoneParcels
(
    "limestoneCloud1",
    rho,
    U,
    g,
    slgThermo
);
But I did not find the function of evolve() in OpenFOAM, I mean the specific form of this function. Could anybody give me some hints about this? Thanks.
openfoammaofnepo is offline   Reply With Quote

Old   January 19, 2016, 16:59
Default
  #2
Senior Member
 
Join Date: Jan 2013
Posts: 297
Rep Power: 6
openfoammaofnepo is on a distinguished road
The source file for coalCloud is as follows:

Code:
namespace Foam
{
    typedef ReactingMultiphaseCloud
    <
        ReactingCloud
        <
            ThermoCloud
            <
                KinematicCloud
                <
                    Cloud
                    <
                        coalParcel
                    >
                >
            >
        >
    > coalCloud;
}
Code:
 typedef ReactingMultiphaseCloud <ReactingCloud<ThermoCloud<KinematicCloud<Cloud<coalParcel>>>>> coalCloud;
"coalParcel" is defined in coalParcel.H as follows:
Code:
    typedef ReactingMultiphaseParcel
    <
        ReactingParcel
        <
            ThermoParcel
            <
                KinematicParcel
                <
                    particle
                >
            >
        >
    > coalParcel;

Last edited by openfoammaofnepo; January 28, 2016 at 16:39.
openfoammaofnepo is offline   Reply With Quote

Old   January 20, 2016, 09:24
Default
  #3
Senior Member
 
Chris Sideroff
Join Date: Mar 2009
Location: Ottawa, ON, CAN
Posts: 387
Rep Power: 13
cnsidero is on a distinguished road
Follow the template trail. It's defined in ReactingCloud:

$FOAM_SRC/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.[C,H]
cnsidero is offline   Reply With Quote

Old   January 25, 2016, 10:17
Default
  #4
Senior Member
 
Join Date: Jan 2013
Posts: 297
Rep Power: 6
openfoammaofnepo is on a distinguished road
Dear Chris,

Thank you for your reply. I have checked that but it is still not clear for me to find how 'this->solve(td);' in this "evolve" function, i.e. in the following source codes from the files you mentioned:

Code:
template<class CloudType>
void Foam::ReactingCloud<CloudType>::evolve()
{
    if (this->solution().canEvolve())
    {
        typename parcelType::template
            TrackingData<ReactingCloud<CloudType> > td(*this);

        this->solve(td);
    }
}
Could you please give me some further hints about what is the operation for this->solve(td);? Thank you so much.

-----------------
For pulverized coal combustion case, I guess the changes of individual particles caused by devolatilization and char (solid carbon) combustion are included in this this->solve(td);?

Last edited by openfoammaofnepo; January 25, 2016 at 10:29. Reason: some comments
openfoammaofnepo is offline   Reply With Quote

Old   January 25, 2016, 14:33
Default
  #5
Senior Member
 
Chris Sideroff
Join Date: Mar 2009
Location: Ottawa, ON, CAN
Posts: 387
Rep Power: 13
cnsidero is on a distinguished road
Go back to coalCloud.H. You'll notice one of the classes the coalCloud typedef is created from is KinematicCloud. KinemeticCloud contains the definition for solve. Line 91 in

$FOAM_SRC/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C

The Lagrangian classes are rather complex due to its policy-based design with templates. It can be a struggle to find where things are and how it all fits together. There's a simple explanation of policy-based design on Wikipedia: https://en.wikipedia.org/wiki/Policy-based_design

ReactingMultiphaseCloud is the host class and the nested classes are the policy classes. As the Wikipedia article mentions, in policy-based design, the host class inherits the methods of the policy classes hence the solve method from KinematicCloud can be called.

Last edited by cnsidero; January 25, 2016 at 17:48.
cnsidero is offline   Reply With Quote

Old   January 25, 2016, 16:52
Default
  #6
Senior Member
 
Join Date: Jan 2013
Posts: 297
Rep Power: 6
openfoammaofnepo is on a distinguished road
Dear Chris,

Thank you so much for your help. I am reading some source files for the lagrangian solvers in OpenFOAM and found that it is indeed very struggling.

In the Lagrangian solver of OpenFOAM, what is the difference between the terminologies "particle", "parcel" and "cloud"? Since we have "coalParcels.evolve();", so the number of ODEs for the mass, momentum and energy is consistent with the number of parcles?

Thank you again.

OFFO
openfoammaofnepo is offline   Reply With Quote

Old   January 26, 2016, 14:06
Default
  #7
Senior Member
 
Join Date: Jan 2013
Posts: 297
Rep Power: 6
openfoammaofnepo is on a distinguished road
Dear Chris,

in the KinematicCloud.H [or .C], how is the quantity "UTrans" is caluclated? This is the source term for the momentum equation, but is it related to the models for the different forces?
openfoammaofnepo is offline   Reply With Quote

Old   January 28, 2016, 13:03
Default
  #8
Senior Member
 
Chris Sideroff
Join Date: Mar 2009
Location: Ottawa, ON, CAN
Posts: 387
Rep Power: 13
cnsidero is on a distinguished road
parcel: represents many particles with identical particle properties
cloud: represents many parcels with varying parcel properties

UTrans: I'm doing all the work here for you so I'll point you in the right direction one more time and then you're own you're own. In KinematicCloud.[C,H] you'll notice the private data member UTrans_ is created or updated from a KinematicCloud<CloudType> object. So the trick is again to recognize the policy-based design of the Lagrangian library. The last policy class coalCloud is defined from is coalParcel, which itself is defined in a similar manner (look in coalParcel.H). The parcel classes are where UTrans is updated (look in $FOAM_SRC/lagrangian/intermediate/parcels/Templates/).

Good luck, Chris

Tip: The shell utilities 'find' and 'grep' are your friend. E.g.

Code:
find $FOAM_SRC/lagrangian "*.[C,H]" | xargs grep -n UTrans\(\) | grep -v lnInclude
will search all .C and .H files in the lagrangian library for the string "UTrans()" and ignore results from the lnInclude directories (duplicates).
openfoammaofnepo likes this.
cnsidero is offline   Reply With Quote

Old   January 28, 2016, 16:35
Default
  #9
Senior Member
 
Join Date: Jan 2013
Posts: 297
Rep Power: 6
openfoammaofnepo is on a distinguished road
Dear Chris,

Your following comment is very helpful for my understanding the code structure, so I mark here:

Code:
The last policy class coalCloud is defined from is coalParcel, which itself is defined in a similar manner (look in coalParcel.H). The parcel classes are where UTrans is updated (look in $FOAM_SRC/lagrangian/intermediate/parcels/Templates/).
I think this is the "channel" between the classes in the following two folders:

Code:
$FOAM_SRC/src/lagrangian/intermediate/clouds
and
Code:
$FOAM_SRC/src/lagrangian/intermediate/parcels
Thanks a lot.
openfoammaofnepo is offline   Reply With Quote

Old   January 28, 2016, 17:06
Default
  #10
Senior Member
 
Join Date: Jan 2013
Posts: 297
Rep Power: 6
openfoammaofnepo is on a distinguished road
About the policy-based programming, the following from Wikipedia is help and is paste here for other people's reference:

A key feature of the policy idiom is that, usually (though it is not strictly necessary), the host class will derive from (make itself a child class of) each of its policy classes using (public) multiple inheritance. (Alternatives are for the host class to merely contain a member variable of each policy class type, or else to inherit the policy classes privately; however inheriting the policy classes publicly has the major advantage that a policy class can add new methods, inherited by the instantiated host class and accessible to its users, which the host class itself need not even know about.) A notable feature of this aspect of the policy idiom is that, relative to object-oriented programming, policies invert the relationship between base class and derived class - whereas in OOP interfaces are traditionally represented by (abstract) base classes and implementations of interfaces by derived classes, in policy-based design the derived (host) class represents the interfaces and the base (policy) classes implement them. It should also be noted that in the case of policies, the public inheritance does not represent an is-a relationship between the host and the policy classes. While this would traditionally be considered evidence of a design defect in OOP contexts, this doesn't apply in the context of the policy idiom.

--Wikipedia
openfoammaofnepo is offline   Reply With Quote

Old   January 28, 2016, 17:36
Default
  #11
Senior Member
 
Join Date: Jan 2013
Posts: 297
Rep Power: 6
openfoammaofnepo is on a distinguished road
For the cloud related classes in $FOAM_SRC/src/lagrangian/intermediate/clouds, are they only for the policy based coding? Because I found that all the physical and modelling calculations (e.g. the inter-phasic interactions between the continuous and dispersed phases, and also the source terms such as SU, SYi, Srho and Shs) have been performed at the level of parcels, which are in $FOAM_SRC/src/lagrangian/intermediate/parcels.

So that means coalParcels have already all the required terms and interactions, as shown in #2 post above. So in this case, we still use cloud related classes. This seems difficult to understand.
openfoammaofnepo is offline   Reply With Quote

Old   January 28, 2016, 23:42
Default
  #12
Senior Member
 
Chris Sideroff
Join Date: Mar 2009
Location: Ottawa, ON, CAN
Posts: 387
Rep Power: 13
cnsidero is on a distinguished road
"however inheriting the policy classes publicly has the major advantage that a policy class can add new methods, inherited by the instantiated host class and accessible to its users, which the host class itself need not even know about."

I want to emphasize this statement, in particular the bold, because this is what makes the policy design difficult to follow. Since a host class inherits methods from the policy classes, one needs to be aware of the methods within all the policy classes because they're not as obvious as they would be with inherited classes in object oriented design.
openfoammaofnepo likes this.
cnsidero is offline   Reply With Quote

Old   January 29, 2016, 06:38
Default
  #13
Senior Member
 
Join Date: Jan 2013
Posts: 297
Rep Power: 6
openfoammaofnepo is on a distinguished road
Quote:
Originally Posted by cnsidero View Post
"however inheriting the policy classes publicly has the major advantage that a policy class can add new methods, inherited by the instantiated host class and accessible to its users, which the host class itself need not even know about."

I want to emphasize this statement, in particular the bold, because this is what makes the policy design difficult to follow. Since a host class inherits methods from the policy classes, one needs to be aware of the methods within all the policy classes because they're not as obvious as they would be with inherited classes in object oriented design.
Thanks, very useful explanations!
openfoammaofnepo is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 0 April 27, 2015 18:25
compressible flow in turbocharger riesotto OpenFOAM 50 May 26, 2014 01:47
error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Native Meshers: blockMesh 2 March 14, 2012 10:56
Compilation errors in ThirdPartymallochoard feng_w OpenFOAM Installation 1 January 25, 2009 07:59
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50


All times are GMT -4. The time now is 08:44.