CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Compiling a OF2.3 solver in OF 3.0.1 (https://www.cfd-online.com/Forums/openfoam-programming-development/177293-compiling-of2-3-solver-3-0-1-a.html)

Mirage September 9, 2016 20:25

Compiling a OF2.3 solver in OF 3.0.1
 
Dear OF-Users and -Developers,

I am using OF.3.0.1, Ubuntu 16.04 LTS.

I am trying to compile a solver, which was written using the OF 2.3.

I tried to compiled the solver in OF 3.0.1, unlikely it did not work.

After modifying the files "files" and "options", I succeed to remove some errors but it did not help to compile the solver.

edited Files:
Code:

pisoFoamT_cyclic.C

EXE = $(FOAM_USER_APPBIN)/pisoFoamT_cyclic

edited Options:
Code:

EXE_INC = \
    -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/fvOptions/lnInclude \
    -I$(LIB_SRC)/sampling/lnInclude

EXE_LIBS = \
    -lincompressibleTurbulenceModel \
    -lincompressibleRASModels \
    -lincompressibleLESModels \
    -lincompressibleTransportModels \
    -lfiniteVolume \
    -lmeshTools \
    -lfvOptions \
    -lsampling

The editing of the "files" and "options" helped to remove some errors. However I am not able to compile the solver.

The Error:
Code:

/OpenFOAM/OpenFOAM-3.0.1/src/OSspecific/POSIX/lnInclude  -fPIC -c pisoFoamT_cyclic.C -o Make/linux64GccDPInt64Opt/pisoFoamT_cyclic.o
pisoFoamT_cyclic.C:66:38: fatal error: readPISOControls.H: No such file or directory

Here is my pisoFoamT_cyclic.C:
Code:

#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "turbulenceModel.H"
#include "IFstream.H"            //ADDED 10/20/14
#include "OFstream.H"            //ADDED 10/20/14
#include "Random.H"            //ADDED 10/20/14

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

int main(int argc, char *argv[])
{
    #include "setRootCase.H"

    #include "createTime.H"
    #include "createMesh.H"
    #include "readThermodynamicProperties.H" //ADDED 10/20/14
    #include "readTransportProperties.H" //ADDED 10/20/14
    #include "createFields.H"
    #include "initContinuityErrs.H"
    #include "readTimeControls.H"
    #include "createGradP.H"        //ADDED 10/20/14

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

    #include "calculateGradT.H"        //ADDED 10/21/14

    Info<< "\nStarting time loop\n" << endl;

    while (runTime.loop())
    {
        Info<< "Time = " << runTime.timeName() << nl << endl;

        #include "readPISOControls.H"
        #include "CourantNo.H"
    #include "setDeltaT.H" // added

   
    turbulence->correct();    //CHANGED 10/29/14

        // Pressure-velocity PISO corrector
        {
            // Momentum predictor

            fvVectorMatrix UEqn
            (
                fvm::ddt(U)
              + fvm::div(phi, U)
              + turbulence->divDevReff(U)
            ==                //ADDED 10/20/14
        flowDirection*gradP    //ADDED 10/20/14
            );

            UEqn.relax();

            if (momentumPredictor)
            {
                solve(UEqn == -fvc::grad(p));
            }

            // --- PISO loop
        volScalarField rAU(1.0/UEqn.A());    //ADDED 10/20/14

            for (int corr=0; corr<nCorr; corr++)
            {
//              volScalarField rAU(1.0/UEqn.A());    //CHANGED 10/20/14

                volVectorField HbyA("HbyA", U);
                HbyA = rAU*UEqn.H();
                surfaceScalarField phiHbyA
                (
                    "phiHbyA",
                    (fvc::interpolate(HbyA) & mesh.Sf())
                  + fvc::interpolate(rAU)*fvc::ddtCorr(U, phi)
                );

                adjustPhi(phiHbyA, U, p);

                // Non-orthogonal pressure corrector loop
                for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
                {
                    // Pressure corrector

                    fvScalarMatrix pEqn
                    (
                        fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
                    );

                    pEqn.setReference(pRefCell, pRefValue);

                    if
                    (
                        corr == nCorr-1
                    && nonOrth == nNonOrthCorr
                    )
                    {
                        pEqn.solve(mesh.solver("pFinal"));
                    }
                    else
                    {
                        pEqn.solve();
                    }

                    if (nonOrth == nNonOrthCorr)
                    {
                        phi = phiHbyA - pEqn.flux();
                    }
                }

                #include "continuityErrs.H"

                U = HbyA - rAU*fvc::grad(p);
                U.correctBoundaryConditions();
            }

    #include "TEqn.H" //ADDED 10/21/14

//ADDED 10/20/14 --------------->
        // Correct driving force for a constant mass flow rate

        // Extract the velocity in the flow direction
        dimensionedScalar magUbarStar =
            (flowDirection & U)().weightedAverage(mesh.V());

        // Calculate the pressure gradient increment needed to
        // adjust the average flow-rate to the correct value
        dimensionedScalar gragPplus =
            (magUbar - magUbarStar)/rAU.weightedAverage(mesh.V());

        U += flowDirection*rAU*gragPplus;

        gradP += gragPplus;

        Info<< "Uncorrected Ubar = " << magUbarStar.value() << tab
            << "pressure gradient = " << gradP.value() << endl;
//ADDED 10/20/14 <---------------
        }

 //      turbulence->correct(); //CHANGED 10/29/14

        runTime.write();

        #include "writeGradP.H" //ADDED 10/20/14   

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info<< "End\n" << endl;

    return 0;
}


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

I am not able to fix the problem and compile the solver.

Please let me know if you need any other informations.

Any advice will be greatly appreciated, thanks in advance :)

Mirage September 9, 2016 21:47

I just removed
readPISOControls.H from the .C file and I got a list of new errors:

Code:

I/home/amine/OpenFOAM/OpenFOAM-3.0.1/src/sampling/lnInclude -IlnInclude -I. -I/home/amine/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/lnInclude -I/home/amine/OpenFOAM/OpenFOAM-3.0.1/src/OSspecific/POSIX/lnInclude  -fPIC -c pisoFoamT_cyclic.C -o Make/linux64GccDPInt64Opt/pisoFoamT_cyclic.o
In file included from pisoFoamT_cyclic.C:51:0:
createFields.H: In function ‘int main(int, char**)’:
createFields.H:71:13: error: ‘incompressible’ was not declared in this scope
    autoPtr<incompressible::turbulenceModel> turbulence
            ^
createFields.H:71:44: error: template argument 1 is invalid
    autoPtr<incompressible::turbulenceModel> turbulence
                                            ^
createFields.H:73:9: error: ‘incompressible’ is not a class or namespace
        incompressible::turbulenceModel::New(U, phi, laminarTransport)
        ^
In file included from pisoFoamT_cyclic.C:53:0:
/home/amine/OpenFOAM/OpenFOAM-3.0.1/src/finiteVolume/lnInclude/readTimeControls.H:32:1: error: ‘adjustTimeStep’ was not declared in this scope
 adjustTimeStep =
 ^
/home/amine/OpenFOAM/OpenFOAM-3.0.1/src/finiteVolume/lnInclude/readTimeControls.H:35:1: error: ‘maxCo’ was not declared in this scope
 maxCo =
 ^
/home/amine/OpenFOAM/OpenFOAM-3.0.1/src/finiteVolume/lnInclude/readTimeControls.H:38:1: error: ‘maxDeltaT’ was not declared in this scope
 maxDeltaT =
 ^
pisoFoamT_cyclic.C:71:12: error: base operand of ‘->’ is not a pointer
  turbulence->correct(); //CHANGED 10/29/14
            ^
pisoFoamT_cyclic.C:81:27: error: base operand of ‘->’ is not a pointer
              + turbulence->divDevReff(U)
                          ^
pisoFoamT_cyclic.C:88:17: error: ‘momentumPredictor’ was not declared in this scope
            if (momentumPredictor)
                ^
pisoFoamT_cyclic.C:96:35: error: ‘nCorr’ was not declared in this scope
            for (int corr=0; corr<nCorr; corr++)
                                  ^
pisoFoamT_cyclic.C:112:46: error: ‘nNonOrthCorr’ was not declared in this scope
                for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
                                              ^
In file included from pisoFoamT_cyclic.C:148:0:
TEqn.H:7:16: error: base operand of ‘->’ is not a pointer
    + turbulence->nut()/Prt
                ^
TEqn.H:24:54: error: base operand of ‘->’ is not a pointer
        volScalarField DiffusivityScalar = turbulence->nut()/Prt;
                                                      ^
/home/amine/OpenFOAM/OpenFOAM-3.0.1/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt64Opt/pisoFoamT_cyclic.o' failed
make: *** [Make/linux64GccDPInt64Opt/pisoFoamT_cyclic.o] Error 1

Please let me know if you need any other informations.

Any advice will be greatly appreciated, thanks in advance :)

