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

thermo vs. turbulence() ?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By dlahaye
  • 1 Post By Tobermory

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 17, 2022, 08:22
Default thermo vs. turbulence() ?
  #1
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 723
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Why is the constructor for the thermo class called without brackets and the constructor for the turbulence class called with brackets.

Apologies for my low literacy in C++. Thx!
dlahaye is offline   Reply With Quote

Old   January 17, 2022, 10:44
Default
  #2
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 668
Rep Power: 14
Tobermory will become famous soon enough
Not sure I follow you Domenico - do you want to add an example?
Tobermory is offline   Reply With Quote

Old   January 17, 2022, 15:58
Default
  #3
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 723
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Thanks for the reply.

An example is line 67 of createFields of reactingFoam at https://develop.openfoam.com/Develop...createFields.H

Motivating my question is the desire of understanding for the combustion model is implemented.

It appears that the implementation of EDM combustion model is not the standard implementation. We thus might want to change that to be able to compare with standard implementations in various other codes.

Cheers, Domenico.
dlahaye is offline   Reply With Quote

Old   January 17, 2022, 16:28
Default
  #4
Member
 
Lorenzo
Join Date: Apr 2020
Location: Italy
Posts: 36
Rep Power: 6
Lorenzo210 is on a distinguished road
Hi,
First of all, let me say that I consider myself as a beginner, so I cannot be totally sure of my suggestion.

Could it be that thermo is defined as an object, whereas turbulence is a pointer?
Looking at createFields.H, thermo is defined in line 5 (see that also pThermo, which is a pointer, is called with parentheses):
Code:
psiReactionThermo& thermo = pThermo();
turbulence is defined in line 53:
Code:
autoPtr<compressible::turbulenceModel> turbulence
(
    compressible::turbulenceModel::New
    (
        rho,
        U,
        phi,
        thermo
    )
);
Regards,

Lorenzo
Lorenzo210 is online now   Reply With Quote

Old   January 18, 2022, 13:14
Default
  #5
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 723
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Dear Lorenzo,

Thank you so much for pointing me in the (what I perceive to be) the correct direction!

Here is my current understanding of what is happening.

For thermo: First, pThermo() is created as an autoPtr. Next, thermo is cast to a pointer.

Code:
autoPtr<psiReactionThermo> pThermo(psiReactionThermo::New(mesh));
psiReactionThermo& thermo = pThermo();

For turbulence: turbulence is created as an autoPtr. This is the only step. A possible reason is that turbulence is not used as argument to create an autoPtr (unlike thermo).

Code:
autoPtr<compressible::turbulenceModel> turbulence
(
    compressible::turbulenceModel::New
    (
        rho,
        U,
        phi,
        thermo
    )
);
Grazie ancora.
Lorenzo210 likes this.
dlahaye is offline   Reply With Quote

Old   January 22, 2022, 11:10
Default
  #6
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 668
Rep Power: 14
Tobermory will become famous soon enough
Domenico

just a few refinements to your earlier post:

Quote:
Originally Posted by dlahaye View Post
For thermo: First, pThermo() is created as an autoPtr. Next, thermo is cast to a pointer.
For turbulence: turbulence is created as an autoPtr. This is the only step. A possible reason is that turbulence is not used as argument to create an autoPtr (unlike thermo).
I think that a more precise version is as follows:
1. On line 4 of createFields.H, a new psiReactionThermo object is created; this returns a pointer that is assigned to smart pointer pThermo
Code:
autoPtr<psiReactionThermo> pThermo(psiReactionThermo::New(mesh));
2. A reference (think of it as an alias) is set to this psiReactionThermo object called thermo, not a pointer; to set the reference you need to address the object (eg int& x = y), and for the autoPtr class you do that with operator() - see line 135 in autoPtrI.H. So that is why we have pThermo() on line 5 of createFields.
Code:
psiReactionThermo& thermo = pThermo();
3. Thereafter, the code uses thermo as a shorthand for pThermo()
4. The turbulence model is constructed in a similar way - first, create a new momentumTransportModel object and assign its pointer to smart pointer called turbulence
Code:
 autoPtr<compressible::momentumTransportModel> turbulence
 (
     compressible::momentumTransportModel::New
     (
         rho,
         U,
         phi,
         thermo
     )
 );
5. to reference the turbulence model object, you need to call the autoPtr operator() method, i.e. you use turbulence(). An example of this is a few lines later in createFields:
Code:
psiReactionThermophysicalTransportModel::New(turbulence(), thermo)
but I guess that this could have been written as:
Code:
psiReactionThermophysicalTransportModel::New(turbulence(), pThermo())
Is that a little clearer? For many years I had shied away from looking "under the hood" at what exactly are autoPtr and tmp ... the coding is actually pretty simple, so if you have an afternoon then have a look ... just make some notes, since I find that the "knowledge" is pretty transient!
Lorenzo210 likes this.
Tobermory is offline   Reply With Quote

Old   January 23, 2022, 15:08
Default
  #7
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 723
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Perfectly clear, thank you so much!

Domenico.
dlahaye is offline   Reply With Quote

Reply


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
Simulation crashes when turbulence is on (reactingMultiphaseEulerFoam) remidemol OpenFOAM Running, Solving & CFD 3 May 26, 2020 05:47
Average Turbulence Intensity in LES M_Hego Visualization & Post-Processing 0 July 24, 2018 15:18
how to set URANS turbulence model in unsteady flow simulation TimLiu OpenFOAM Pre-Processing 0 April 25, 2017 08:52
Turbulence postprocessing Mohsin FLUENT 2 October 3, 2016 14:18
Code release: Flow Transition and Turbulence Chaoqun Liu Main CFD Forum 0 September 26, 2008 17:15


All times are GMT -4. The time now is 07:33.