CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   why the function linearInterpolate(phi) can be directly used? (https://www.cfd-online.com/Forums/openfoam-programming-development/162143-why-function-linearinterpolate-phi-can-directly-used.html)

huyidao November 4, 2015 10:12

why the function linearInterpolate(phi) can be directly used?
 
Hello.
In this wiki page
https://openfoamwiki.net/index.php/O...eInterpolation,include this sentence:
"The linear scheme is explicitly included with fvCFD.H, a file that at the top level of most solvers. To specifically force a linear interpolation:
linearInterpolate(phi);"
But I do not understand this,can anyone explain this to me why in the createPhi.H the linearInterpolate(U) can be directly used?THe linearInterpolate() is a part of the class linear..,it confuses me.

hk318i November 5, 2015 05:50

Quote:

Originally Posted by huyidao (Post 571865)
Hello.
In this wiki page
https://openfoamwiki.net/index.php/O...eInterpolation,include this sentence:
"The linear scheme is explicitly included with fvCFD.H, a file that at the top level of most solvers. To specifically force a linear interpolation:
linearInterpolate(phi);"
But I do not understand this,can anyone explain this to me why in the createPhi.H the linearInterpolate(U) can be directly used?THe linearInterpolate() is a part of the class linear..,it confuses me.

Hello,

This sentence means that fvCFD.H includes the linear interpolation (linear.H), therefore it is available for every solver.

linearInterpolate() can be directly used because it is a function not a class. To be more precise it is a template function which calls surfaceInterpolationScheme::interpolate static function. linearInterpolate() is defined in linear.H.

Bw,
Hassan

huyidao November 5, 2015 06:34

Thank you.
I finally realize my stupid mistake..I did not read the code carefully..
The function linearInterpolate is not part of class linear.It is defined in the namespace Foam.

Quote:

template<class Type>
class linear
:
public surfaceInterpolationScheme<Type>
{
// Private Member Functions
//- Disallow default bitwise assignment
void operator=(const linear&);
public:
//- Runtime type information
TypeName("linear");
// Constructors
//- Construct from mesh
linear(const fvMesh& mesh)
:
surfaceInterpolationScheme<Type>(mesh)
{}
//- Construct from Istream
linear(const fvMesh& mesh, Istream&)
:
surfaceInterpolationScheme<Type>(mesh)
{}
//- Construct from faceFlux and Istream
linear
(
const fvMesh& mesh,
const surfaceScalarField&,
Istream&
)
:
surfaceInterpolationScheme<Type>(mesh)
{}
// Member Functions
//- Return the interpolation weighting factors
tmp<surfaceScalarField> weights
(
const GeometricField<Type, fvPatchField, volMesh>&
) const
{
return this->mesh().surfaceInterpolation::weights();
}
};
//**********************************************
//**********************************************
//**********************************************
//class linear ends here..
//The linearInterpolate is not a part of class linear
//It is defined in namespace Foam
//**********************************************
// *********************************************
//**********************************************
template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
linearInterpolate(const GeometricField<Type, fvPatchField, volMesh>& vf)
{
return surfaceInterpolationScheme<Type>::interpolate
(
vf,
vf.mesh().surfaceInterpolation::weights()
);
}
template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
linearInterpolate(const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvf)
{
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tinterp =
linearInterpolate(tvf());
tvf.clear();
return tinterp;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam


All times are GMT -4. The time now is 04:23.