Question

i have two questions about the following code:

  211 template<class Type>
  212 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
  213 limitedSurfaceInterpolationScheme<Type>::flux //Return the interpolation  
                                                    //weighting factors.
  214 (                                             
  215     const GeometricField<Type, fvPatchField, volMesh>& phi
  216 ) const
  217 {
  218     return faceFlux_*this->interpolate(phi); //const surfaceScalarField& 
  219 }                                            //faceFlux_
  1. Line 211 - 213: The shown method flux(...) should be a method-template where the return-type is limitedSurfaceInterpolationScheme<Type> . What does tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > in this connection exactly mean?

  2. Line 218: What does faceFlux_*this do? faceFlux_ is member-object of class-template limitedSurfaceInterpolationScheme<Type> and *this is the content of the object method flux(...) was called on.

greetings streight

Was it helpful?

Solution

  1. tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > is return type of method flux from class limitedSurfaceInterpolationScheme<Type>. It's normal method from class template, not a method template.

  2. faceFlux_*this->interpolate(phi); is exactly the same as faceFlux_*(this->interpolate(phi)); - it's multiplication.

OTHER TIPS

Indeed clear writing would make it clear

  template<class Type>
  tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
  limitedSurfaceInterpolationScheme<Type>::flux(const GeometricField<Type,fvPatchField,volMesh> &phi ) const
   {
     return faceFlux_  *  this->interpolate(phi);  
   }     

So from above it is clear that it is implementation of function which defined like this in header.

template<class Type>
class limitedSurfaceInterpolationScheme
{
  //before  c++ 11 we had to write nested template right angle bracket with space > >
//return_type fun_name(argument) 
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >  flux(const GeometricField<Type,fvPatchField,volMesh> &phi ) const ;// constant member function

}

For more see How to define a template class in a .h file and implement it in a .cpp file

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top