这个问题是关于 openFoam (foam extend v4) C++ 但我相信我遇到的问题是一个基本的 C++ 编程问题。
我正在尝试使用autoCreateOmega
其原型可以在
foam-extend-4.0/src/turbulenceModels/incompressible/RAS/lnInclude/backwardsCompatibilityWallFunctions.H
并且定义在相应的backwardsCompatibilityWallFunctions.C
.
在我的solver.C 文件中,顶部有以下内容:
#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"
我的一部分createFields.H
看起来像这样:
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())
);
当我尝试编译此求解器时,出现以下错误:
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
为什么"backwardsCompatibilityWallFunctions.H"
不允许我在我的程序中使用 autoCreateOmega?任何帮助深表感谢。
如果需要更多信息,请告诉我。
编辑
在"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
);
而在"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
);
}
如建议:如果我添加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