LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-19-2012, 02:49 AM   #1
samiam1000
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Rep: Reputation: Disabled
Compiling in c++ (OpenFOAM)


Dear All,

I am trying to compile a script (a new solver for OpenFOAM).

I get this error

Code:
lab@lab-laptop:~/OpenFOAM/lab-2.1.0/applications/solvers/chtMultiRegionFoam_Epta$ wmake
Making dependency list for source file fluid/compressibleCourantNo.C
Making dependency list for source file solid/solidRegionDiffNo.C
Making dependency list for source file chtMultiRegionFoam_Epta.C
SOURCE=fluid/compressibleCourantNo.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -Ifluid -Isolid -Iinclude -I/opt/openfoam210/src/meshTools/lnInclude -I/opt/openfoam210/src/finiteVolume/lnInclude -I/opt/openfoam210/src/turbulenceModels -I/opt/openfoam210/src/turbulenceModels/compressible/RAS/lnInclude -I/opt/openfoam210/src/finiteVolume/cfdTools -I/opt/openfoam210/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam210/src/thermophysicalModels/specie/lnInclude -I/opt/openfoam210/src/thermophysicalModels/basicSolidThermo/lnInclude -I/opt/openfoam210/src/turbulenceModels/compressible/turbulenceModel/lnInclude -I/opt/openfoam210/src/thermophysicalModels/radiationModels/lnInclude -IlnInclude -I. -I/opt/openfoam210/src/OpenFOAM/lnInclude -I/opt/openfoam210/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/compressibleCourantNo.o
SOURCE=solid/solidRegionDiffNo.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -Ifluid -Isolid -Iinclude -I/opt/openfoam210/src/meshTools/lnInclude -I/opt/openfoam210/src/finiteVolume/lnInclude -I/opt/openfoam210/src/turbulenceModels -I/opt/openfoam210/src/turbulenceModels/compressible/RAS/lnInclude -I/opt/openfoam210/src/finiteVolume/cfdTools -I/opt/openfoam210/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam210/src/thermophysicalModels/specie/lnInclude -I/opt/openfoam210/src/thermophysicalModels/basicSolidThermo/lnInclude -I/opt/openfoam210/src/turbulenceModels/compressible/turbulenceModel/lnInclude -I/opt/openfoam210/src/thermophysicalModels/radiationModels/lnInclude -IlnInclude -I. -I/opt/openfoam210/src/OpenFOAM/lnInclude -I/opt/openfoam210/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/solidRegionDiffNo.o
SOURCE=chtMultiRegionFoam_Epta.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -Ifluid -Isolid -Iinclude -I/opt/openfoam210/src/meshTools/lnInclude -I/opt/openfoam210/src/finiteVolume/lnInclude -I/opt/openfoam210/src/turbulenceModels -I/opt/openfoam210/src/turbulenceModels/compressible/RAS/lnInclude -I/opt/openfoam210/src/finiteVolume/cfdTools -I/opt/openfoam210/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam210/src/thermophysicalModels/specie/lnInclude -I/opt/openfoam210/src/thermophysicalModels/basicSolidThermo/lnInclude -I/opt/openfoam210/src/turbulenceModels/compressible/turbulenceModel/lnInclude -I/opt/openfoam210/src/thermophysicalModels/radiationModels/lnInclude -IlnInclude -I. -I/opt/openfoam210/src/OpenFOAM/lnInclude -I/opt/openfoam210/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/chtMultiRegionFoam_Epta.o
In file included from chtMultiRegionFoam_Epta.C:66:
solid/setRegionSolidFields.H: In function ‘int main(int, char**)’:
solid/setRegionSolidFields.H:1: warning: unused variable ‘mesh’
solid/setRegionSolidFields.H:15: warning: unused variable ‘T’
In file included from chtMultiRegionFoam_Epta.C:78:
solid/setRegionSolidFields.H:1: warning: unused variable ‘mesh’
solid/setRegionSolidFields.H:15: warning: unused variable ‘T’
fluid/setRegionFluidFields.H:1: warning: unused variable ‘mesh’
fluid/setRegionFluidFields.H:5: warning: unused variable ‘kappa’
fluid/setRegionFluidFields.H:6: warning: unused variable ‘U’
fluid/setRegionFluidFields.H:7: warning: unused variable ‘phi’
fluid/setRegionFluidFields.H:9: warning: unused variable ‘turb’
fluid/setRegionFluidFields.H:10: warning: unused variable ‘K’
fluid/setRegionFluidFields.H:11: warning: unused variable ‘dpdt’
fluid/setRegionFluidFields.H:13: warning: unused variable ‘p’
fluid/setRegionFluidFields.H:14: warning: unused variable ‘psi’
fluid/setRegionFluidFields.H:15: warning: unused variable ‘h’
fluid/setRegionFluidFields.H:18: warning: unused variable ‘gh’
fluid/setRegionFluidFields.H:19: warning: unused variable ‘ghf’
fluid/setRegionFluidFields.H:21: warning: unused variable ‘rad’
In file included from fluid/solveFluid.H:13,
                 from chtMultiRegionFoam_Epta.C:106:
