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/)
-   -   No matching function for call to "FOAM::GeometricField<double, FOAM::fvPatchField, >" (https://www.cfd-online.com/Forums/openfoam-programming-development/240129-no-matching-function-call-foam-geometricfield-double-foam-fvpatchfield.html)

Teresa Sun December 14, 2021 02:52

No matching function for call to "FOAM::GeometricField<double, FOAM::fvPatchField, >"
 
Dear Foamers,
This issues happen while building a new eddy viscosity model which is based on Smagorinsky model.


Error messages

Code:

../turbulenceModels/lnInclude/QR.C:91:10: error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField()’
  91 |          0;
      |          ^
In file included from /software/software/OpenFOAM/v2006-foss-2020a/OpenFOAM-v2006/src/OpenFOAM/lnInclude/GeometricField.H:792,
                from /software/software/OpenFOAM/v2006-foss-2020a/OpenFOAM-v2006/src/OpenFOAM/lnInclude/GeometricScalarField.H:40,
                from /software/software/OpenFOAM/v2006-foss-2020a/OpenFOAM-v2006/src/OpenFOAM/lnInclude/GeometricFields.H:40,
                from /software/software/OpenFOAM/v2006-foss-2020a/OpenFOAM-v2006/src/finiteVolume/lnInclude/volFields.H:39,
                from /software/software/OpenFOAM/v2006-foss-2020a/OpenFOAM-v2006/src/finiteVolume/lnInclude/nearWallDist.H:41,
                from ../turbulenceModels/lnInclude/turbulenceModel.H:49,
                from ../turbulenceModels/lnInclude/TurbulenceModel.H:40,
                from lnInclude/IncompressibleTurbulenceModel.H:42,
                from turbulentTransportModels/turbulentTransportModels.H:28,
                from turbulentTransportModels/turbulentTransportModels.C:28:



The modified codes are
Code:

// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //

template<class BasicTurbulenceModel>               
tmp<volScalarField> QR<BasicTurbulenceModel>::k
(                       
    const tmp<volTensorField>& gradU               
) const
{                                           
      volSymmTensorField  D(symm(gradU));     
      volScalarField      q1(dimensionedScalar("q1", dimensionSet(0, 0, -2, 0, 0, 0, 0), 1e-5)); 
//    volScalarField      k1(dimensionedScalar("k1", dimensionSet(0, 0, -1, 0, 0, 0, 0), 0)); 
      volScalarField      r(max(-det(D),dimensionedScalar("r1", dimensionSet(0, 0, -3, 0, 0, 0, 0), 0)));
      volScalarField      q((1.0/2.0)*(dev(D) && D));
       


//    if ( q <= (dimensionedScalar("q1", dimensionSet(0, 0, -2, 0, 0, 0, 0), 1e-6))) 
    if ( q <= q1 ) 
    {       
    return tmp<volScalarField>
    (
        new volScalarField
        (
                IOobject
                (
                    IOobject::groupName("k", this->alphaRhoPhi_.group()),
                    this->runTime_.timeName(),
                    this->mesh_
                ),
//              dimensionedScalar ("k",dimensionSet(0, 0, -1, 0, 0, 0, 0), 0);
//                this->k = k1;
                0;
        )     
      );
      }       
      return tmp<volScalarField>
      (
        new volScalarField
        (
                IOobject
                (
                        IOobject::groupName("k", this->alphaRhoPhi_.group()),
                        this->runTime_.timeName(),
                        this->mesh_
                ),
                mag(r)/q;
        )
      );       
}

, in which the uncommand lines were several attempts which didn't work.

Any pointer would be great appreciated!

Teresa

olesen December 14, 2021 12:10

Quote:

Originally Posted by Teresa Sun (Post 818460)
Code:

../turbulenceModels/lnInclude/QR.C:91:10: error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField()’
  91 |          0;
      |          ^


...
    return tmp<volScalarField>
    (
        new volScalarField
        (
            IOobject
            (
                IOobject::groupName("k", this->alphaRhoPhi_.group()),
                this->runTime_.timeName(),
                this->mesh_
            ),
//              dimensionedScalar ("k",dimensionSet(0, 0, -1, 0, 0, 0, 0), 0);
//            this->k = k1;
            0;
        )     
      );



That's the problem when you stare at code too long. You have an ';' in your creation of

tmp<volScalarField>. The flood of compiler errors doesn't really help with finding it.

olesen December 14, 2021 12:17

[QUOTE=Teresa Sun;818460]
Code:

      return tmp<volScalarField>
      (
    new volScalarField
    (
        IOobject
        (
            IOobject::groupName("k", this->alphaRhoPhi_.group()),
            this->runTime_.timeName(),
            this->mesh_
        ),
        mag(r)/q;
    )
      );


For that type of code it can be a bit clearer if you use the forwarding factory method instead. Eg,


Code:

return tmp<volScalarField>::New
(
    IOobject
    (
        IOobject::groupName("k", this->alphaRhoPhi_.group()),
        this->runTime_.timeName(),
        this->mesh_
    ),
    mag(r)/q
);

This saves one level of brackets and indentation. I think it makes the code more readable. Also if you don't need to register the field, you can also use volScalarField::New directly (various different forms of that one) to save some typing.

Teresa Sun December 16, 2021 08:44

Hi Mark,
thanks for your correction and will change the layout later. The mistake was way too straightforward.
But after correcting the issue is as same as before. Is that because something went wrong about the conversion between dimensioedScalar and volScalarField?

The is issue
Quote:

../turbulenceModels/lnInclude/QR.C:51:25: error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject, Foam::volScalarField&, Foam::dimensionedScalar)’
51 | volScalarField q1
| ^~
In file included from /software/software/OpenFOAM/v2006-foss-2020a/OpenFOAM-v2006/src/OpenFOAM/lnInclude/GeometricField.H:792,
from /software/software/OpenFOAM/v2006-foss-2020a/OpenFOAM-v2006/src/OpenFOAM/lnInclude/GeometricScalarField.H:40,
from /software/software/OpenFOAM/v2006-foss-2020a/OpenFOAM-v2006/src/OpenFOAM/lnInclude/GeometricFields.H:40,
from /software/software/OpenFOAM/v2006-foss-2020a/OpenFOAM-v2006/src/finiteVolume/lnInclude/volFields.H:39,
from /software/software/OpenFOAM/v2006-foss-2020a/OpenFOAM-v2006/src/finiteVolume/lnInclude/nearWallDist.H:41,
from ../turbulenceModels/lnInclude/turbulenceModel.H:49,
from ../turbulenceModels/lnInclude/TurbulenceModel.H:40,
from lnInclude/IncompressibleTurbulenceModel.H:42,
from turbulentTransportModels/turbulentTransportModels.H:28,
from turbulentTransportModels/turbulentTransportModels.C:28:
/software/software/OpenFOAM/v2006-foss-2020a/OpenFOAM-v2006/src/OpenFOAM/lnInclude/GeometricField.C:695:1: note: candidate: ‘Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&, const wordList&, const wordList&) [with Type = double; PatchField = Foam::fvPatchField; GeoMesh = Foam::volMesh; Foam::wordList = Foam::List<Foam::word>]’
695 | Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
The new codes are
Quote:

volScalarField q1
(
IOobject
(
"q1",
this->runTime_.timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
q1,
dimensionedScalar(dimensionSet(0, 0, -2, 0, 0, 0, 0), 1e-5)
);

volScalarField r(max(-det(D),dimensionedScalar("r1", dimensionSet(0, 0, -3, 0, 0, 0, 0), 0)));
volScalarField q((1.0/2.0)*dev(D) && D);


if ( q <= q1 )
{
return 0;
}

return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
IOobject::groupName("k", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_
),
mag(r)/q
)
);

olesen December 16, 2021 09:58

Quote:

Originally Posted by Teresa Sun (Post 818729)
Hi Mark,
thanks for your correction and will change the layout later. The mistake was way too straightforward.
But after correcting the issue is as same as before. Is that because something went wrong about the conversion between dimensioedScalar and volScalarField?


Not really the problem. At this point you really need to check how the fields are defined, which arguments are expected etc. Either in the header or here: https://www.openfoam.com/documentati...d.html#details


See which constructors are available and pick the one that you think you are using. In your current case you will notice that you are trying something, but not really sure what.


All times are GMT -4. The time now is 12:03.