CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Manual limiter of velocity doesn't work (https://www.cfd-online.com/Forums/openfoam-solving/114556-manual-limiter-velocity-doesnt-work.html)

batta31 March 13, 2013 07:40

Manual limiter of velocity doesn't work
 
Hi to everyone guys!

I'm experiencing this problem and I really don' t know what to do: I'm running with the solver adjointShapeOptimizationFoam, but now I'm trying to modify it a little, since sometimes the equations diverge.

What I want to do is to use a manual limiter, that limits the value of the velocity in each cell if it raises too much, so I've inserted these lines at the bottom of the solver:

forAll(Ua,cellI)
{
Ua[cellI].component(0)=min(Ua[cellI].component(0), 200);
Ua[cellI].component(1)=min(Ua[cellI].component(1), 200);
Ua[cellI].component(2)=min(Ua[cellI].component(2), 200);
}

forAll(Ua,cellJ)
{
Ua[cellJ].component(0)=max(Ua[cellJ].component(0), -200);
Ua[cellJ].component(1)=max(Ua[cellJ].component(1), -200);
Ua[cellJ].component(2)=max(Ua[cellJ].component(2), -200);
}

I'm expecting that these lines behave like a threshold value for each component of the velocity at each iteration, but I've run a simulation and I discovered that the values of the velocity were bigger than the range [-200:200].

Maybe the lines I've added are wrong?

Any help is really appreciated.
Thanks in advance

Simone

P.s. I'm running in parallel, but I hope this is not a problem for the code I've added.

batta31 March 14, 2013 03:22

Please guy, is there someone that can help?

doubtsincfd March 14, 2013 09:29

You will need to limit the values on the patches also (all faces on patches)

forAll(U.boundaryField(),patchI)
{
forAll(U.boundaryField()[patchI],faceI)
{
U.boundaryField()[patchI][faceI].component(0)=some value;
}

}

Also your solver might adjust U values not only after solving momentum equation. So make sure that your are limiting after each calculation step of U

batta31 March 15, 2013 07:09

Thank you Omkar! The problem was exactly on the patches, since I had forgotten to loop on them. By adding your lines now it seems to work perfectly.

immortality March 15, 2013 07:46

hi Simone
I think limiting velocity can also resolve my problem.
Could you send me your modified solver?
Thanks.

immortality March 16, 2013 18:29

where should i add them exactly?

immortality March 17, 2013 20:24

can use velocity limiters only on a patch not entire the domain?

immortality March 17, 2013 20:26

hi Omkar
Could you send me the code with added expressions for rhoPimpleFoam?

doubtsincfd March 17, 2013 20:37

My code consists of combination of above two codes.
Like I said, it did not work for me so I erased that code.
The codes in this forum clearly explain how to limit velocity in the domain and the patches

batta31 March 18, 2013 04:04

Hi immortality!
With respect to the adjointShapeOptimizationFoam solver, you should put the " two" limiter just above the lines

Quote:

// Explicitly relax pressure for adjoint momentum corrector
pa.relax();

// Adjoint momentum corrector
Ua -= rAUa*fvc::grad(pa);
Ua.correctBoundaryConditions();
into the predictor-corrector loop. At least, I did in this way!

If you want to "limit" only the patches you should insert only the lines that doubtsincfd suggested.

If, instead, you asked to limit only one specific patch you can use something like this:

Quote:

word patchName = "NAME_OF_THE_PATCH";
label patchID = mesh.boundary().findPatchID(patchName2);

forAll(U.boundaryField()[patchID],faceI)
{
U.boundaryField()[patchID][faceI].component(0)=some value;
}
Hope this works

Simone

immortality March 19, 2013 13:57

thanks.where the codes should be added in rhoPimpleFoam?
rhoPimpleFoam.C is this:
Code:

#include "fvCFD.H"
#include "basicPsiThermo.H"
#include "turbulenceModel.H"
#include "bound.H"
#include "pimpleControl.H"

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

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

    pimpleControl pimple(mesh);

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

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

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

    while (runTime.run())
    {
        #include "readTimeControls.H"
        #include "compressibleCourantNo.H"
        #include "setDeltaT.H"

        runTime++;

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

        #include "rhoEqn.H"

        // --- Pressure-velocity PIMPLE corrector loop
        while (pimple.loop())
        {
            #include "UEqn.H"
            #include "hEqn.H"

            // --- Pressure corrector loop
            while (pimple.correct())
            {
                #include "pEqn.H"
            }

            if (pimple.turbCorr())
            {
                turbulence->correct();
            }
        }

        runTime.write();

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

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

    return 0;
}


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

