|
[Sponsors] |
Turbulence models and run time selection tables |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 13, 2014, 16:47 |
Turbulence models and run time selection tables
|
#1 |
Senior Member
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 452
Rep Power: 24 |
Hi all, I spent some hours overnight to understand how turbulence models are selected by the run time selection mechanism, the best commentary I've read was by marupio:
"4.3.5 When does this all happen? The "virtual constructor" table is fully built and loaded into memory when the include list is fully read, and before the first line of code is executed. This is achieved using the static keyword. All static members of a class exist prior to any instance of that class." OpenFOAM guide/runTimeSelection mechanism For example en turbulenceModel.C Code:
75 76 autoPtr<turbulenceModel> turbulenceModel::New 77 ( 78 const volVectorField& U, 79 const surfaceScalarField& phi, 80 transportModel& transport, 81 const word& turbulenceModelName 82 ) 83 { 84 // get model name, but do not register the dictionary 85 // otherwise it is registered in the database twice 86 const word modelType 87 ( 88 IOdictionary 89 ( 90 IOobject 91 ( 92 "turbulenceProperties", 93 U.time().constant(), 94 U.db(), 95 IOobject::MUST_READ_IF_MODIFIED, 96 IOobject::NO_WRITE, 97 false 98 ) 99 ).lookup("simulationType") 100 ); 101 102 Info<< "Selecting turbulence model type " << modelType << endl; 103 104 turbulenceModelConstructorTable::iterator cstrIter = 105 turbulenceModelConstructorTablePtr_->find(modelType); 106 107 if (cstrIter == turbulenceModelConstructorTablePtr_->end()) 108 { 109 FatalErrorIn 110 ( 111 "turbulenceModel::New(const volVectorField&, " 112 "const surfaceScalarField&, transportModel&, const word&)" 113 ) << "Unknown turbulenceModel type " 114 << modelType << nl << nl 115 << "Valid turbulenceModel types:" << endl 116 << turbulenceModelConstructorTablePtr_->sortedToc() 117 << exit(FatalError); 118 } 119 120 return autoPtr<turbulenceModel> 121 ( 122 cstrIter()(U, phi, transport, turbulenceModelName) 123 ); http://www.cfd-online.com/Forums/ope...nderstand.html I've read other material about this topic, such as: Run-time type selection in OpenFOAM – the type name system but the point of when these tables are created and how isn't completely clear for me yet. All commentaries are appreciated! Santiago.
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D. Research Scientist Research Center for Computational Methods (CIMEC) - CONICET/UNL Tel: 54-342-4511594 Int. 7032 Colectora Ruta Nac. 168 / Paraje El Pozo (3000) Santa Fe - Argentina. http://www.cimec.org.ar |
|
September 14, 2014, 05:38 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
Greetings Santiago,
OK, this is a bit strenuous to detail every single step with showing the actual code (and it's already done in the other pages), so I'll have to describe this in a more conceptual way. First of all, let's approach a few initialization programming paradigms in a not very technical way, while keeping in mind that the technical terms and examples can be found here: http://www.cplusplus.com/doc/tutorial/
Now, with these concepts in mind, we can easily describe how the "RunTimeSelectionTable" mechanism works in OpenFOAM:
So, to answer your question, have a look at the file "src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H":
Best regards, Bruno
__________________
|
|
September 14, 2014, 08:45 |
|
#3 |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
Hi Santiago,
have you seen my blog post on the RTS implementation? If you go through the steps described there very carefully, you'll see that the table initialization is encapsulated in the nested class template generated by the macro. " That is it, the initialization of the addAlgorithmBaseWordConstructorToAlgorithmBaseTabl e_ object takes care of adding the “constructor” of the class to the run-time type selection table." This constructor calls the class static function that creates the table, in case it has not yet been created: Code:
addWordConstructorToTable ( const word& lookup = AlgorithmBaseType::typeName ) { constructWordConstructorTables(); The constructor of this object calls the static function responsible for creating the table. The function is static, because the table is a class-static object: there are as many tables as there are RTS enabled classes in OpenFOAM. If the RTS tables would be initialized as objects, the order of their initialization would be undefined, because that's just how C++ works. Therfore, the creation is packed in the static class function. Having them initialized in an undefined order might result in the attempt of the derived RTS class to add its constructor to the yet uninitialized RTS table of the base class. Boom. I had a lot of difficulties in writing that post, because the system is a bit complex: it uses nested class templates, static as well as global objects, etc... I hope this helps somewhat..
__________________
When asking a question, prepare a SSCCE. |
|
September 18, 2014, 15:52 |
|
#4 |
Senior Member
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 452
Rep Power: 24 |
Thanks Bruno for the complete explanation! Respect to the Tomislav question, yes I've read your material but still couldn't find the moment when tables are created. I've prepared some slides explaining the RTS with the macros and the calling sequence for a real case (extracted by debugging). The topic of when the tables are created is not explained but the mechanisms are shown. I've took some concepts and paragraphs of you and the credits are added,
https://drive.google.com/file/d/0B2l...it?usp=sharing I hope more people got involved and add their knowledge here!. Regards.
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D. Research Scientist Research Center for Computational Methods (CIMEC) - CONICET/UNL Tel: 54-342-4511594 Int. 7032 Colectora Ruta Nac. 168 / Paraje El Pozo (3000) Santa Fe - Argentina. http://www.cimec.org.ar |
|
September 28, 2014, 15:54 |
|
#5 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
@Santiago: Many thanks for compiling+sharing that document! I gave a quick read to it and didn't find anything wrong with it, but I didn't double-check every single detail either . Honestly, there is already tons of knowledge here on the forums, on the conferences/workshops, open+public+online courses and so on. The problem is that there are very few people that are compiling this information into more convenient/consolidated formats/locations. The best couple of places where I know this can be consolidated is at http://openfoamwiki.net and at the Cocoons Project, but people are usually more keen on using the formats/locations they're more familiar with ... hence information gets dispersed and only those who know what to look for will find the answers... oh well. Best regards, Bruno
__________________
|
|
October 10, 2014, 07:23 |
|
#6 | |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
Quote:
Cool that you assembled the document! I find that describing things like this often leads to new ways of understanding the problem. Also, thanks for adding credits, it would be great if you would add a link to that blog post in the future because cross-linking is what keeps the documentation alive and searchable... As for the RTS table initialization, if you still don't understand when this happens, I would propose you try something out.
Hope this helps... Tomislav
__________________
When asking a question, prepare a SSCCE. |
||
October 10, 2014, 07:36 |
|
#7 | |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
Quote:
Yes I perfectly agree that the information is dispersed, but better to have people actually contributing to the community and having fun while doing so, then forcing people to just use wiki, or just use CocoonsProject, or just post on the forum, or to use any other "established" system(s)... Variety is a sign evolution....
__________________
When asking a question, prepare a SSCCE. |
||
December 21, 2015, 04:08 |
|
#8 |
Member
Pekka Pasanen
Join Date: Feb 2012
Location: Finland
Posts: 87
Rep Power: 14 |
I feel like this is totally related to my problem with duplicate entry errors. Can someone help me how to implement own turbulence model properly in -dev or 3.0.x? I'm guessing the use of makeRASModel(kOmegaSSTSASnew), which uses makeTurbulenceModel.H, also creates entries for base classes laminar, RASModel and LESModel in the custom library. Solvers then complain about those duplicate entries.
More details here: http://www.cfd-online.com/Forums/ope...tml#post578060 |
|
December 21, 2015, 04:46 |
|
#9 |
Senior Member
|
@zordiack,
Do you have test case? On my laptop all I have got is sigSEGV if I try to use the library. |
|
December 21, 2015, 06:12 |
|
#10 |
Member
Pekka Pasanen
Join Date: Feb 2012
Location: Finland
Posts: 87
Rep Power: 14 |
Here is one, modified pitzDaily.
Compile the new libs (kOmegaSSTSASnew) from the github link, run blockMesh, run simpleFoam. |
|
December 21, 2015, 11:28 |
|
#11 |
Senior Member
|
Hi,
When you do Code:
makeBaseTurbulenceModel ( geometricOneField, volScalarField, compressibleTurbulenceModel, CompressibleTurbulenceModel, ThermalDiffusivity, fluidThermo ); See pull request on Github with "corrected" variant. I am not sure that it is canonical way of defining new models, yet it compiles and solver does not complain about duplicate entries. |
|
December 21, 2015, 12:31 |
|
#12 | |
Member
Pekka Pasanen
Join Date: Feb 2012
Location: Finland
Posts: 87
Rep Power: 14 |
Quote:
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wind turbine simulation | Saturn | CFX | 60 | July 17, 2024 06:45 |
An error has occurred in cfx5solve: | volo87 | CFX | 5 | June 14, 2013 18:44 |
Low-Re turbulence models | grtabor | OpenFOAM Running, Solving & CFD | 4 | February 15, 2010 11:25 |
RPM in Wind Turbine | Pankaj | CFX | 9 | November 23, 2009 05:05 |
air bubble is disappear increasing time using vof | xujjun | CFX | 9 | June 9, 2009 08:59 |