|
[Sponsors] |
July 18, 2011, 10:52 |
NoRepository
|
#1 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
Now that I'm working with templates, would someone be able to tell me the purpose of the "NoRepository" flag? I've been ignoring it until now, but I'm thinking I'm limiting the compatibility of my code.
|
|
July 19, 2011, 18:35 |
|
#2 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi David,
I read something about this sometime ago... I did a search now here in the forum and picked up this thread: http://www.cfd-online.com/Forums/ope...epository.html - mmm, it doesn't say much, except for this: Quote:
What this entails is the following scenario:
So I can only assume that this is an optimization solution, along with respecting the coding standards defined for OpenFOAM, as well as similar to using inline functions/methods: keeping the template code objects close to their definitions will keep things nice and optimum. Perhaps going back to OpenFOAM 1.0 or before that, we could figure out the transition period that lead to this conclusion... Best regards, Bruno
__________________
|
||
July 30, 2011, 15:07 |
|
#3 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
After brainstorming a bit more on this subject, as well as reading up on the subject, I'll write down my findings here.
The article "How To Organize Template Source Code" explains precisely the information we are looking for about templates. To sum up:
Bruno
__________________
|
|
August 3, 2011, 12:08 |
|
#4 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
Thank-you, Bruno. Very well explained!
|
|
September 26, 2011, 08:49 |
|
#5 |
Senior Member
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17 |
Hi Bruno,
So if I am developing a BC that has no template definitions, based on a BC that has template classes, it is safe to remove the #ifdef NoRepository part and yet still be able to use other template classes from other libraries (e.g. Field<vector>). Is that true? Thanks Hisham |
|
September 26, 2011, 09:19 |
|
#6 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Hisham,
If your new BC is simply a class, and not a template class, then you don't need "NoRepository". Best regards, Bruno
__________________
|
|
June 2, 2012, 18:44 |
|
#8 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
I was searching for the possibility of somehow unroll templates and stumbled on this page: http://gcc.gnu.org/onlinedocs/gcc/Te...antiation.html I was going to quote part of the page, but then kept reading and concluded that there is too much good stuff to be read about this "template repository" business! Happy reading! Bruno PS: and no, I haven't found any preprocessor that unrolls templates... and have my doubts that such exists
__________________
|
|
June 2, 2012, 18:57 |
|
#9 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
I'm not sure if I'm addressing what you mean by "unrolling", but you should check out the feature/blockCoupledFVM branch in the OpenFOAM-extend repository:
http://openfoam-extend.git.sourcefor...lockCoupledFVM We've implemented a preprocessor "for loop". The main files that do this are src/VectorN/include/VectorNRunMacro.H, and src/OpenFOAM/include/customUserDefines.H You'll see it is a fairly simple solution that keeps the "bloat" of preprocessor directives isolated to two files. It solves a problem where we couldn't compile all possible instantiations of VectorN<int> because it became too large and crashed the compile. But we still wanted users to be able to choose which ones to compile for their purposes. Maybe this isn't related to what you mean.
__________________
~~~ Follow me on twitter @DavidGaden |
|
June 2, 2012, 19:28 |
|
#10 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi David,
Thanks for the quick answer, but unfortunately no, I wasn't thinking of unrolling in the standard sense of for-loop unrolling. I can't think of a better name for it, but my idea for unrolling templates was along the lines of:
But I guess this is one of those holy grail things... Best regards, Bruno
__________________
|
|
June 3, 2012, 14:37 |
|
#11 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
When we were trying to solve the VectorN problem, we looked into solutions that combine scripting languages with preprocessors. M4 was one idea... but I didn't want to add to OpenFOAM prerequisites, so I never really looked into its capabilities. Their site is old school.
__________________
~~~ Follow me on twitter @DavidGaden |
|
May 1, 2013, 14:54 |
|
#12 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
Just to complement my (very) old post #3, I've found various examples in OpenFOAM of template repositories put into practice. The OpenFOAM's thermodynamics libraries rely heavily on using multi-layered templated classes such as this example: Code:
thermoType hRhoThermo<pureMixture<constTransport<specieThermo<hConstThermo<perfectGas>>>>>; Using OpenFOAM 2.2.x as reference, here's an example:
Quote:
I'll see if I can come up with an example of this in the next hour and I'll edit the post accordingly . edit: see this thread: http://www.cfd-online.com/Forums/ope...tml#post424491 - specifically the post #11 Best regards, Bruno
__________________
Last edited by wyldckat; May 1, 2013 at 16:36. Reason: see "edit:" |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
New boundary condition and %23ifdef NoRepository | tehache | OpenFOAM Running, Solving & CFD | 9 | May 29, 2007 06:56 |