CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

gSum: no matching function call

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 20, 2017, 08:16
Default gSum: no matching function call
  #1
New Member
 
Gunther
Join Date: Jan 2017
Posts: 2
Rep Power: 0
Gunther is on a distinguished road
Hey,

I try to compile a code which used to compile in OF 2.3, but in version 4.1 it doesn't do so any more. I receive the error: no matching function for call to gSum... (see below) Does anyone know if a gSum function is relocated or removed in the latest OF? Many thanks in advance!

The piece of the code which the error is called from is as follows:
Code:
#include "pollutant.H"
#include "fvCFD.H"
#include "IOmanip.H"

void pollutant::balance()
{
    forAllConstIter(HashTable<isotope*>, isotopes_, iter)
    {
        const isotope& nuclide = *iter();
        const volScalarField& Ci = nuclide.C();
        Info << "Total amount of " << Ci.name()
             << " in the system: " << gSum(Ci.internalField()*mesh_.V()) 
	     << endl;
    }
}
The complete error message is the following:
HTML Code:
pollutant.C: In member function ‘void Foam::pollutant::balance()’:
pollutant/pollutant.C:443:72: error: no matching function for call to ‘gSum(Foam::tmp<Foam::DimensionedField<double, Foam::volMesh> >)’
              << " in the system: " << gSum(Ci.internalField()*mesh_.V()) 
                                                                        ^
pollutant/pollutant.C:443:72: note: candidates are:
In file included from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/Field.C:870:0,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/Field.H:405,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/scalarField.H:38,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/dimensionSet.H:46,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/dimensionedType.H:40,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/dimensionedScalar.H:38,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/dimensionedTypes.H:31,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/GeometricField.H:43,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/GeometricScalarField.H:38,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/GeometricFields.H:34,
                 from OpenFOAM/OpenFOAM-4.1/src/finiteVolume/lnInclude/volFields.H:37,
                 from pollutant/pollutant.H:37,
                 from pollutant/pollutant.C:26:
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFunctions.C:543:24: note: template<class Type> Type Foam::gSum(const Foam::UList<T>&, Foam::label)
 G_UNARY_FUNCTION(Type, gSum, sum, sum)
                        ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFunctions.C:533:12: note: in definition of macro ‘G_UNARY_FUNCTION’
 ReturnType gFunc(const UList<Type>& f, const label comm)                       \
            ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFunctions.C:543:24: note:   template argument deduction/substitution failed:
 G_UNARY_FUNCTION(Type, gSum, sum, sum)
                        ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFunctions.C:533:12: note: in definition of macro ‘G_UNARY_FUNCTION’
 ReturnType gFunc(const UList<Type>& f, const label comm)                       \
            ^
pollutant/pollutant.C:443:72: note:   ‘Foam::tmp<Foam::DimensionedField<double, Foam::volMesh> >’ is not derived from ‘const Foam::UList<T><< " in the system: " << gSum(Ci.internalField()*mesh_.V()) 
                                                                        ^
In file included from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/Field.C:870:0,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/Field.H:405,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/scalarField.H:38,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/dimensionSet.H:46,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/dimensionedType.H:40,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/dimensionedScalar.H:38,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/dimensionedTypes.H:31,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/GeometricField.H:43,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/GeometricScalarField.H:38,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/GeometricFields.H:34,
                 from OpenFOAM/OpenFOAM-4.1/src/finiteVolume/lnInclude/volFields.H:37,
                 from pollutant/pollutant.H:37,
                 from pollutant/pollutant.C:26:
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFunctions.C:543:24: note: template<class Type> Type Foam::gSum(const Foam::tmp<Foam::Field<Type> >&)
 G_UNARY_FUNCTION(Type, gSum, sum, sum)
                        ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFunctions.C:303:12: note: in definition of macro ‘TMP_UNARY_FUNCTION’
 ReturnType Func(const tmp<Field<Type>>& tf1)                                   \
            ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFunctions.C:543:1: note: in expansion of macro ‘G_UNARY_FUNCTION’
 G_UNARY_FUNCTION(Type, gSum, sum, sum)
 ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFunctions.C:543:24: note:   template argument deduction/substitution failed:
 G_UNARY_FUNCTION(Type, gSum, sum, sum)
                        ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFunctions.C:303:12: note: in definition of macro ‘TMP_UNARY_FUNCTION’
 ReturnType Func(const tmp<Field<Type>>& tf1)                                   \
            ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFunctions.C:543:1: note: in expansion of macro ‘G_UNARY_FUNCTION’
 G_UNARY_FUNCTION(Type, gSum, sum, sum)
 ^
pollutant/pollutant.C:443:72: note:   mismatched types ‘Foam::Field<Type>’ and ‘Foam::DimensionedField<double, Foam::volMesh><< " in the system: " << gSum(Ci.internalField()*mesh_.V()) 
                                                                        ^