fluid/hEqn.H:11: error: ‘sources’ was not declared in this scope
make: *** [Make/linux64GccDPOpt/chtMultiRegionFoam_Epta.o] Error 1
and I can not und why, since I did something similar for another solver and it works.

The files involved are these:
Code:
    // Initialise fluid field pointer lists
    PtrList<basicRhoThermo> thermoFluid(fluidRegions.size());
    PtrList<volScalarField> rhoFluid(fluidRegions.size());
    PtrList<volScalarField> kappaFluid(fluidRegions.size());
    PtrList<volVectorField> UFluid(fluidRegions.size());
    PtrList<surfaceScalarField> phiFluid(fluidRegions.size());
    PtrList<uniformDimensionedVectorField> gFluid(fluidRegions.size());
    PtrList<compressible::turbulenceModel> turbulence(fluidRegions.size());
    PtrList<volScalarField> p_rghFluid(fluidRegions.size());
    PtrList<volScalarField> ghFluid(fluidRegions.size());
    PtrList<surfaceScalarField> ghfFluid(fluidRegions.size());
    PtrList<radiation::radiationModel> radiation(fluidRegions.size());
    PtrList<volScalarField> KFluid(fluidRegions.size());
    PtrList<volScalarField> dpdtFluid(fluidRegions.size());

    List<scalar> initialMassFluid(fluidRegions.size());

    // Populate fluid field pointer lists
    forAll(fluidRegions, i)
    {
        Info<< "*** Reading fluid mesh thermophysical properties for region "
            << fluidRegions[i].name() << nl << endl;

        Info<< "    Adding to thermoFluid\n" << endl;
        thermoFluid.set
        (
            i,
            basicRhoThermo::New(fluidRegions[i]).ptr()
        );

        Info<< "    Adding to rhoFluid\n" << endl;
        rhoFluid.set
        (
            i,
            new volScalarField
            (
                IOobject
                (
                    "rho",
                    runTime.timeName(),
                    fluidRegions[i],
                    IOobject::NO_READ,
                    IOobject::AUTO_WRITE
                ),
                thermoFluid[i].rho()
            )
        );

        Info<< "    Adding to kappaFluid\n" << endl;
        kappaFluid.set
        (
            i,
            new volScalarField
            (
                IOobject
                (
                    "kappa",
                    runTime.timeName(),
                    fluidRegions[i],
                    IOobject::NO_READ,
                    IOobject::NO_WRITE
                ),
                thermoFluid[i].Cp()*thermoFluid[i].alpha()
            )
        );

        Info<< "    Adding to UFluid\n" << endl;
        UFluid.set
        (
            i,
            new volVectorField
            (
                IOobject
                (
                    "U",
                    runTime.timeName(),
                    fluidRegions[i],
                    IOobject::MUST_READ,
                    IOobject::AUTO_WRITE
                ),
                fluidRegions[i]
            )
        );

        Info<< "    Adding to phiFluid\n" << endl;
        phiFluid.set
        (
            i,
            new surfaceScalarField
            (
                IOobject
                (
                    "phi",
                    runTime.timeName(),
                    fluidRegions[i],
                    IOobject::READ_IF_PRESENT,
                    IOobject::AUTO_WRITE
                ),
                linearInterpolate(rhoFluid[i]*UFluid[i])
                    & fluidRegions[i].Sf()
            )
        );

        Info<< "    Adding to gFluid\n" << endl;
        gFluid.set
        (
            i,
            new uniformDimensionedVectorField
            (
                IOobject
                (
                    "g",
                    runTime.constant(),
                    fluidRegions[i],
                    IOobject::MUST_READ,
                    IOobject::NO_WRITE
                )
            )
        );

        Info<< "    Adding to turbulence\n" << endl;
        turbulence.set
        (
            i,
            autoPtr<compressible::turbulenceModel>
            (
                compressible::turbulenceModel::New
                (
                    rhoFluid[i],
                    UFluid[i],
                    phiFluid[i],
                    thermoFluid[i]
                )
            ).ptr()
        );

        Info<< "    Adding to ghFluid\n" << endl;
        ghFluid.set
        (
            i,
            new volScalarField("gh", gFluid[i] & fluidRegions[i].C())
        );

        Info<< "    Adding to ghfFluid\n" << endl;
        ghfFluid.set
        (
            i,
            new surfaceScalarField("ghf", gFluid[i] & fluidRegions[i].Cf())
        );

        p_rghFluid.set
        (
            i,
            new volScalarField
            (
                IOobject
                (
                    "p_rgh",
                    runTime.timeName(),
                    fluidRegions[i],
                    IOobject::MUST_READ,
                    IOobject::AUTO_WRITE
                ),
                fluidRegions[i]
            )
        );

        // Force p_rgh to be consistent with p
        p_rghFluid[i] = thermoFluid[i].p() - rhoFluid[i]*ghFluid[i];

        radiation.set
        (
            i,
            radiation::radiationModel::New(thermoFluid[i].T())
        );

        initialMassFluid[i] = fvc::domainIntegrate(rhoFluid[i]).value();

        Info<< "    Adding to KFluid\n" << endl;
        KFluid.set
        (
            i,
            new volScalarField
            (
                "K",
                0.5*magSqr(UFluid[i])
            )
        );

        Info<< "    Adding to dpdtFluid\n" << endl;
        dpdtFluid.set
        (
            i,
            new volScalarField
            (
                "dpdt",
                fvc::ddt(thermoFluid[i].p())
            )
        );
    IObasicSourceList sources(fluidRegions[i]);
    }
