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/)
-   -   Using adjustableTimeStep in pisoFoam (https://www.cfd-online.com/Forums/openfoam-solving/130436-using-adjustabletimestep-pisofoam.html)

odellar February 26, 2014 04:33

Using adjustableTimeStep in pisoFoam
 
Hi,

I've found a couple of pages online documenting where to add code in the pisoFoam solver code such that using:

Code:

adjustTimeStep  yes;

maxCo        1;

maxDeltaT    0.5;

in the controlDict file will work (as the pisoFoam doesn't originally support adjustable timestep) - but it's still not particularly clear.

For a start I don't actually know how to get to the solver.c file (which I believe is where I need to add code?)

If anyone could give me some step-by-step instructions of exactly what to do that would be much appreciated.

Thanks, Olie

odellar February 26, 2014 09:06

Update
 
If it helps, I *think* I've put the right code in the right place within pisoFoam.C, thanks to this tutorial: http://www.idurun.com/?p=371

This involved me editing the pisoFoam.C file using
Code:

sudo gedit pisoFoam.C
as it initially told me I don't have permission for some reason. But when I try to compile it using
Code:

wmake
I get this:

Code:

mkdir: cannot create directory `linux64GccDPOpt': Permission denied
/bin/sh: 1: cannot create linux64GccDPOpt/options: Directory nonexistent
make: *** [linux64GccDPOpt/options] Error 2
/opt/openfoam221/wmake/MakefileFiles:40: linux64GccDPOpt/options: No such file or directory
make: *** No rule to make target `linux64GccDPOpt/options'. Stop.
wmake error: file 'Make/linux64GccDPOpt/objectFiles' could not be created in /opt/openfoam221/applications/solvers/incompressible/pisoFoam

Any ideas?

Thanks



sfmoabdu June 1, 2014 15:06

it may be too late to reply but let me do it just for anyone will have the same problem.
adding adjustable time step to pisoFoam is not that big issue, just google the tutorial "adding temprature to icofoam" and instead of temprature you will add two headers in the pisoFoam.C (or whatever you will call it)

After:
# include "initContinuityErrs.H"
add this:
# include "readTimeControls.H"

and after:
# include "CourantNo.H"
add this:
# include "setDeltaT.H"

and run wmake.

in system/controlDict add these lines.

adjustTimeStep on;
maxCo 0.3;

and in fvSchemes add linear as following:

interpolationSchemes
{
default linear;
.
.
.
}

Enjoy!!

bentkj April 13, 2018 07:48

Quote:

Originally Posted by sfmoabdu (Post 495088)
it may be too late to reply but let me do it just for anyone will have the same problem.
adding adjustable time step to pisoFoam is not that big issue, just google the tutorial "adding temprature to icofoam" and instead of temprature you will add two headers in the pisoFoam.C (or whatever you will call it)

After:
# include "initContinuityErrs.H"
add this:
# include "readTimeControls.H"

and after:
# include "CourantNo.H"
add this:
# include "setDeltaT.H"

and run wmake.

in system/controlDict add these lines.

adjustTimeStep on;
maxCo 0.3;

and in fvSchemes add linear as following:

interpolationSchemes
{
default linear;
.
.
.
}

Enjoy!!

Hi, sorry if this is late but after I add the 2 headers and do wmake, i get the errors:

Quote:

Making dependency list for source file my_pisoFoam.C
g++ -std=c++0x -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam4/src/TurbulenceModels/turbulenceModels/lnInclude -I/opt/openfoam4/src/TurbulenceModels/incompressible/lnInclude -I/opt/openfoam4/src/transportModels -I/opt/openfoam4/src/transportModels/incompressible/singlePhaseTransportModel -I/opt/openfoam4/src/finiteVolume/lnInclude -I/opt/openfoam4/src/meshTools/lnInclude -I/opt/openfoam4/src/sampling/lnInclude -IlnInclude -I. -I/opt/openfoam4/src/OpenFOAM/lnInclude -I/opt/openfoam4/src/OSspecific/POSIX/lnInclude -fPIC -c my_pisoFoam.C -o Make/linux64GccDPInt32Opt/my_pisoFoam.o
In file included from my_pisoFoam.C:57:0:
/opt/openfoam4/src/finiteVolume/lnInclude/readTimeControls.H: In function ‘int main(int, char**)’:
/opt/openfoam4/src/finiteVolume/lnInclude/readTimeControls.H:32:1: error: ‘adjustTimeStep’ was not declared in this scope
adjustTimeStep =
^
/opt/openfoam4/src/finiteVolume/lnInclude/readTimeControls.H:35:1: error: ‘maxCo’ was not declared in this scope
maxCo =
^
/opt/openfoam4/src/finiteVolume/lnInclude/readTimeControls.H:38:1: error: ‘maxDeltaT’ was not declared in this scope
maxDeltaT =
^
/opt/openfoam4/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt32Opt/my_pisoFoam.o' failed
make: *** [Make/linux64GccDPInt32Opt/my_pisoFoam.o] Error 1
any idea?

*EDIT: turns out another header file was missing. this is #include "createTimeControls.H"
adding that in solved the problem. Thank you.

Source: https://www.cfd-online.com/Forums/op...-solver-c.html

caoxuxiang November 13, 2018 21:50

Quote:

Originally Posted by bentkj (Post 688768)
Hi, sorry if this is late but after I add the 2 headers and do wmake, i get the errors:



any idea?

*EDIT: turns out another header file was missing. this is #include "createTimeControls.H"
adding that in solved the problem. Thank you.

Source: https://www.cfd-online.com/Forums/op...-solver-c.html

i have the same problem now. maybe i can give you some advices. when i found the pisoFoam.c, there no # include "readTimeControls.H" and # include "setDeltaT.H" . i just done the same steps as you, then i got wrong information too.

“the variable was not declared” is tell me that it was not declared before to use it. so i added the #include "createTimeControls.H" after #include "createControl.H", it works well.

p.s of-4.0

clapointe November 14, 2018 15:20

For future reference, pimpleFoam can be run essentially as pisoFoam by setting nOuterCorrectors to 1. This alleviates any coding problem. pimpleFoam supports adjustable timestep.

Caelan

amuzeshi September 30, 2020 11:14

Quote:

Originally Posted by odellar (Post 476844)
Hi,

I've found a couple of pages online documenting where to add code in the pisoFoam solver code such that using:

Code:

adjustTimeStep  yes;

maxCo        1;

maxDeltaT    0.5;

in the controlDict file will work (as the pisoFoam doesn't originally support adjustable timestep) - but it's still not particularly clear.

For a start I don't actually know how to get to the solver.c file (which I believe is where I need to add code?)

If anyone could give me some step-by-step instructions of exactly what to do that would be much appreciated.

Thanks, Olie

Hi,
In order to make it possible to use adjustable time step in pisoFoam, in OpenFOAM v2006, follow these steps:
Code:

mkdir -p  $WM_PROJECT_USER_DIR/solvers/incompressible
cp -r $FOAM_SOLVERS/incompressible/pisoFoam  $WM_PROJECT_USER_DIR/solvers/incompressible/myPisoFoam
cd $WM_PROJECT_USER_DIR/solvers/incompressible/myPisoFoam
mv pisoFoam myPisoFoam
sed -i s/pisoFoam/myPisoFoam/g Make/files

Then add the red lines to myPisoFoam.C:
Code:

...
    #include "createFields.H"                                                                 
    #include "initContinuityErrs.H"                                                         
    #include "CourantNo.H"                                                           
    #include "createTimeControls.H"                                                   
    #include "setInitialDeltaT.H"

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

        #include "CourantNo.H"                                                                       
        #include "setDeltaT.H"
...

Now execute:
Code:

wclean
wmake

Make sure that you are in myPisoFoam directory when you issue these two commands.

Ali

sourav90 February 23, 2021 12:03

Small correction
 
Quote:

Originally Posted by amuzeshi (Post 784141)
Hi,
In order to make it possible to use adjustable time step in pisoFoam, in OpenFOAM v2006, follow these steps:
Code:

mkdir -p  $WM_PROJECT_USER_DIR/solvers/incompressible
cp -r $FOAM_SOLVERS/incompressible/pisoFoam  $WM_PROJECT_USER_DIR/solvers/incompressible/myPisoFoam
cd $WM_PROJECT_USER_DIR/solvers/incompressible/myPisoFoam
mv pisoFoam.C myPisoFoam.C
sed -i s/pisoFoam/myPisoFoam/g Make/files

...

Ali

Hi Ali & others, thanks very much for adding this :). I confirm this works with openFOAM version 8 also, but with the small modification of the commands shown in green.

wolfindark October 14, 2022 19:19

It gives me following error: Any idea?

Code:

/home/kano/OpenFOAM/OpenFOAM-10/src/finiteVolume/lnInclude/setDeltaT.H: In function ‘int main(int, char**)’:
/home/kano/OpenFOAM/OpenFOAM-10/src/finiteVolume/lnInclude/setDeltaT.H:37:34: error: expected primary-expression before ‘.’ token
  37 |    deltaT = min(deltaT, fvModels.maxDeltaT());
      |                                  ^
make: *** [/home/kano/OpenFOAM/OpenFOAM-10/wmake/rules/General/transform:26: Make/linux64GccDPInt32Debug/mymhdFoam.o] Error 1


amuzeshi October 26, 2022 22:00

Quote:

Originally Posted by wolfindark (Post 837564)
It gives me following error: Any idea?

Code:

/home/kano/OpenFOAM/OpenFOAM-10/src/finiteVolume/lnInclude/setDeltaT.H: In function ‘int main(int, char**)’:
/home/kano/OpenFOAM/OpenFOAM-10/src/finiteVolume/lnInclude/setDeltaT.H:37:34: error: expected primary-expression before ‘.’ token
  37 |    deltaT = min(deltaT, fvModels.maxDeltaT());
      |                                  ^
make: *** [/home/kano/OpenFOAM/OpenFOAM-10/wmake/rules/General/transform:26: Make/linux64GccDPInt32Debug/mymhdFoam.o] Error 1


Which version of OF?

wolfindark October 27, 2022 05:21

Quote:

Originally Posted by amuzeshi (Post 838287)
Which version of OF?

OpenFOAM-10

amuzeshi October 30, 2022 17:26

Quote:

Originally Posted by wolfindark (Post 838320)
OpenFOAM-10

In Make/files, change
Code:

FOAM_APPBIN
to
Code:

FOAM_USER_APPBIN
In myPisoFoam
Code:

mv pisoFoam myPisoFoam
I successfully compiled it, and the turbulent cavity (pisoFoam/RAS) is successfully run when adjustTimeStep is true.

Simone81 June 12, 2023 18:57

Hi,

I am trying to implement adjustTimeStep in the solver shallowWaterFoam in openFOAM-10, following the instruction from the previous posts. I do the following
Code:

mkdir -p  $WM_PROJECT_USER_DIR/solvers/incompressible
cp -r $FOAM_SOLVERS/incompressible/shallowWater  $WM_PROJECT_USER_DIR/solvers/incompressible/myShallowWater
cd $WM_PROJECT_USER_DIR/solvers/incompressible/myShallowWater
mv shallowWaterFoam.C myShallowWaterFoam.C
sed -i s/shallowWaterFoam/myShallowWaterFoam/g Make/files

then in the file myShallowWaterFoam.C I have included the files in red:
Code:

#include "fvCFD.H"
#include "pimpleControl.H"
#include "fvModels.H"
#include "fvConstraints.H"

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

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

    #include "setRootCaseLists.H"
    #include "createTime.H"
    #include "createMesh.H"
    #include "createControl.H"
    #include "createFields.H"
                                                         
    #include "CourantNo.H"                                                           
    #include "createTimeControls.H"                                                   
    #include "setInitialDeltaT.H"


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

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

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

        #include "CourantNo.H"
        #include "setDeltaT.H"

Then I compile
Code:

wclean
wmake

and I get the following error:
Code:

/opt/openfoam10/src/finiteVolume/lnInclude/setDeltaT.H: In function ‘int main(int, char**)’:
/opt/openfoam10/src/finiteVolume/lnInclude/setDeltaT.H:37:34: error: expected primary-expression before ‘.’ token
  37 |    deltaT = min(deltaT, fvModels.maxDeltaT());
      |                                ^
make: *** [/opt/openfoam10/wmake/rules/General/transform:26: Make/linux64GccDPInt32Opt/myShallowWaterFoam.o] Error 1

I also replaced
Code:

FOAM_APPBIN
with
Code:

FOAM_USER_APPBIN
but I get the same error as wolfindark in the post #9. What am I doing wrong?
Thank you!


All times are GMT -4. The time now is 17:31.