where UEqn.H is:
Code:

// Solve the Momentum equation

tmp<fvVectorMatrix> UEqn
(
    fvm::ddt(rho, U)
  + fvm::div(phi, U)
  + turbulence->divDevRhoReff(U)
);

UEqn().relax();

volScalarField rAU(1.0/UEqn().A());

if (pimple.momentumPredictor())
{
    solve(UEqn() == -fvc::grad(p));
    K = 0.5*magSqr(U);
}

hEqn.H:
Code:

{
    fvScalarMatrix hEqn
    (
        fvm::ddt(rho, h)
      + fvm::div(phi, h)
      - fvm::laplacian(turbulence->alphaEff(), h)
    ==
        dpdt
      - (fvc::ddt(rho, K) + fvc::div(phi, K))
    );

    hEqn.relax();
    hEqn.solve();

    thermo.correct();
}

pEqn.H:
Code:

rho = thermo.rho();
rho = max(rho, rhoMin);
rho = min(rho, rhoMax);
rho.relax();

U = rAU*UEqn().H();

if (pimple.nCorrPISO() <= 1)
{
    UEqn.clear();
}

if (pimple.transonic())
{
    surfaceScalarField phid
    (
        "phid",
        fvc::interpolate(psi)
      *(
            (fvc::interpolate(U) & mesh.Sf())
          + fvc::ddtPhiCorr(rAU, rho, U, phi)
        )
    );

    while (pimple.correctNonOrthogonal())
    {
        fvScalarMatrix pEqn
        (
            fvm::ddt(psi, p)
          + fvm::div(phid, p)
          - fvm::laplacian(rho*rAU, p)
        );

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

        if (pimple.finalNonOrthogonalIter())
        {
            phi == pEqn.flux();
        }
    }
}
else
{
    phi =
        fvc::interpolate(rho)*
        (
            (fvc::interpolate(U) & mesh.Sf())
          + fvc::ddtPhiCorr(rAU, rho, U, phi)
        );

    while (pimple.correctNonOrthogonal())
    {
        // Pressure corrector
        fvScalarMatrix pEqn
        (
            fvm::ddt(psi, p)
          + fvc::div(phi)
          - fvm::laplacian(rho*rAU, p)
        );

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

        if (pimple.finalNonOrthogonalIter())
        {
            phi += pEqn.flux();
        }
    }
}

#include "rhoEqn.H"
#include "compressibleContinuityErrs.H"

// Explicitly relax pressure for momentum corrector
p.relax();

// Recalculate density from the relaxed pressure
rho = thermo.rho();
rho = max(rho, rhoMin);
rho = min(rho, rhoMax);
rho.relax();
Info<< "rho max/min : " << max(rho).value()
    << " " << min(rho).value() << endl;

U -= rAU*fvc::grad(p);
U.correctBoundaryConditions();
K = 0.5*magSqr(U);

dpdt = fvc::ddt(p);


batta31 March 21, 2013 07:06

In my opinion after

Code:

if (pimple.turbCorr())
{
    turbulence->correct();
}

should be fine.

immortality March 26, 2013 08:57

thank you dear Simone for your help
so I added it.is it correct?why you have wrote patchName2 in findPatchID?
I put U[cellI] instead of Ua[cellI] due to use in rhoPimpleFoam does it have any problem?
I want not to let U becomes higher than sound speed(flow should be subsonic)
will it be true that I write sqrt(1.4*287.14*T[cellI]) instead of 500 I have put now?
I want to be certain to compile the modified solver.
thanks again.
Code:

word patchName = "left";
        label patchID = mesh.boundary().findPatchID(patchName);
        forAll(U.boundaryField()[patchID],faceI)
          {
              U.boundaryField()[patchID][faceI].component(0)=min(U[cellI].component(0), 500);
          }


immortality March 26, 2013 11:49

I used it for the patch.but velocity in cells near the inflow boundary are supersonic.
where I add the expressions to limit velocity on top of domain?
and what do you mean from cellI and cellJ in this expressions:
forAll(Ua,cellI)
{
Ua[cellI].component(0)=min(Ua[cellI].component(0), 200);
Ua[cellI].component(1)=min(Ua[cellI].component(1), 200);
Ua[cellI].component(2)=min(Ua[cellI].component(2), 200);
}