davidtran September 28, 2016 09:02

Hi Mirage,

Did you solve your problem? I am facing the similar issue when I compiled a code. Could you share your experience?

Best regards,

Mirage September 28, 2016 17:08

Quote:

Originally Posted by davidtran (Post 619591)
Hi Mirage,

Did you solve your problem? I am facing the similar issue when I compiled a code. Could you share your experience?

Best regards,

I solved the problem. The solver is working, but i am not sure, if it is correct.
I will post here the modification, that i did, as soon as possible :)

agustinvo September 30, 2016 03:47

Hi

it seems that it already works in your case! Try the solver and tell us!

As I can see, the file readPISOControls.H is not found. It means that in your options file, the directory where you are supposed to look for it does not have it. From OF2.3.1 to OF3.0.1 some directories were changed, so your error could be related with that. You can take a look to other solver who uses that file, and check how they call it.

Mirage October 4, 2016 12:43

Hello guys,

The solver is running but I am not getting the same results with OF2.3.
I am running a LES and I am not able to have output for nuSgs.

Here are the lines, that i edited:

Code:

In creatField.H :

label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell(p, piso.dict(), pRefCell, pRefValue);
mesh.setFluxRequired(p.name());


Code:

in the .C file

    pisoControl piso(mesh);                   

    #include "createTimeControls.H"


