Skip to content

Can't compile with eigenVectors()

Summary

Can't compile the code that calculates eigenVectors() of a volSymmTensorField directly.

Steps to reproduce

Same as the example case. eigenValues() is OK but eigenVectors() fails.

Example case

To avoid confusion I'm changing the example case a little bit.

//Psi_ is a volSymmTensorField
eig_=eigenValues(Psi_);
R_=eigenVectors(Psi_,eig_);

What is the current bug behaviour?

Can't compile the code.

What is the expected correct behavior?

In src/OpenFOAM/primitives/SymmTensor/symmTensor/symmTensor.H there's

vector eigenValues(const symmTensor& T); and

tensor eigenVectors(const symmTensor& T, const vector& eVals);

eigenValues() can compile which means the conversion from Foam::volSymmTensorField to const Foam::symmTensor is OK. So eigenVectors() should work as well.

Relevant logs and/or images

error: no matching function for call to 'eigenVectors'
    R_=eigenVectors(Psi_,eig_);
       ^~~~~~~~~~~~
/Users/gux215/OpenFOAM/OpenFOAM-v2012/src/OpenFOAM/lnInclude/tensor.H:94:17: note: 
      candidate function not viable: no known conversion from
      'Foam::volSymmTensorField' (aka 'GeometricField<SymmTensor<double>,
      fvPatchField, Foam::volMesh>') to 'const Foam::tensor' (aka
      'const Tensor<double>') for 1st argument
Tensor<complex> eigenVectors
                ^
/Users/gux215/OpenFOAM/OpenFOAM-v2012/src/OpenFOAM/lnInclude/symmTensor.H:95:8: note: 
      candidate function not viable: no known conversion from
      'Foam::volSymmTensorField' (aka 'GeometricField<SymmTensor<double>,
      fvPatchField, Foam::volMesh>') to 'const Foam::symmTensor' (aka 'const
      SymmTensor<double>') for 1st argument
tensor eigenVectors

Also tested with GCC 8 in a Linux VM

/usr/lib/openfoam/openfoam2012/src/OpenFOAM/lnInclude/symmTensor.H:95:8: note: candidate: ‘Foam::tensor Foam::eigenVectors(const symmTensor&, const vector&)’
 tensor eigenVectors
        ^~~~~~~~~~~~
/usr/lib/openfoam/openfoam2012/src/OpenFOAM/lnInclude/symmTensor.H:95:8: note:   no known conversion for argument 1 from ‘Foam::volSymmTensorField’ {aka ‘Foam::GeometricField<Foam::SymmTensor<double>, Foam::fvPatchField, Foam::volMesh>’} to ‘const symmTensor&’ {aka ‘const Foam::SymmTensor<double>&’}

Environment information

  • OpenFOAM version : v2012
  • Operating system : macOS/Linux
  • Hardware info : x86
  • Compiler : Clang/GCC

Possible fixes

    forAll(Psi_, celli) {
        eig_[celli]=eigenValues(Psi_[celli]);
        R_[celli]=eigenVectors(Psi_[celli],eig_[celli]);
    }

Can be compiled successfully, but that's too stupid. It should be doable without using forAll.

Edited by Guanyang Xue