forAll(Ua,cellJ)
{
Ua[cellJ].component(0)=max(Ua[cellJ].component(0), -200);
Ua[cellJ].component(1)=max(Ua[cellJ].component(1), -200);
Ua[cellJ].component(2)=max(Ua[cellJ].component(2), -200);
}

batta31 March 27, 2013 10:59

You have to put those line before the ones to limit the boundary. cellI and cellJ are two (unuseful) different counters. You can use the same for both cycles.

immortality March 27, 2013 11:20

thank you dear Simone again
is this correct now?:
Code:

forAll(U,cellI)
          {
            U[cellI].component(0)=min(U[cellI].component(0), sqrt(1.4*287.14*T.boundaryField()[patchID][faceI])-30);
          }
          forAll(U,cellJ)
          {
            U[cellJ].component(1)=max(U[cellI].component(1),-150);
          }
        word patchName = "left";
        label patchID = mesh.boundary().findPatchID(patchName);
        forAll(U.boundaryField()[patchID],faceI)
          {
              U.boundaryField()[patchID][faceI].component(0)=min(U.boundaryField()[patchID][faceI].component(0), sqrt(1.4*287.14*T.boundaryField()[patchID][faceI])-30);
              U.boundaryField()[patchID][faceI].component(1)=max(U.boundaryField()[patchID][faceI].component(1),-150);
          }

another question! could we do both loops into single one by for instance I counter?
thanks.

immortality March 27, 2013 11:29

when compiled it this error occurred:
Code:

ehsan@Ehsan-com:~/Desktop/rhoPimpleFoamLimited$ wmakeMaking dependency list for source file rhoPimpleFoamLimited.C
SOURCE=rhoPimpleFoamLimited.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam211/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam211/src/turbulenceModels/compressible/turbulenceModel -I/opt/openfoam211/src/finiteVolume/cfdTools -I/opt/openfoam211/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam211/src/OpenFOAM/lnInclude -I/opt/openfoam211/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/rhoPimpleFoamLimited.o
rhoPimpleFoamLimited.C: In function ‘int main(int, char**)’:
rhoPimpleFoamLimited.C:90:79: error: ‘Foam::T’ does not have class type
rhoPimpleFoamLimited.C:90:96: error: ‘patchID’ was not declared in this scope
rhoPimpleFoamLimited.C:90:105: error: ‘faceI’ was not declared in this scope
rhoPimpleFoamLimited.C:94:41: error: name lookup of ‘cellI’ changed for ISO ‘for’ scoping [-fpermissive]
rhoPimpleFoamLimited.C:94:41: note: (if you use ‘-fpermissive’ G++ will accept your code)
rhoPimpleFoamLimited.C:100:132: error: ‘Foam::T’ does not have class type
make: *** [Make/linux64GccDPOpt/rhoPimpleFoamLimited.o] Error 1

whats error in T?

batta31 March 27, 2013 11:30

Actually I don't know if OF will allow you such a statement:

Code:

U[cellI].component(0)=
min(U[cellI].component(0), sqrt(1.4*287.14*T.boundaryField()[patchID][faceI])-30);

since you are looping inside the domain for the component of U you can't assign its value with respect to the value of the temperature on the boundary!

I don't know if you can use something like this:

Code:

U[cellI].component(0)=
min(U[cellI].component(0), sqrt(1.4*287.14*T.[cellI])-30);

You could try with the line above if I understand well your intention, i.e. you want to threshold the value of the velocity with respect to the local value of the Mach number.

Hope this help.

immortality March 27, 2013 11:37

thank you.
yes Simone you understood well.
I modified it as so:
Code:

forAll(U,cellI)
          {
            U[cellI].component(0)=min(U[cellI].component(0), sqrt(1.4*287.14*T.[cellI])-30);
          }
          forAll(U,cellJ)
          {
            U[cellJ].component(1)=max(U[cellI].component(1),-150);
          }
        word patchName = "left";
        label patchID = mesh.boundary().findPatchID(patchName);
        forAll(U.boundaryField()[patchID],faceI)
          {
              U.boundaryField()[patchID][faceI].component(0)=min(U.boundaryField()[patchID][faceI].component(0), sqrt(1.4*287.14*T.boundaryField()[patchID][faceI])-30);
              U.boundaryField()[patchID][faceI].component(1)=max(U.boundaryField()[patchID][faceI].component(1),-150);
          }

but this error is shown:
Code:

