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

Warning:no return statement in function returning non-void [-Wreturn-type]

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 19, 2021, 03:21
Default Warning:no return statement in function returning non-void [-Wreturn-type]
  #1
New Member
 
Join Date: May 2020
Posts: 8
Rep Power: 4
3014214149 is on a distinguished road
Hi, everyone,

I'm compiling a new lib in Of-4.1. I met a warning"no return statement in function returning non-void [-Wreturn-type]" when compiling. The warning occurred in my code file "imcompressibleTurbuleneModel.H" line 140.

The code is:

#ifndef incompressibleTurbulenceModel_H
#define incompressibleTurbulenceModel_H

#include "turbulenceModel.H"
#include "geometricOneField.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

// Forward declarations
class fvMesh;

/*---------------------------------------------------------------------------*\
Class incompressibleTurbulenceModel Declaration
\*---------------------------------------------------------------------------*/

class incompressibleTurbulenceModel
:
public turbulenceModel
{

protected:

// Protected data

geometricOneField rho_;


// Protected member functions

//- ***HGW Temporary function to be removed when the run-time selectable
// thermal transport layer is complete
virtual void correctNut()
{}


private:

// Private Member Functions

//- Disallow default bitwise copy construct
incompressibleTurbulenceModel(const incompressibleTurbulenceModel&);

//- Disallow default bitwise assignment
void operator=(const incompressibleTurbulenceModel&);


public:

//- Runtime type information
TypeName("incompressibleTurbulenceModel");


// Constructors

//- Construct from components
incompressibleTurbulenceModel
(
const geometricOneField& rho,
const volVectorField& U,
const surfaceScalarField& alphaRhoPhi,
const surfaceScalarField& phi,
const word& propertiesName
);


//- Destructor
virtual ~incompressibleTurbulenceModel()
{}


// Member Functions

//- Return the laminar dynamic viscosity
virtual tmp<volScalarField> mu() const;

//- Return the laminar dynamic viscosity on patch
virtual tmp<scalarField> mu(const label patchi) const;

//- Return the turbulence dynamic viscosity
virtual tmp<volScalarField> mut() const;

//- Return the turbulence dynamic viscosity on patch
virtual tmp<scalarField> mut(const label patchi) const;

//- Return the effective dynamic viscosity
virtual tmp<volScalarField> muEff() const;

//- Return the effective dynamic viscosity on patch
virtual tmp<scalarField> muEff(const label patchi) const;

//- Return the effective stress tensor including the laminar stress
virtual tmp<volSymmTensorField> devReff() const = 0;

//- Return the source term for the momentum equation
virtual tmp<fvVectorMatrix> divDevReff(volVectorField& U) const = 0;

//- Return the source term for the momentum equation using NN surrogate
virtual tmp<fvVectorMatrix> divDevReff
(
volVectorField& U,
volTensorField& S,
volTensorField& R
) { } //line 140
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

Could anyone tell me how to resolve this warning? Many thanks!
3014214149 is offline   Reply With Quote

Old   January 19, 2021, 12:40
Default
  #2
Member
 
Fabian Friberg
Join Date: Dec 2020
Posts: 31
Rep Power: 4
lumpor is on a distinguished road
The { } at line 140 is the function body, which is empty. The file is a header file, which means it usually only has function declarations and not function implementations (except for some trivial functions like get functions).


The functions expects the body to include a "return x" line, where x is of type virtual tmp<fvVectorMatrix>. Since the function body is empty, nothing is returned.


Most likely it's supposed to be a function declaration and not a function implementation. Replacing {} with ; should work.
lumpor is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[blockMesh] Errors during blockMesh meshing Madeleine P. Vincent OpenFOAM Meshing & Mesh Conversion 51 May 30, 2016 11:51
Creating a new field from terms of the turbulence model HaZe OpenFOAM Programming & Development 15 November 24, 2014 14:51
Missing math.h header Travis FLUENT 4 January 15, 2009 12:48
Droplet Evaporation Christian Main CFD Forum 2 February 27, 2007 07:27
REAL GAS UDF brian FLUENT 6 September 11, 2006 09:23


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