pollutant/pollutant.C:443:72: note:   ‘Foam::tmp<Foam::DimensionedField<double, Foam::volMesh> >’ is not derived from ‘const Foam::tmp<Foam::Field<Type> >’
In file included from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldField.C:390:0,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldField.H:198,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/GeometricField.H:45,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/GeometricScalarField.H:38,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/GeometricFields.H:34,
                 from OpenFOAM/OpenFOAM-4.1/src/finiteVolume/lnInclude/volFields.H:37,
                 from pollutant/pollutant.H:37,
                 from pollutant/pollutant.C:26:
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:559:24: note: template<template<class> class Field, class Type> Type Foam::gSum(const Foam::FieldField<Field, Type>&)
 G_UNARY_FUNCTION(Type, gSum, sum, sum)
                        ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:549:12: note: in definition of macro ‘G_UNARY_FUNCTION’
 returnType gFunc(const FieldField<Field, Type>& f)                             \
            ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:559:24: note:   template argument deduction/substitution failed:
 G_UNARY_FUNCTION(Type, gSum, sum, sum)
                        ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:549:12: note: in definition of macro ‘G_UNARY_FUNCTION’
 returnType gFunc(const FieldField<Field, Type>& f)                             \
            ^
pollutant/pollutant.C:443:72: note:   ‘Foam::tmp<Foam::DimensionedField<double, Foam::volMesh> >’ is not derived from ‘const Foam::FieldField<Field, Type><< " in the system: " << gSum(Ci.internalField()*mesh_.V()) 
                                                                        ^
In file included from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldField.C:390:0,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldField.H:198,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/GeometricField.H:45,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/GeometricScalarField.H:38,
                 from OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/GeometricFields.H:34,
                 from OpenFOAM/OpenFOAM-4.1/src/finiteVolume/lnInclude/volFields.H:37,
                 from pollutant/pollutant.H:37,
                 from pollutant/pollutant.C:26:
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:559:24: note: template<template<class> class Field, class Type> Type Foam::gSum(const Foam::tmp<Foam::FieldField<Field, Type> >&)
 G_UNARY_FUNCTION(Type, gSum, sum, sum)
                        ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:400:12: note: in definition of macro ‘TMP_UNARY_FUNCTION’
 returnType func(const tmp<FieldField<Field, Type>>& tf1)                       \
            ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:559:1: note: in expansion of macro ‘G_UNARY_FUNCTION’
 G_UNARY_FUNCTION(Type, gSum, sum, sum)
 ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:559:24: note:   template argument deduction/substitution failed:
 G_UNARY_FUNCTION(Type, gSum, sum, sum)
                        ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:400:12: note: in definition of macro ‘TMP_UNARY_FUNCTION’
 returnType func(const tmp<FieldField<Field, Type>>& tf1)                       \
            ^
OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/FieldFieldFunctions.C:559:1: note: in expansion of macro ‘G_UNARY_FUNCTION’
 G_UNARY_FUNCTION(Type, gSum, sum, sum)
 ^
pollutant/pollutant.C:443:72: note:   mismatched types ‘Foam::FieldField<Field, Type>’ and ‘Foam::DimensionedField<double, Foam::volMesh><< " in the system: " << gSum(Ci.internalField()*mesh_.V()) 
                                                                        ^
pollutant/pollutant.C:443:72: note:   ‘Foam::tmp<Foam::DimensionedField<double, Foam::volMesh> >’ is not derived from ‘const Foam::tmp<Foam::FieldField<Field, Type> >’
make: *** [Make/linux64GccDPInt32Opt/pollutant/pollutant.o] Error 1

Last edited by Gunther; January 21, 2017 at 10:24.
Gunther is offline   Reply With Quote

Old   January 23, 2017, 03:36
Default
  #2
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 339
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
If you run
Code:
git grep gSum
in the OpenFOAM-dev repository, you will find that OpenFOAM still uses gSum().
I assume that the necessary headers changed, have a look on current code which uses gSum().
GerhardHolzinger is offline   Reply With Quote

Old   January 23, 2017, 03:43
Default
  #3
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,933
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Code:
pollutant/pollutant.C:443:72: error: no matching function for call to ‘gSum(Foam::tmp<Foam::DimensionedField<double, Foam::volMesh> >)’
Well, error is rather self-explanatory. * operation returns tmp object, gSum can not operate on tmp objects. You need either to dereference tmp using () operator, so your call becomes something like:

Code:
gSum((Ci.internalField()*mesh_.V())())
or you can try to create volScalarField from tmp before doing gSum.
reza2031, ancolli and rajibroy like this.
alexeym is offline   Reply With Quote

Old   January 24, 2017, 16:38
Default
  #4
New Member
 
Gunther
Join Date: Jan 2017
Posts: 2
Rep Power: 0
Gunther is on a distinguished road
Hey Alexey and Gerhard,

Thank you both for your answers. The dereferencing with the () operator worked. So, special thanks to you Alexey! Nice solution
Gunther is offline   Reply With Quote

Reply

Tags
error, gsum, incompatible code


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Other] refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 2 November 11, 2021 11:04
Elementwise multiplication operator johndeas OpenFOAM Running, Solving & CFD 3 March 9, 2019 13:03
Compiling User Fortran with CFX 14.0 on Win64 Raijin Thunderkeg CFX 29 March 9, 2016 11:45
latest OpenFOAM-1.6.x from git failed to compile phsieh2005 OpenFOAM Bugs 25 February 9, 2010 04:37
Droplet Evaporation Christian Main CFD Forum 2 February 27, 2007 06:27


All times are GMT -4. The time now is 20:32.