ehsan@Ehsan-com:~/Desktop/rhoPimpleFoamLimited$ wmakeMaking dependency list for source file rhoPimpleFoamLimited.C
SOURCE=rhoPimpleFoamLimited.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam211/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam211/src/turbulenceModels/compressible/turbulenceModel -I/opt/openfoam211/src/finiteVolume/cfdTools -I/opt/openfoam211/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam211/src/OpenFOAM/lnInclude -I/opt/openfoam211/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/rhoPimpleFoamLimited.o
rhoPimpleFoamLimited.C: In function ‘int main(int, char**)’:
rhoPimpleFoamLimited.C:90:79: error: ‘Foam::T’ does not have class type
rhoPimpleFoamLimited.C:90:96: error: ‘patchID’ was not declared in this scope
rhoPimpleFoamLimited.C:90:105: error: ‘faceI’ was not declared in this scope
rhoPimpleFoamLimited.C:94:41: error: name lookup of ‘cellI’ changed for ISO ‘for’ scoping [-fpermissive]
rhoPimpleFoamLimited.C:94:41: note: (if you use ‘-fpermissive’ G++ will accept your code)
rhoPimpleFoamLimited.C:100:132: error: ‘Foam::T’ does not have class type
make: *** [Make/linux64GccDPOpt/rhoPimpleFoamLimited.o] Error 1


batta31 March 27, 2013 11:40

it's

Code:

T[cellI]
not

Code:

T.[cellI]

immortality March 27, 2013 11:45

thanks.but the error persists:
Code:

ehsan@Ehsan-com:~/Desktop/rhoPimpleFoamLimited$ wmake
Making dependency list for source file rhoPimpleFoamLimited.C
SOURCE=rhoPimpleFoamLimited.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam211/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam211/src/turbulenceModels/compressible/turbulenceModel -I/opt/openfoam211/src/finiteVolume/cfdTools -I/opt/openfoam211/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam211/src/OpenFOAM/lnInclude -I/opt/openfoam211/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/rhoPimpleFoamLimited.o
rhoPimpleFoamLimited.C: In function ‘int main(int, char**)’:
rhoPimpleFoamLimited.C:90:85: error: invalid types ‘<unresolved overloaded function type>[Foam::label {aka int}]’ for array subscript
rhoPimpleFoamLimited.C:94:41: error: name lookup of ‘cellI’ changed for ISO ‘for’ scoping [-fpermissive]
rhoPimpleFoamLimited.C:94:41: note: (if you use ‘-fpermissive’ G++ will accept your code)
rhoPimpleFoamLimited.C:100:132: error: ‘Foam::T’ does not have class type
make: *** [Make/linux64GccDPOpt/rhoPimpleFoamLimited.o] Error 1


immortality March 27, 2013 11:48

the code is now:
Code:

forAll(U,cellI)
          {
            U[cellI].component(0)=min(U[cellI].component(0), sqrt(1.4*287.14*T[cellI])-30);
          }
          forAll(U,cellJ)
          {
            U[cellJ].component(1)=max(U[cellI].component(1),-150);
          }
        word patchName = "left";
        label patchID = mesh.boundary().findPatchID(patchName);
        forAll(U.boundaryField()[patchID],faceI)
          {
              U.boundaryField()[patchID][faceI].component(0)=min(U.boundaryField()[patchID][faceI].component(0), sqrt(1.4*287.14*T.boundaryField()[patchID][faceI])-30);
              U.boundaryField()[patchID][faceI].component(1)=max(U.boundaryField()[patchID][faceI].component(1),-150);
          }


immortality March 28, 2013 08:22

hi
did you find a reason for this error and not compiling?

batta31 March 28, 2013 08:54

Maybe the first error (the one at line 90) is because you are trying to subtract T and the scalar value 30, but I'm not sure about it.


The second error (line 94) it's because you are using [cellI] variable into a loop with [cellJ].

The third (line 100) it's because, probably, you can't write T.boundaryField[patchID][faceI] since, I think, T doesn't have the access class "boundaryField". Try instead

Code:

T.boundary[patchID][faceI]
as, for example, happens for the variable p in other solvers.

Hope this helps

Simone

immortality March 28, 2013 09:24

thanks dear Simone.I changed it so:
Code:

forAll(U,cellI)
          {
            U[cellI].component(0)=min(U[cellI].component(0), sqrt(1.4*287.14*T[cellI]));
          }
          forAll(U,cellJ)
          {
            U[cellJ].component(1)=max(U[cellJ].component(1),-150);
          }
        word patchName = "left";
        label patchID = mesh.boundary().findPatchID(patchName);
        forAll(U.boundaryField()[patchID],faceI)
          {
              U.boundaryField()[patchID][faceI].component(0)=min(U.boundaryField()[patchID][faceI].component(0), sqrt(1.4*287.14*T.boundary()[patchID][faceI]));
              U.boundaryField()[patchID][faceI].component(1)=max(U.boundaryField()[patchID][faceI].component(1),-150);
          }

but the error:
Code:

rhoPimpleFoamLimited.C: In function ‘int main(int, char**)’:
rhoPimpleFoamLimited.C:90:85: error: invalid types ‘<unresolved overloaded function type>[Foam::label {aka int}]’ for array subscript
rhoPimpleFoamLimited.C:100:132: error: ‘Foam::T’ does not have class type
make: *** [Make/linux64GccDPOpt/rhoPimpleFoamLimited.o] Error 1

what's your opinion?

batta31 March 28, 2013 09:43

How have you defined T?

immortality March 28, 2013 09:43

it seems it has trouble with T field.I only put it:
Code:

forAll(U,cellI)
          {
            //U[cellI].component(0)=min(U[cellI].component(0), sqrt(401.996*T[cellI]));
            U[cellI].component(0)=min(U[cellI].component(0), T[cellI]);
            U[cellI].component(1)=max(U[cellI].component(1),-150);
          }

and showed this error:
Code:

rhoPimpleFoamLimited.C: In function ‘int main(int, char**)’:
rhoPimpleFoamLimited.C:91:69: error: invalid types ‘<unresolved overloaded function type>[Foam::label {aka int}]’ for array subscript
make: *** [Make/linux64GccDPOpt/rhoPimpleFoamLimited.o] Error 1

but when all is a number it works well.

immortality March 28, 2013 09:52

it seems it has trouble with T field.I only put it:
Code:

forAll(U,cellI)
          {
            //U[cellI].component(0)=min(U[cellI].component(0), sqrt(401.996*T[cellI]));
            U[cellI].component(0)=min(U[cellI].component(0), T[cellI]);
            U[cellI].component(1)=max(U[cellI].component(1),-150);
          }

and showed this error:
Code:

rhoPimpleFoamLimited.C: In function ‘int main(int, char**)’:
rhoPimpleFoamLimited.C:91:69: error: invalid types ‘<unresolved overloaded function type>[Foam::label {aka int}]’ for array subscript
make: *** [Make/linux64GccDPOpt/rhoPimpleFoamLimited.o] Error 1

but when all is a number it works well.

immortality March 28, 2013 10:05

it seems it has trouble with T field.I only put it:
Code:

forAll(U,cellI)
          {
            //U[cellI].component(0)=min(U[cellI].component(0), sqrt(401.996*T[cellI]));
            U[cellI].component(0)=min(U[cellI].component(0), T[cellI]);
            U[cellI].component(1)=max(U[cellI].component(1),-150);
          }

and showed this error:
Code:

rhoPimpleFoamLimited.C: In function ‘int main(int, char**)’:
rhoPimpleFoamLimited.C:91:69: error: invalid types ‘<unresolved overloaded function type>[Foam::label {aka int}]’ for array subscript
make: *** [Make/linux64GccDPOpt/rhoPimpleFoamLimited.o] Error 1

but when all is a number it works well.

immortality March 28, 2013 10:16

oh.it wasn't sending but three of it send at a same time!
what do you mean by defining T?
OF doesn't recognize T field itself?

batta31 March 28, 2013 10:24

You are modifying a solver that was already present, right? Check in the associated createFields.H file how is T defined!

And then try to have a look to the access functions that can be used for that particular "T" field.

Cheers
Simone

immortality March 28, 2013 10:39

