method surfaceSum(...) of class fvc
hi,
I' m having problems with understanding the method surfaceSum(...) below: Code:
template<class Type> Code:
In method surfaceSum(...) the input parameter tssf is passed to "another" surfaceSum(...) method. Wouldn t that cause some kind of endless loop, because in the new called method surfaceSum(...) the method gets called again and so on? |
The ()-operator strips the object from it's tmp-"shell", so the following call to surfaceSum leads to a different method, namely one that is called when a GeometricField is passed: http://foam.sourceforge.net/docs/cpp...ce.html#l00138
|
hi again,
Quote:
All I can see in the method operator () is that in line 215 it is proved if the object is tmp (temporary) and in line 217 if the pointer ptr_ is not NULL. If both these conditions are fullfilled the pointer ptr_ is dereferenced and returned in line 224. |
Code:
224* return *ptr_; It dereferences the pointer stored in the tmp<> object, and returns the dereferenced pointer. * What happens if you dereference a pointer pointing to an object? You get access to that object. Note that in our case, the object in question is a vol*Field. Does that make things clear? Recommended reading: http://openfoamwiki.net/index.php/OpenFOAM_guide/tmp |
Quote:
2. Furthermore, how do you know it is a vol*Field? I have the following source code: Code:
scalarField sumPhi Code:
const surfaceScalarField& phi Code:
→ template<class Type, template<class> class PatchField, class GeoMesh> |
Quote:
tmp<GeometricField<scalar, PatchField, GeoMesh> > tMag stores a pointer to a GeometricField<scalar, PatchField, GeoMesh>, which is the same thing as a volScalarField. So when you call tMag() you will end up with the underlying volScalarField. - Anton |
:D , now I got it. Just one more question:
How did you know that ptr_ points to the geometricfield and not to the tmp<"geometricfield">? |
On line 330 of the code you posted a new object of GeometricField<> is allocated and it's pointer is passed on to the constructor of tmp<>: http://foam.sourceforge.net/docs/cpp...bf3c32f4c76004
|
Ok, thx alot. Question solved.
|
All times are GMT -4. The time now is 20:18. |