and
Code:
{
    fvScalarMatrix hEqn
    (
        fvm::ddt(rho, h)
      + fvm::div(phi, h)
      - fvm::laplacian(turb.alphaEff(), h)
     ==
        dpdt
      - (fvc::ddt(rho, K) + fvc::div(phi, K))
      + rad.Sh(thermo)
      + sources(rho, h)
    );

    hEqn.relax();
    sources.constrain(hEqn);
    hEqn.solve(mesh.solver(h.select(finalIter)));

    thermo.correct();

    rad.correct();

    Info<< "Min/max T:" << min(thermo.T()).value() << ' '
        << max(thermo.T()).value() << endl;
}
Could anyone help?

Thanks a lot,
Samuele
 
Old 04-19-2012, 03:00 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,660

Rep: Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528
sorry, but it looks insufficient. I do not know which code belongs to which file, and they are only part of the files. line numbers are also unavailable.
So you need to believe: sources cannot be resolved at chtMultiRegionFoam_Epta.C:106 because it is not defined in the current scope. You need to check the scope (together with the includes)...
 
Old 04-19-2012, 03:14 AM   #3
samiam1000
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
solver

This is the solver. If you provide an email address, I can send you 4 cases:

buoyantSimpleFoam, buoyantSimpleFoam_Epta, chtMultiRegionFoam and chtMultiRegionFoam_Epta.

