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

method Foam::tmp<Foam::fv::gradScheme<Type> > Foam::fv::gradScheme<Type>::New

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 22, 2013, 06:37
Default method Foam::tmp<Foam::fv::gradScheme<Type> > Foam::fv::gradScheme<Type>::New
  #1
Senior Member
 
Join Date: Jan 2012
Posts: 166
Rep Power: 14
maybee is on a distinguished road
hi I have a question about the following method:

Code:
SNIPPET1
template<class Type>
33*Foam::tmp<Foam::fv::gradScheme<Type> > Foam::fv::gradScheme<Type>::New //Return a pointer to a new*gradScheme*created on freestore.
34*(
35* const fvMesh& mesh,
36* Istream& schemeData
37*)
38*{
39* if (fv::debug)
40* {
41* Info<< "gradScheme<Type>::New"
42* "(const fvMesh& mesh, Istream& schemeData) : "
43* "constructing gradScheme<Type>"
44* << endl;
45* }
46*
47* if (schemeData.eof())
48* {
49* FatalIOErrorIn
50* (
51* "gradScheme<Type>::New"
52* "(const fvMesh& mesh, Istream& schemeData)",
53* schemeData
54* ) << "Grad scheme not specified" << endl << endl
55* << "Valid grad schemes are :" << endl
56* << IstreamConstructorTablePtr_->sortedToc()
57* << exit(FatalIOError);
58* }
59*
60* const word schemeName(schemeData);
61*
62* typename IstreamConstructorTable::iterator cstrIter =
63* IstreamConstructorTablePtr_->find(schemeName);
64*
65* if (cstrIter == IstreamConstructorTablePtr_->end())
66* {
67* FatalIOErrorIn
68* (
69* "gradScheme<Type>::New"
70* "(const fvMesh& mesh, Istream& schemeData)",
71* schemeData
72* ) << "Unknown grad scheme " << schemeName << nl << nl
73* << "Valid grad schemes are :" << endl
74* << IstreamConstructorTablePtr_->sortedToc()
75* << exit(FatalIOError);
76* }
77*
78* return cstrIter()(mesh, schemeData); // typename IstreamConstructorTable::iterator cstrIter (siehe oben)
79*}
In line 78 the operator () of class HashTable is called on cstrIter:

Code:
//SNIPPET2
template<class T, class Key, class Hash>
  145 inline T& Foam::HashTable<T, Key, Hash>::operator()(const Key& key)
  146 {
  147     iterator iter = this->find(key);
  148 
  149     if (iter == this->end())
  150     {
  151         this->insert(key, T());
  152         return *find(key);
  153     }
  154     else
  155     {
  156         return *iter;
  157     }
  158 }
In SNIPPET1 line 78 what do the second braces "(mesh, schemeData)" mean/do?

greetings
maybee
maybee is offline   Reply With Quote

Old   December 22, 2013, 17:15
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Maybee,

You will find the "New" functionality in everthing runtime selectionable function. What it basically does is to construct a specific class; in your case a specific gradient scheme. The information in the parenteses is merely the objects needed to construct that specific gradient scheme.

Kind regards,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj 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
On the alpha Eqn of VOF method when using Immersed boundary method in OpenFOAM keepfit OpenFOAM 4 January 31, 2014 14:32
multiphaseEulerFoam: method mag(...) withing method solveAlphase() maybee OpenFOAM Programming & Development 0 December 21, 2013 10:13
[Gmsh] discretizer - gmshToFoam Andyjoe OpenFOAM Meshing & Mesh Conversion 13 March 14, 2012 04:35
Comparison: Finite Volume Method vs. Analytic Method m-fry Main CFD Forum 1 April 20, 2010 14:40
Code for most powerfull FDV Method D.S.Nasan Main CFD Forum 6 September 4, 2008 02:08


All times are GMT -4. The time now is 21:57.