View Issue Details

IDProjectCategoryView StatusLast Update
0003564OpenFOAMBugpublic2020-10-05 11:04
ReporterGCr Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Summary0003564: compiled errors while using DimensionedField<Type, GeoMesh>
DescriptionWhen using DimensionedField<tensor, volMesh>, there is compiling error: no matching function for call to ‘T(const Foam::Field<Foam::Tensor<double> >&, const Foam::Field<Foam::Tensor<double> >&)’ Foam::T(result(), *this);
Steps To Reproduce1.write the following code in createFields.H of the icoFoam application.
    volTensorField Ut = fvc::grad(U);
    DimensionedField<tensor, volMesh> Ud = Ut.internalField();
    Info << Ud.T() << endl;
2.compile and the error occurs.
Additional Informationthe Foam::T() global functions in the FieldFunctions.H is declared as:
    template<class Type> void T(Field<Type>& res, const UList<Type>& f);
However, the member function T() of the class dimensionedField<Type, GeoMesh> is defined as:
     template<class Type, class GeoMesh> tmp<DimensionedField<Type, GeoMesh>> DimensionedField<Type, GeoMesh>::T() const
    {
        tmp<DimensionedField<Type, GeoMesh>> result
        (
            DimensionedField<Type, GeoMesh>::New
            (
                name() + ".T()",
                mesh_,
                dimensions_
            )
        );
    Foam::T(result(), *this);
    return result;
    }
where the operator() of the tmp<T> return a const reference of T rather than a non-const reference which is required by Foam::T() global function.
So, I modify the above code:
    Foam::T(result(), *this);
into:
    Foam::T(result.ref(), *this);
After this modification, the compilation can be done successfully.
TagsNo tags attached.

Activities

henry

2020-10-05 11:04

manager   ~0011568

Resolved in OpenFOAM-dev by commit 077e35dc83a4488f63e5ba65356a0ca6e7ec0c0d
Resolved in OpenFOAM-8 by commit 540d813da95b928ab37722775257b43bf1e58936

Issue History

Date Modified Username Field Change
2020-10-05 02:30 GCr New Issue
2020-10-05 11:04 henry Assigned To => henry
2020-10-05 11:04 henry Status new => resolved
2020-10-05 11:04 henry Resolution open => fixed
2020-10-05 11:04 henry Fixed in Version => 8
2020-10-05 11:04 henry Note Added: 0011568