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/)
-   -   problems with U & U computation (https://www.cfd-online.com/Forums/openfoam-programming-development/92187-problems-u-u-computation.html)

ds-gti September 5, 2011 11:36

problems with U & U computation
 
Dear Foamers,

I want to compute the L2-norm. It works fine for p as it is a volScalarField but not for U. I also do not know, why the output line starting with Info work fine but doesn't if it is copied outside the line.

The current code is:
Code:

Udiff = U-Uexact;
 
pLErr = sqrt(magSqr(pdiff)); //is computed
ULErr = sqrt(Udiff.internalField() & Udiff.internalField()); //causes trouble

Info << "UErr " << sqrt(Udiff.internalField() & Udiff.internalField()) << endl; //is printed into log file

The current error message is the following, which I do not understand exactly.

Code:

no match for âoperator=â in âULErr = Foam::sqrt(const Foam::tmp<Foam::GeometricField<double, PatchField, GeoMesh> >&)
                                    [with PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]()â

/home/e322st30/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:1032: note: candidates are:

        void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=(const Foam::GeometricField<Type, PatchField, GeoMesh>&)
                                    [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]

/home/e322st30/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:1057: note:
void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&)
                                    [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]

/home/e322st30/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:1093: note:
void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=(const Foam::dimensioned<Type>&)
                                    [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]

Thanks for advise!
David

eugene September 6, 2011 04:33

Not 100% sure why you are getting the error, try putting "::" in front of the offending "sqrt". However, there is a simpler way to compute the vector magnitude that will definitely work:

ULErr = mag(U-Uexact);

ds-gti September 6, 2011 12:13

Thanks a lot for your reply!

The :: added gives:

Code:

T.C:191: error: cannot convert âFoam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >â to âdoubleâ for argument â1â to âdouble sqrt(double)â
make: *** [Make/linux64GccDPOpt/T.o] Error 1

and ULErr = mag(U-Uexact); is not working too...
Code:

no match for âoperator=â in âUL2 = Foam::mag(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]()â
/home/e322st30/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:1032: note: candidates are: void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=(const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/e322st30/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:1057: note:                void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/e322st30/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:1093: note:                void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=(const Foam::dimensioned<Type>&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
make: *** [Make/linux64GccDPOpt/TTest.o] Error 1

What to try next?

ds-gti September 7, 2011 06:12

ULErr is a volScalarField. Now it works.


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