Code:

in the Make/options file:

EXE_INC = \
    -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/sampling/lnInclude

EXE_LIBS = \
    -lturbulenceModels \
    -lincompressibleTurbulenceModels \
    -lincompressibleTransportModels \
    -lfiniteVolume \
    -lmeshTools \
    -lsampling

The declaration of the turbulence Model in the constant folder was also changed in the new version. For example I do not need the LES file any more in the constant folder. I can declare my LES with all the parameter directly in the turbulenceProperties file. Please check the official OF website.

The slover written in OF2.3 was based on pisoFOAM. I just compared the new (OF3.1) and old pisoFOAM solvers and edit my solver.
My results do not look similar, that why i am not sure, if it is correct :/

Please feel free to correct or improve my suggestions :)

DoQuocVu July 1, 2017 04:26

Quote:

Originally Posted by Mirage (Post 617340)
I just removed
readPISOControls.H from the .C file and I got a list of new errors:

Code:

I/home/amine/OpenFOAM/OpenFOAM-3.0.1/src/sampling/lnInclude -IlnInclude -I. -I/home/amine/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/lnInclude -I/home/amine/OpenFOAM/OpenFOAM-3.0.1/src/OSspecific/POSIX/lnInclude  -fPIC -c pisoFoamT_cyclic.C -o Make/linux64GccDPInt64Opt/pisoFoamT_cyclic.o
In file included from pisoFoamT_cyclic.C:51:0:
createFields.H: In function ‘int main(int, char**)’:
createFields.H:71:13: error: ‘incompressible’ was not declared in this scope
    autoPtr<incompressible::turbulenceModel> turbulence
            ^
createFields.H:71:44: error: template argument 1 is invalid
    autoPtr<incompressible::turbulenceModel> turbulence
                                            ^
