CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   double dot tensor product (double inner product) implementation (

yogzebul July 28, 2011 07:55

double dot tensor product (double inner product) implementation


I'm trying to solve energy equation using a modified icoFoam solver.
I would like to take into account viscous dissipations in energy equation and to do that I need to calculate the double inner product between the viscous stress tensor and gradient of velocity.
I tried this:

//tensors computation
volTensorField gradU = fvc::grad(U);
volTensorField tau = nu * (gradU + gradU.T());

//solve the steady-state energy equation in temperature.
solve ( rho * Cp * fvm::div(phi, T) - fvm::laplacian(ka, T) - (tau && gradU));

but it doesn't compile leading to the error :

error: no match for ‘operator-’ in ‘Foam::operator-(const Foam::tmp<Foam::fvMatrix<Type> >&, const Foam::tmp<Foam::fvMatrix<Type> >&) [with Type = Foam::Vector<double>](((const Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > >&)((const Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > >*)(& Foam::fvm::laplacian(const Foam::dimensioned<Type2>&, Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&) [with Type = Foam::Vector<double>, GType = double](((Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&)(& T)))))))
- Foam::operator&&(const Foam::GeometricField<TypeR, PatchField, GeoMesh>&, const Foam::GeometricField<Type1, PatchField, GeoMesh>&) [with Type1 = Foam::Tensor<double>, Type2 = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>&)((const Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>*)(& gradU))))’

When I remove the term

- (tau && gradU)
of the formlation, the solver compiles perfectely...:confused:

So it's seems to be the double dot product implementation which doesn't work...

Any ideas ? (I use OpenFoam1.7.1)

Thanks in advance


Amir July 28, 2011 09:48

just a suggestion but I not sure it works:

volScalarField source = (tau && gradU);
solve ( rho * Cp * fvm::div(phi, T) - fvm::laplacian(ka, T) - source);

yogzebul July 28, 2011 11:28

Thank you Amir,

I understood my mistake !
T was declared as a vector field in my createField.H !

I don't understand anymore why it successed to compile without the inner product term. Although laplacian can be a vector field, I believed that the divergence one cannot...
Maybe the divergence of a tensor field is a vector field ?

Anyway, that's working perfectly now.

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