The buoyantSimpleFoam and the chtMultiRegionFoam are the `original' solvers, as they are implemented in OpenFOAM, while buoyantSimpleFoam_Epta and chtMultiRegionFoam_Epta are the modified (by me) solvers.
The former works, while the latter doesn't.

Thanks a lot,

Samuele

PS: if you prefer, you can download the 2 edited solvers from here ( http://www.cfd-online.com/Forums/ope...egionfoam.html ).

Last edited by samiam1000; 04-19-2012 at 03:17 AM.
 
Old 04-19-2012, 07:53 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,660

Rep: Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528
in such cases I would try g++ -E <original options> and -o filename not needed.
this will run preprocessor, will resolve includes and evaluate macros. In the result we may check the scope. Maybe there is a type mismatch problem, or you tried to call a protected/private member. Unfortunately I cannot run g++ from here.
 
Old 04-19-2012, 08:57 AM   #5
samiam1000
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Do you think that it could be a problem of compiler? If so could you help me to edit the Make file properly.
 
Old 04-20-2012, 01:32 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,660

Rep: Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528
I do not think it is a compiler or makefile issue (maybe the compiler is too strict and maybe an older version would allow this construction, but I'm not sure about it).
You defined the class sources at the end of createFluidFields.H, maybe this is not the right place, you can try to move this line at the beginning of the file, or even in the main function.
Could you try that -E flag? I would like to see the output of the command
 
Old 04-20-2012, 02:29 AM   #7
samiam1000
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Pardon the fool question: what does this mean? How can I give the -E options and where?
Something like
Code:
wmake -E
?

Thanks a lot,

Samuele
 
Old 04-20-2012, 02:36 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,660

Rep: Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528Reputation: 7528
no, that is not wmake. run wmake as usual, and look at the last executed command before the error message:
Quote:
SOURCE=chtMultiRegionFoam_Epta.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -Ifluid -Isolid -Iinclude -I/opt/openfoam210/src/meshTools/lnInclude -I/opt/openfoam210/src/finiteVolume/lnInclude -I/opt/openfoam210/src/turbulenceModels -I/opt/openfoam210/src/turbulenceModels/compressible/RAS/lnInclude -I/opt/openfoam210/src/finiteVolume/cfdTools -I/opt/openfoam210/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam210/src/thermophysicalModels/specie/lnInclude -I/opt/openfoam210/src/thermophysicalModels/basicSolidThermo/lnInclude -I/opt/openfoam210/src/turbulenceModels/compressible/turbulenceModel/lnInclude -I/opt/openfoam210/src/thermophysicalModels/radiationModels/lnInclude -IlnInclude -I. -I/opt/openfoam210/src/OpenFOAM/lnInclude -I/opt/openfoam210/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/chtMultiRegionFoam_Epta.o
here is the command we need: remove -o Make/linux64GccDPOpt/chtMultiRegionFoam_Epta.o and add -E > somefilename (do not forget to set SOURCE)
it will create a preprocessed source file, you will see the result.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Good but sorta easy guide to Kernel compiling/Re-Compiling? linus72 Linux - General 1 07-13-2009 01:37 PM
OpenFOAM - cfd package installation problem. jabir Linux - Software 0 11-30-2007 06:09 AM
when i install the software "openfoam",i meet the following network problem ztdep Linux - Networking 0 07-22-2005 12:23 AM
Various Compiling Errors (GCC compiling Openal, GUIlib, xmms-wma) gregorya Linux - Software 2 08-27-2004 05:03 AM
Compiling in ACPI support on Compaq 2135CA (system crashes while compiling) Dag Linux - Laptop and Netbook 20 07-30-2004 07:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration