|
[Sponsors] |
error: "namespace definition is not allowed here" |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 24, 2012, 10:55 |
error: "namespace definition is not allowed here"
|
#1 |
New Member
Join Date: Oct 2012
Posts: 3
Rep Power: 13 |
Hej
I'm trying to adapt the twoPhaseEulerFoam solver in a way, that one can use the LaunderGibsonRSTM turbulence model instead of the kEpsilon model. I replaced the corresponding line in the main code (in myTwoPhaseEulerFoam.C) an defined all the necessary links in the make/options file. So far, everything is clear and ok. Now, I'm trying to compile the new solver (with wmake) an I get always the same errors: for 6 H-files, the error "namespace definition is not allowed here" occurs. These are all unchanged files at the original place, so a bug in these files can be excluded, I assume. Online, I found some similar problem descriptions, but without solutions. And I really have no idea in which direction I have to look for the solution... Does somebody know this problem? I'd be really glad about an answer :-) Thanks in advance! Nik PS: I'm working with OpenFoam 1.7.1 |
|
October 24, 2012, 17:16 |
|
#2 |
Senior Member
Gijsbert Wierink
Join Date: Mar 2009
Posts: 383
Rep Power: 18 |
Hi Nik,
The reason is that you include a file with a namespace declaration where you shouldn't. Just test it by copying the original twoPhaseEulerFoam and putting Code:
namespace Foam {
__________________
Regards, Gijs |
|
October 25, 2012, 04:47 |
|
#3 |
New Member
Join Date: Oct 2012
Posts: 3
Rep Power: 13 |
Thanks a lot for your answer. I also had the idea to test the original twoPhaseEulerFoam and I surprisingly remarked that there I get the same error message. Although, it is possible to run a case with my new solver, I just do not know if everything works fine or not, the results I get are generally quite reasonable, but a "rest-uncertainty" is still there. I think I have to discuss that tomorrow with my thesis-supervisor...
If I get more insight in that problem, I'll post that solution here... |
|
July 6, 2015, 11:36 |
namespace definition not allowed here
|
#4 |
New Member
kh
Join Date: Jun 2015
Posts: 9
Rep Power: 10 |
Hi everyone,
I, too, have this error when I am trying to compile meltFoam after changing the include file from readSIMPLEControls.H to simpleControl.H. In this thread it is suggested that the namespace is included where it shouldn't be. However the simpleControl.H has the following lines: ... #include "solutionControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ Class simpleControl Declaration \*---------------------------------------------------------------------------*/ ... and the solutionControl.H has ... #include "fvMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ Class solutionControl Declaration \*---------------------------------------------------------------------------*/ ... I don't know why this compiler error appears, since both the namespace declarations are "as is" in the lnInclude directory. How is it that both namespace Foam declarations are included to the meltFoam.c code. Isn't this a conflict to start out with? Thanks for helping me out here. K |
|
August 4, 2015, 07:01 |
|
#5 |
New Member
as
Join Date: Jul 2015
Posts: 19
Rep Power: 10 |
Hi,
I am also getting this error of namespace definition.. mahaanu@HDHW3153 /opt/OpenFOAM/OpenFOAM-2.3.x/applications/solvers/trial $ wmake Making dependency files... SOURCE=trial.C ; x86_64-w64-mingw32-g++ -m64 -Dcygwin64 -DWM_DP -DMSWIN -DLITTLE_ENDIAN -Wall -Wextra -Wno-un used-parameter -Wnon-virtual-dtor -O3 -DNDEBUG -DNoRepository -ftemplate-depth-100 -ItwoPhaseMixtureThermo -I /opt/OpenFOAM/OpenFOAM-2.3.x/src/transportModels/compressible/lnInclude -I/opt/OpenFOAM/OpenFOAM-2.3.x/src/the rmophysicalModels/basic/lnInclude -I/opt/OpenFOAM/OpenFOAM-2.3.x/src/transportModels/twoPhaseMixture/lnInclude -I/opt/OpenFOAM/OpenFOAM-2.3.x/src/transportModels/interfaceProperties/lnInclude -I/opt/OpenFOAM/OpenFOAM-2.3 .x/src/turbulenceModels/compressible/turbulenceModel -I/opt/OpenFOAM/OpenFOAM-2.3.x/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude -I/opt/OpenFOAM/OpenFOAM-2.3.x/src/OSsp ecific/MSWindows/lnInclude -c $SOURCE -o Make/cygwin64mingw-w64DPOpt/trial.o In file included from /opt/OpenFOAM/OpenFOAM-2.3.x/src/transportModels/compressible/lnInclude/PorousZones.H:41 :0, from trial.C:56: /opt/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/IOPtrList.H: In function ‘int main(int, char**)’: /opt/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/IOPtrList.H:43:1: error: ‘namespace’ definition is not all owed here namespace Foam ^ In file included from /opt/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/IOPtrList.H:104:0, from /opt/OpenFOAM/OpenFOAM-2.3.x/src/transportModels/compressible/lnInclude/PorousZones.H:41 , from trial.C:56: /opt/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/IOPtrList.C:30:1: error: a template declaration cannot app ear at block scope template<class T> ^ /opt/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/IOPtrList.C:51:1: error: expected ‘;’ before ‘template’ template<class T> ^ trial.C:121:1: error: expected ‘}’ at end of input } ^ trial.dep:578: die Regel für Ziel „Make/cygwin64mingw-w64DPOpt/trial.o“ scheiterte make: *** [Make/cygwin64mingw-w64DPOpt/trial.o] Fehler 1 Could you please tell me what I can do? Thanks in advance! |
|
August 4, 2015, 16:36 |
|
#6 |
Senior Member
|
Hi,
There are .H files that are supposed to be included from within the solver main function (like createTime.H, createMesh.H, UEqn.H, pEqn.H etc) and there are .H files that are supposed to be included outside main function. Unfortunately they have the same extension (for example in controversial Google C++ style guide extensions of header files that a part of class code and that are meant just for textual inclusion have different extensions). So I guess, you have to provide more details about your code and what you are trying to achieve. Right now answer is "you are trying to include file inside your main function that is not supposed to be included there". |
|
December 3, 2015, 06:29 |
|
#7 |
Member
Christa
Join Date: Apr 2011
Posts: 53
Rep Power: 15 |
update:I moved the inclusion of the header file outside of the main, just below # inlcude pimpleControl.H, and that seems to sort out this problem. Several more to go, but it's progress.
Hi, I am running against this issue as well. Brief overview of what I'm trying to do: - modify sonicLiquidFoam.C and createFields.H so I can run non Newtonian fluid simulation - build compressible transport model library, by modifying the files structured as in this directory - compile and run compressible non Newtonian simulations So I have now build and successfully compiled my compressibleTransportModels library in the user directory, but I am getting the error in namespace definition when trying to compile the solver. My new solver looks like this (I am highlighting the changes I have made from the original): Code:
#include "fvCFD.H" #include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" pimpleControl pimple(mesh); #include "readThermodynamicProperties.H" #include "compressibleSinglePhaseTransportModel.H" //"readTransportProperties.H" #include "createFields.H" #include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "readTimeControls.H" #include "compressibleCourantNo.H" fluid.correct(); solve(fvm::ddt(rho) + fvc::div(phi)); // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { fvVectorMatrix UEqn ( fvm::ddt(rho, U) + fvm::div(phi, U) - fvm::laplacian(fluid.mu(), U) ); solve(UEqn == -fvc::grad(p)); // --- Pressure corrector loop while (pimple.correct()) { volScalarField rAU("rAU", 1.0/UEqn.A()); surfaceScalarField rhorAUf ( "rhorAUf", fvc::interpolate(rho*rAU) ); U = rAU*UEqn.H(); surfaceScalarField phid ( "phid", psi *( (fvc::interpolate(U) & mesh.Sf()) + rhorAUf*fvc::ddtCorr(rho, U, phi)/fvc::interpolate(rho) ) ); phi = (rhoO/psi)*phid; fvScalarMatrix pEqn ( fvm::ddt(psi, p) + fvc::div(phi) + fvm::div(phid, p) - fvm::laplacian(rhorAUf, p) ); pEqn.solve(); phi += pEqn.flux(); solve(fvm::ddt(rho) + fvc::div(phi)); #include "compressibleContinuityErrs.H" U -= rAU*fvc::grad(p); U.correctBoundaryConditions(); } } rho = rhoO + psi*p; runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; } // ************************************************************************* // When compiling this code, I receive an error that the namespace definition is not allowed in this syntax (inside the compressibleTransportModel.H): Code:
#ifndef compressibleTransportModel_H #define compressibleTransportModel_H #include "primitiveFieldsFwd.H" #include "volFieldsFwd.H" #include "surfaceFieldsFwd.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ Class compressibleTransportModel Declaration \*---------------------------------------------------------------------------*/ class compressibleTransportModel { // Private Member Functions //- Disallow copy construct compressibleTransportModel(const compressibleTransportModel&); //- Disallow default bitwise assignment void operator=(const compressibleTransportModel&); public: //- Runtime type information TypeName("compressibleTransportModel"); // Constructors //- Construct from components compressibleTransportModel (); //- Destructor virtual ~compressibleTransportModel(); // Member Functions //- Return the dynamic laminar viscosity virtual tmp<volScalarField> mu() const = 0; //- Return the dynamic laminar viscosity for patch virtual tmp<scalarField> mu(const label patchi) const = 0; //- Return the laminar viscosity // virtual tmp<volScalarField> nu() const = 0; //- Return the laminar viscosity for patch // virtual tmp<scalarField> nu(const label patchi) const = 0; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif I am confused because as mentioned by people above: 1. the part of the code that crashes is left as is i.e. I did not modify this file 2. the way the header is included in exactly the same as in the case of nonNewtonianIcoFoam, the only standard solver to include a transport model and which I used as my model for the modification. Any help will be greatly appreciated. Cheers, Christa |
|
December 3, 2015, 08:58 |
|
#8 |
Senior Member
|
Hi,
Let me repeat: 1. There are headers just for textual inclusion (like UEqn.H, pEqn.H, readPISOControls.H etc) that SHOULD be included inside main function. There is no class definitions inside, just a sequence of statements that for convenience are put in a separate file. 2. There are header with class definitions (like compressibleSinglePhaseTransportModel.H, incompressibleTurbulenceModel.H etc). Inside these files APIs are defined, they should be included outside main function (just in the beginning of the file). So returning to your colourful code. 1. Red include statement should be outside main function. 2. Red fluid object should be created in createFields.H file (or elsewhere before while loop but inside main function). |
|
December 3, 2015, 18:26 |
|
#9 | |
Member
Christa
Join Date: Apr 2011
Posts: 53
Rep Power: 15 |
Quote:
Sorry for making you repeat things. I read your message many times and only now do I actually understand what you're saying about the different header files. Coding is a bit of a struggle for me. Many thanks again, Christa |
||
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Ansys Fluent 13.0 UDF compilation problem in Window XP (32 bit) | Yogini | Fluent UDF and Scheme Programming | 7 | October 3, 2012 07:24 |
CFX problem in ubuntu (linux) | Vigneshramaero | CFX | 0 | July 13, 2012 10:22 |
CFX-Pre problem, pls help!!! | cth_yao | CFX | 0 | February 17, 2012 00:52 |
OpenFOAM static build on Cray XT5 | asaijo | OpenFOAM Installation | 9 | April 6, 2011 12:21 |
CFX Post: Problem with Macro | Shafiul | CFX | 12 | January 5, 2011 15:24 |