createFields.H:73:9: error: ‘incompressible’ is not a class or namespace
        incompressible::turbulenceModel::New(U, phi, laminarTransport)
        ^
In file included from pisoFoamT_cyclic.C:53:0:
/home/amine/OpenFOAM/OpenFOAM-3.0.1/src/finiteVolume/lnInclude/readTimeControls.H:32:1: error: ‘adjustTimeStep’ was not declared in this scope
 adjustTimeStep =
 ^
/home/amine/OpenFOAM/OpenFOAM-3.0.1/src/finiteVolume/lnInclude/readTimeControls.H:35:1: error: ‘maxCo’ was not declared in this scope
 maxCo =
 ^
/home/amine/OpenFOAM/OpenFOAM-3.0.1/src/finiteVolume/lnInclude/readTimeControls.H:38:1: error: ‘maxDeltaT’ was not declared in this scope
 maxDeltaT =
 ^
pisoFoamT_cyclic.C:71:12: error: base operand of ‘->’ is not a pointer
  turbulence->correct(); //CHANGED 10/29/14
            ^
pisoFoamT_cyclic.C:81:27: error: base operand of ‘->’ is not a pointer
              + turbulence->divDevReff(U)
                          ^
pisoFoamT_cyclic.C:88:17: error: ‘momentumPredictor’ was not declared in this scope
            if (momentumPredictor)
                ^
pisoFoamT_cyclic.C:96:35: error: ‘nCorr’ was not declared in this scope
            for (int corr=0; corr<nCorr; corr++)
                                  ^
pisoFoamT_cyclic.C:112:46: error: ‘nNonOrthCorr’ was not declared in this scope
                for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
                                              ^
In file included from pisoFoamT_cyclic.C:148:0:
TEqn.H:7:16: error: base operand of ‘->’ is not a pointer
    + turbulence->nut()/Prt
                ^
TEqn.H:24:54: error: base operand of ‘->’ is not a pointer
        volScalarField DiffusivityScalar = turbulence->nut()/Prt;
                                                      ^
/home/amine/OpenFOAM/OpenFOAM-3.0.1/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt64Opt/pisoFoamT_cyclic.o' failed
make: *** [Make/linux64GccDPInt64Opt/pisoFoamT_cyclic.o] Error 1

Please let me know if you need any other informations.

Any advice will be greatly appreciated, thanks in advance :)

I'm trying to add a scalar transport equation to icoFoam and i'm facing a similar problem but my error message is something shorter, just like this:

Code:

icoScalarTransportFoam.C: In function ‘int main(int, char**)’:
icoScalarTransportFoam.C:74:31: error: ‘nCorr_’ was not declared in this scope
        for (int corr=0; corr<nCorr_; corr++)

Eventhough i've included the createPisoControl.H as you said but the error message still remain unchanged.

Do you have any idea how to read the nCorrectors into icoFoam.C??

My icoScalarTransportFoam.C is like this and i'm using openfoam 4.0
Code:

#include "fvCFD.H"
#include "pisoControl.H"

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

