This question is about openFoam (foam extend v4) C++ but I believe the issue I have is a fundamental C++ programming problem.
I am trying to use the function autoCreateOmega
whose prototype can be found in
foam-extend-4.0/src/turbulenceModels/incompressible/RAS/lnInclude/backwardsCompatibilityWallFunctions.H
and the definition is in the corresponding backwardsCompatibilityWallFunctions.C
.
In my solver.C file I have the following at the top:
#include "fvCFD.H"
#include "simpleControl.H"
#include "wallDist.H"
#include "backwardsCompatibilityWallFunctions.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
simpleControl simple(mesh);
# include "createFields.H"
And part of my createFields.H
looks like this:
Info<< "Reading field omega\n" << endl;
volScalarField omega
(
IOobject
(
"omega",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
//mesh
autoCreateOmega("omega", mesh, U.db())
);
When I try to compile this solver I get the following error:
In file included from solver.C:48:0:
createFields.H: In function ‘int main(int, char**)’:
createFields.H:50:46: error: ‘autoCreateOmega’ was not declared in this scope
autoCreateOmega("omega", mesh, U.db())
^
createFields.H:50:46: note: suggested alternative:
In file included from solver.C:37:0:
/home/foam/foam-extend-4.0/src/turbulenceModels/incompressible/RAS/lnInclude/backwardsCompatibilityWallFunctions.H:98:25: note: ‘Foam::incompressible::autoCreateOmega’
tmp<volScalarField> autoCreateOmega
^
solver.dep:714: recipe for target 'Make/linux64GccDPOpt/solver.o' failed
make: *** [Make/linux64GccDPOpt/solver.o] Error 1
why doesnt including "backwardsCompatibilityWallFunctions.H"
allow me to use autoCreateOmega in my program? Any help is much appreciated.
Please let me know if more information is required.
Edit
In "backwardsCompatibilityWallFunctions.H"
:
#ifndef backwardsCompatibilityWallFunctions_H
#define backwardsCompatibilityWallFunctions_H
#include "fvMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
//- omega
tmp<volScalarField> autoCreateOmega
(
const word& fieldName,
const fvMesh& mesh,
const objectRegistry& obj
);
tmp<volScalarField> autoCreateOmega
(
const word& fieldName,
const fvMesh& mesh
);
And in "backwardsCompatibilityWallFunctions.C"
tmp<volScalarField> autoCreateOmega
(
const word& fieldName,
const fvMesh& mesh,
const objectRegistry& obj
)
{
return
autoCreateWallFunctionField
<
scalar,
RASModels::omegaWallFunctionFvPatchScalarField
>
(
fieldName,
mesh,
obj
);
}
tmp<volScalarField> autoCreateOmega
(
const word& fieldName,
const fvMesh& mesh
)
{
return
autoCreateWallFunctionField
<
scalar,
RASModels::omegaWallFunctionFvPatchScalarField
>
(
fieldName,
mesh,
mesh
);
}
As suggested: If I add using Foam::incompressible::autoCreateOmega;
Make/linux64GccDPOpt/solver.o: In function `main':
solver.C:(.text.startup+0x7dd): undefined reference to `Foam::incompressible::autoCreateOmega(Foam::word const&, Foam::fvMesh const&, Foam::objectRegistry const&)'
collect2: error: ld returned 1 exit status
/home/foam/foam-extend-4.0/wmake/Makefile:159: recipe for target '/home/foam/applications/bin/linux64GccDPOpt/solver' failed
make: *** [/home/foam/applications/bin/linux64GccDPOpt/solver] Error 1