Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • openfoam openfoam
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 420
    • Issues 420
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 7
    • Merge requests 7
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • openfoamopenfoam
  • Issues
  • #1868
Closed
Open
Issue created Oct 03, 2020 by Guan Chaoran@Chaoran

Compiled error while using DimensionedField<tensor, volMesh>

I encountered a compiled error while using Dimensioned<tensor, volMesh>. Here is what I wrote in the createFields.H of the icoFoam:

volTensorField Ut = fvc::grad(U);
DimensionedField<tensor, volMesh> Ud = Ut.internalField();
Info << Ud << endl;
Info << Ud.T() << endl;

And the compiled error was:

error: no matching function for call to ‘T(const Foam::Field<Foam::Tensor<double> >&, const Foam::Field<Foam::Tensor<double> >&)’ Foam::T(result(), *this);

Then I found the Foam::T() 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 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. Actually I encountered this problem in openFOAM 8 version. But I checked the corresponding source codes of OpenFOAM V2006. The same problem seems also exists.

Assignee
Assign to
Time tracking