CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Divergence of a volTensorField (

SpinDoctor January 31, 2013 07:49

Divergence of a volTensorField
I am a physicist trying to write an OpenFOAM solver for a computational spin dynamics problem. I am getting a compiler error at the line where I attempt to take the divergence of a volTensorField times a surfaceScalarField. Here is a simplified version of the code:

#include "fvCFD.H"

int main(int argc, char *argv[])

#include "setRootCase.H"
#include "createTime.H"
#include "createMeshNoClear.H"
#include "initContinuityErrs.H"

* Create:
* volVectorField M
* volVectorField Omega
* surfaceScalarField Deff
#include "createFields.H"

while (runTime.loop())
volTensorField Gamma(fvc::grad(M));

// The following line gives this compilation error:
// error: no matching function for call to
// ‘Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField,Foam::volMesh>::
// GeometricField(Foam::tmp<Foam::fvMatrix<Foam::Tens or<double> > >)’

volVectorField foo(fvm::div(Deff, Gamma));

return 0;

The exact error message is this:

forum.cpp:35:49: error: no matching function for call to ‘Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::tmp<Foam::fvM atrix<Foam::Tensor<double> > >)’

I expected that the compiler would match the above code with the following declaration from fvmDiv.H :

template<class Type>
tmp<fvMatrix<Type> > div
const surfaceScalarField&,
const GeometricField<Type, fvPatchField, volMesh>&

Compiler /OS info: g++ (SUSE Linux 12.2) 4.7.1 20120723 [gcc-4_7-branch revision 189773]

Any advice would be appreciated.


All times are GMT -4. The time now is 00:24.