Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
openfoam
openfoam
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 366
    • Issues 366
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 11
    • Merge Requests 11
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • openfoamopenfoam
  • Issues
  • #1868

Closed
Open
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
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None