its total of creatFields.H!
its seemed that T is not defined explicitly in it.
should I add it?like rho?
where can find access functions?
Code:

    Info<< "Reading thermophysical properties\n" << endl;

    autoPtr<basicPsiThermo> pThermo
    (
        basicPsiThermo::New(mesh)
    );
    basicPsiThermo& thermo = pThermo();

    volScalarField& p = thermo.p();
    volScalarField& h = thermo.h();
    const volScalarField& psi = thermo.psi();

    volScalarField rho
    (
        IOobject
        (
            "rho",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        thermo.rho()
    );

    Info<< "Reading field U\n" << endl;
    volVectorField U
    (
        IOobject
        (
            "U",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

    #include "compressibleCreatePhi.H"

    dimensionedScalar rhoMax(pimple.dict().lookup("rhoMax"));
    dimensionedScalar rhoMin(pimple.dict().lookup("rhoMin"));

    Info<< "Creating turbulence model\n" << endl;
    autoPtr<compressible::turbulenceModel> turbulence
    (
        compressible::turbulenceModel::New
        (
            rho,
            U,
            phi,
            thermo
        )
    );

    Info<< "Creating field dpdt\n" << endl;
    volScalarField dpdt("dpdt", fvc::ddt(p));

    Info<< "Creating field kinetic energy K\n" << endl;
    volScalarField K("K", 0.5*magSqr(U));


immortality March 28, 2013 15:45

I defined T as:
Code:

volScalarField T
    (
        IOobject
        (
            "T",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        thermo.T()
    );

in creatFields.H
is it true now?
but another question,how T is written in time folders when it is not defined directly in creatFields.H?

immortality March 28, 2013 16:28

but the error now is:
Code:

ehsan@Ehsan-com:~/Desktop/rhoPimpleFoamLimited$ wmake
Making dependency list for source file rhoPimpleFoamLimited.C
SOURCE=rhoPimpleFoamLimited.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam220/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam220/src/turbulenceModels/compressible/turbulenceModel -I/opt/openfoam220/src/finiteVolume/cfdTools -I/opt/openfoam220/src/finiteVolume/lnInclude -I/opt/openfoam220/src/meshTools/lnInclude -I/opt/openfoam220/src/sampling/lnInclude -I/opt/openfoam220/src/fvOptions/lnInclude -IlnInclude -I. -I/opt/openfoam220/src/OpenFOAM/lnInclude -I/opt/openfoam220/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/rhoPimpleFoamLimited.o
rhoPimpleFoamLimited.C: In function ‘int main(int, char**)’:
rhoPimpleFoamLimited.C:94:83: error: call of overloaded ‘sqrt(double)’ is ambiguous
rhoPimpleFoamLimited.C:94:83: note: candidates are:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:157:1: note: double sqrt(double)
/opt/openfoam220/src/OpenFOAM/lnInclude/dimensionedScalar.H:65:19: note: Foam::dimensionedScalar Foam::sqrt(const dimensionedScalar&)
/opt/openfoam220/src/OpenFOAM/lnInclude/Scalar.H:258:1: note: Foam::doubleScalar Foam::sqrt(Foam::doubleScalar)
/opt/openfoam220/src/OpenFOAM/lnInclude/Scalar.H:258:1: note: Foam::floatScalar Foam::sqrt(Foam::floatScalar)
rhoPimpleFoamLimited.C:106:161: error: call of overloaded ‘sqrt(double)’ is ambiguous
rhoPimpleFoamLimited.C:106:161: note: candidates are:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:157:1: note: double sqrt(double)
/opt/openfoam220/src/OpenFOAM/lnInclude/dimensionedScalar.H:65:19: note: Foam::dimensionedScalar Foam::sqrt(const dimensionedScalar&)
/opt/openfoam220/src/OpenFOAM/lnInclude/Scalar.H:258:1: note: Foam::doubleScalar Foam::sqrt(Foam::doubleScalar)
/opt/openfoam220/src/OpenFOAM/lnInclude/Scalar.H:258:1: note: Foam::floatScalar Foam::sqrt(Foam::floatScalar)
make: *** [Make/linux64GccDPOpt/rhoPimpleFoamLimited.o] Error 1

what do you think about this?
thank you.

immortality March 29, 2013 01:10

what is incorrect in T now?I've defined it.
Another question is if this limiting true in aspect of CFD results?i mean does it lead to correct results with limiting?whats its influence in your opinion?

immortality March 29, 2013 08:20

did anyone find a reason and solution of the problem?

ngj March 29, 2013 08:44

I believe it would help if you put

Code:

Foam::
in front of your "sqrt" operation.

Kind regards,

Niels

immortality March 29, 2013 09:00

thank you very very so much dear Niels!!:D
it resolved.
may you tell me the reason?is the sqrt a class object?
how could i find the access functions for fields?

ngj March 29, 2013 09:04

It is my understand that the compiler does not know, whether to use the std:: or Foam:: class definition of sqrt, since the Foam:: is probably derived from std::.

Kind regards,

Niels

immortality March 30, 2013 07:19

i have a subsonic problem but velocity at early time steps goes higher than sonic velocity and so i've limited it to sonic values as you can see above.
I have a doubt about the effect of this work on last results.
Because running takes much time i decided to ask first.
The CFD problem is unsteady compressible if important.


All times are GMT -4. The time now is 06:45.