int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"

    pisoControl piso(mesh);

    #include "createFields.H"
    #include "initContinuityErrs.H"

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

    Info<< "\nStarting time loop\n" << endl;

    while (runTime.loop())
    {
        Info<< "Time = " << runTime.timeName() << nl << endl;

        #include "CourantNo.H"
    #include "createPisoControl.H"
        // Momentum predictor

        fvVectorMatrix UEqn
        (
            fvm::ddt(U)
          + fvm::div(phi, U)
          - fvm::laplacian(nu, U)
        );

        if (piso.momentumPredictor())
        {
            solve(UEqn == -fvc::grad(p));
        }

        // --- PISO loop

        for (int corr=0; corr<nCorr_; corr++)
        {
        #include "TEqn.H"
            volScalarField rUA = 1.0/UEqn.A();
        while (piso.correct())
        {
            volScalarField rAU(1.0/UEqn.A());
            volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
            surfaceScalarField phiHbyA
            (
                "phiHbyA",
                fvc::flux(HbyA)
              + fvc::interpolate(rAU)*fvc::ddtCorr(U, phi)
            );

            adjustPhi(phiHbyA, U, p);

            // Update the pressure BCs to ensure flux consistency
            constrainPressure(p, U, phiHbyA, rAU);

            // Non-orthogonal pressure corrector loop
            while (piso.correctNonOrthogonal())
            {
                // Pressure corrector

                fvScalarMatrix pEqn
                (
                    fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
                );

                pEqn.setReference(pRefCell, pRefValue);

                pEqn.solve(mesh.solver(p.select(piso.finalInnerIter())));

                if (piso.finalNonOrthogonalIter())
                {
                    phi = phiHbyA - pEqn.flux();
                }
            }

            #include "continuityErrs.H"

            U = HbyA - rAU*fvc::grad(p);
            U.correctBoundaryConditions();
        }
    }
        runTime.write();

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info<< "End\n" << endl;

    return 0;

}

Qihao January 10, 2018 11:09

Quote:

Originally Posted by DoQuocVu (Post 655487)
I'm trying to add a scalar transport equation to icoFoam and i'm facing a similar problem but my error message is something shorter, just like this:

Code:

icoScalarTransportFoam.C: In function ‘int main(int, char**)’:
icoScalarTransportFoam.C:74:31: error: ‘nCorr_’ was not declared in this scope
        for (int corr=0; corr<nCorr_; corr++)

Eventhough i've included the createPisoControl.H as you said but the error message still remain unchanged.

Do you have any idea how to read the nCorrectors into icoFoam.C??

My icoScalarTransportFoam.C is like this and i'm using openfoam 4.0
Code:

#include "fvCFD.H"
#include "pisoControl.H"

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

int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"

    pisoControl piso(mesh);

    #include "createFields.H"
    #include "initContinuityErrs.H"

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

    Info<< "\nStarting time loop\n" << endl;

    while (runTime.loop())
    {
        Info<< "Time = " << runTime.timeName() << nl << endl;

        #include "CourantNo.H"
    #include "createPisoControl.H"
        // Momentum predictor

        fvVectorMatrix UEqn
        (
            fvm::ddt(U)
          + fvm::div(phi, U)
          - fvm::laplacian(nu, U)
        );

        if (piso.momentumPredictor())
        {
            solve(UEqn == -fvc::grad(p));
        }

        // --- PISO loop

        for (int corr=0; corr<nCorr_; corr++)
        {
        #include "TEqn.H"
            volScalarField rUA = 1.0/UEqn.A();
        while (piso.correct())
        {
            volScalarField rAU(1.0/UEqn.A());
            volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
            surfaceScalarField phiHbyA
            (
                "phiHbyA",
                fvc::flux(HbyA)
              + fvc::interpolate(rAU)*fvc::ddtCorr(U, phi)
            );

            adjustPhi(phiHbyA, U, p);

            // Update the pressure BCs to ensure flux consistency
            constrainPressure(p, U, phiHbyA, rAU);

            // Non-orthogonal pressure corrector loop
            while (piso.correctNonOrthogonal())
            {
                // Pressure corrector

                fvScalarMatrix pEqn
                (
                    fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
                );

                pEqn.setReference(pRefCell, pRefValue);

                pEqn.solve(mesh.solver(p.select(piso.finalInnerIter())));

                if (piso.finalNonOrthogonalIter())
                {
                    phi = phiHbyA - pEqn.flux();
                }
            }

            #include "continuityErrs.H"

            U = HbyA - rAU*fvc::grad(p);
            U.correctBoundaryConditions();
        }
    }
        runTime.write();

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info<< "End\n" << endl;

    return 0;

}

hi,Do you solve this problem now?

DoQuocVu January 10, 2018 11:44

Hi Qihao,

It has been so long that I couldn't remember weather the problem had been solved or not.
Anyway, what is your problem and error messages? You can include your files here so that I can give you a hand :)


All times are GMT -4. The time now is 20:28.