CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

ControlDict: How to only get one time folder for the results?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   October 22, 2010, 13:19
Default ControlDict: How to only get one time folder for the results?
  #1
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 9
Daniele111 is on a distinguished road
hi
Is possible with simpleFoam in time directory write only one data time directory? I want start my simulation from lastTime and when it finish my result must be overwrite on startTime directory, then i restar my simulation and again new result must be overwrite. I want only a directory
Thanks
Daniele111 is offline   Reply With Quote

Old   October 22, 2010, 14:23
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Deltares, Delft, The Netherlands
Posts: 1,746
Rep Power: 29
ngj will become famous soon enoughngj will become famous soon enough
Hi Daniele

Then you should consider the purgeWrite option. Its functionality is described in details in the User Guide. However, note that it requires the use of the timeStep as writeControl option.

Hope it helps and enjoy your weekend,

Niels
ngj is offline   Reply With Quote

Old   October 23, 2010, 11:37
Default
  #3
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 9
Daniele111 is on a distinguished road
I tried but i have one directory for each simulation, and would only one for many simulation...
Daniele111 is offline   Reply With Quote

Old   October 23, 2010, 12:51
Default
  #4
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,978
Blog Entries: 39
Rep Power: 108
wyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of light
Greetings Danielle and Niels,

Interesting requirement Danielle, but "-overwrite" argument option only exists for meshers, AFAIK, otherwise it would be the perfect solution for you.
But you also left out one crucial piece of information: are the simulations meant to end at the same time snapshot?

For example, there are three scenarios I can think of:
  1. The simulations are meant to always end at time snapshot 1000.
  2. The simulations end at different time snapshots.
  3. The simulations end when the residuals are acceptable, therefore you end it without simpleFoam's prior knowledge. This means that you will need frequent time snapshot writes, in order to keep track of what has happened before you terminate the execution.
For either one of these, I've got a solution for you, but it depends if your system allows symbolic links in the file system. Most Linux boxes that use ext2/3/4 will do fine, but I'm not certain that for example some high end clusters will allow symbolic links...

The concept is quite simple, so here is one solution (out of N possible solutions ) for each scenario, based on the same principle:
  1. If they always end at the same time snapshot, for example 1000 - run this command in your case folder:
    Code:
    ln -s 0 1000
    This will link symbolically the folder 1000 to 0, therefore anything written/read to/from folder 1000, will be in fact the folder 0.
    Then, since you don't need any time snapshots midway, you must do something like this in your controlDict:
    Code:
    startFrom       startTime;
    startTime       0;
    stopAt          endTime;
    endTime         1000;
    deltaT          0.5;
    writeControl    runTime;
    writeInterval   $endTime;
    purgeWrite      0;
    Only deltaT and endTime should be different for your simulation in question! All of these other variables must be kept as they are, otherwise you wont end up with the last time snapshot saved into the desired link folder.
  2. If simulations vary in end time, then in the previous solution you only have to change the controlDict's endTime (and possibly the deltaT), and you must also create a link for that new end time, for example 900.5:
    Code:
    ln -s 0 900.5
  3. If it's unknown when the simulation will be terminated, then writeInterval cannot be the same as the end time. You'll have to stipulate frequent saves, in order to keep losses to a minimum. This will be a serious pain, because you'll need one link per saved snapshot. One way to keep it simple, is to run something like this in the terminal, before each modified run (i.e., if the endTime increases or if your deltaT changes):
    Code:
    endTime=0.5
    deltaT=0.1
    for t in $(seq $deltaT $deltaT $endTime | sed 's=,=\.='); do ln -s 0 $t; done
And there you have it, the solutions for the 3 scenarios I can think of. I hope I've managed to keep it simple and easy to understand. If not, I'll try to rephrase my explanations

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   October 23, 2010, 13:02
Default
  #5
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 9
Daniele111 is on a distinguished road
I think that my case is 3! But i try to explain better my problem. I have a evolutive simulation and I use a matlab code that execute at each time step OpenFoam to calulate wall shear stress, with new wall shear matlab calculate new domain shape and I modify mesh and restart openfoam from lastTime, the problem is that on my university server I have a limited space and the simulation are very long and I can't use a lot of space!
Daniele111 is offline   Reply With Quote

Old   October 23, 2010, 13:33
Default
  #6
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,978
Blog Entries: 39
Rep Power: 108
wyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of light
Hi Danielle,

Then Niels's solution should also be possible for you, as long as you:
  • Use:
    Code:
    startFrom       lastTime;
    purgeWrite      1;
  • Increment the endTime for each new iteration+simulation, therefore you would have to update controlDict for each simulation.
  • In Matlab, detect which is the last time iteration, in case it ends sooner than expected (i.e., different than endTime).
Either way, you should now have more than one possible solution for your problem

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   October 23, 2010, 14:33
Default
  #7
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 9
Daniele111 is on a distinguished road
"Increment the endTime for each new iteration+simulation, therefore you would have to update controlDict for each simulation."

But I don't know endTime, each OpenFoam simulation stop when residuals are down
Daniele111 is offline   Reply With Quote

Old   October 23, 2010, 15:08
Default
  #8
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Deltares, Delft, The Netherlands
Posts: 1,746
Rep Power: 29
ngj will become famous soon enoughngj will become famous soon enough
Hi Daniele

The overall framework by Bruno is functional, and if your solver stops at a given residual, you put endTime to something really, really large. Would that work?

If your question about not knowing the endTime is a Matlab issue regarding which time folder to enter to do the post-processing step, I could imagine that you might do as follows inside matlab:

Code:
[s,w] = unix('ls -d [0-9] | sort -g | tail -1 | tr -d ''\n'''); % The ''\n'' is needed, otherwise cd(w) won't work
cd(w);
which will give you the latest time step and enter that time directory.

Best regards,

Niels
ngj is offline   Reply With Quote

Old   October 23, 2010, 15:15
Default
  #9
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 9
Daniele111 is on a distinguished road
Thanks
Doing a small summary, Would you post me an example of a controlDict file to see if i understand yours routine?

Daniele
Daniele111 is offline   Reply With Quote

Old   October 23, 2010, 15:22
Default
  #10
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Deltares, Delft, The Netherlands
Posts: 1,746
Rep Power: 29
ngj will become famous soon enoughngj will become famous soon enough
Honestly no. Merely combine posts #6 and #8 and you should be fine.

/ Niels
ngj is offline   Reply With Quote

Old   October 23, 2010, 15:25
Default
  #11
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 9
Daniele111 is on a distinguished road
Thanks for all.
In this way Have I always only one time directory ?
Daniele111 is offline   Reply With Quote

Old   October 24, 2010, 05:27
Default
  #12
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 9
Daniele111 is on a distinguished road
Uhmm purgeWrite don't resolve my problem...Example:
I start first simulation in OpenFoam, it converges after 47 time step and simulation stops, so I have 0 and 47 time directory. I star new simulation it starts from 47, and it converges at 56 time step, but in my case directory I don't have only 0 and 56 time directory but 0 47 and 56.
Daniele111 is offline   Reply With Quote

Old   October 24, 2010, 06:21
Default
  #13
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,978
Blog Entries: 39
Rep Power: 108
wyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of light
Greetings to all!

@Niels: there is a small typo in your command in post #8; it should have an asterisk for the ls:
Code:
ls -d [0-9]*
@Daniele: well in a way it's good to know that purgeWrite doesn't remove the starting snapshot, since this way we have the beginning and the end of the simulation But since this isn't what you want, I suggest what Niels has pretty much already suggested - keep using your current settings in controlDict, but run things like this:
Code:
simpleFoam
rm -rf 0
mv `ls -d [0-9]* | sort -g | tail -1 | tr -d ''\n''` 0
This will run simpleFoam, then remove the 0 snapshot when complete and move/rename the last snapshot to 0. The last two commands can be executed directly in Matlab:
Code:
unix('rm -rf 0; mv `ls -d [0-9]* | sort -g | tail -1 | tr -d ''\n''` 0')
Best regards,
Bruno
__________________

Last edited by wyldckat; October 24, 2010 at 06:37. Reason: Ooops, typo in Daniele's name...
wyldckat is offline   Reply With Quote

Old   October 24, 2010, 06:25
Default
  #14
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 9
Daniele111 is on a distinguished road
Thanks you a lot Bruno, now it is clear! You are very useful!

Daniele
Daniele111 is offline   Reply With Quote

Old   March 19, 2016, 18:38
Default
  #15
Member
 
Ram
Join Date: Oct 2015
Posts: 35
Rep Power: 3
Scram_1 is on a distinguished road
Hey,
I've already run some iterations using a custom solver. After some time (approximately 100 iterations), the Courant number starts to blow up and the simulation terminates. (At least I believe it's the Co blowing up which is causing it to terminate). Now, to ensure that the Co remains less than 1 , I want to reduce deltaT in the controlDict file. But doing so does not change the deltaT when I resume the simulation. How do I change the deltaT while ensuring that the simulation starts from the point it has stopped with the updated deltaT

Here's the error


Courant Number mean: 0.0778162 max: 1.38578
smoothSolver: Solving for Ux, Initial residual = 0.00297599, Final residual = 7.76143e-006, No Iterations 8
smoothSolver: Solving for Uy, Initial residual = 0.00559096, Final residual = 7.71217e-006, No Iterations 4
DICPCG: Solving for p, Initial residual = 0.0466867, Final residual = 9.81585e-007, No Iterations 754
DICPCG: Solving for p, Initial residual = 0.000445843, Final residual = 9.98038e-007, No Iterations 100
DICPCG: Solving for p, Initial residual = 0.000181184, Final residual = 9.64879e-007, No Iterations 53
time step continuity errors : sum local = 5.26678e-010, global = 2.18292e-015, cumulative = -3.17868e-012
DICPCG: Solving for p, Initial residual = 0.0119082, Final residual = 9.30373e-007, No Iterations 739
DICPCG: Solving for p, Initial residual = 5.90821e-005, Final residual = 9.27508e-007, No Iterations 26
DICPCG: Solving for p, Initial residual = 3.38914e-005, Final residual = 9.32952e-007, No Iterations 21
time step continuity errors : sum local = 5.04431e-010, global = 2.64054e-015, cumulative = -3.17604e-012
DILUPBiCG: Solving for T, Initial residual = 0.0122802, Final residual = 2.62996e-009, No Iterations 5
ExecutionTime = 173.687 s ClockTime = 173 s

Time = 12.1485

Courant Number mean: 0.0780047 max: 1.6609
smoothSolver: Solving for Ux, Initial residual = 0.00329476, Final residual = 4.90866e+227, No Iterations 1000
smoothSolver: Solving for Uy, Initial residual = 0.00622384, Final residual = 1.32554e+227, No Iterations 1000
DICPCG: Solving for p, Initial residual = 1, Final residual = nan, No Iterations 1001
DICPCG: Solving for p, Initial residual = nan, Final residual = nan, No Iterations 1001


--> FOAM FATAL IO ERROR:
wrong token type - expected Scalar, found on line 0 the word 'nan'

file: C:/OpenFOAM/cygwin64/opt/OpenFOAM/OpenFOAM-2.3.x/tutorials/incompressible/icoFoam/laminar_pipe -U=2/system/data.solverPerformance.p at line 0.

From function operator>>(Istream&, Scalar&)
in file lnInclude/Scalar.C at line 93.

FOAM exiting

And here's my controlDict file

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application my_icoFoam;

startFrom latestTime;

startTime 0;

stopAt endTime;

endTime 25;

deltaT 0.0005;

writeControl timeStep;

writeInterval 200;

purgeWrite 0;

writeFormat binary;

writePrecision 6;

writeCompression off;

timeFormat general;

maxCo 0.6;

adjustTimeStep yes;

timePrecision 6;

runTimeModifiable true;


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


Thanks!!
Ram
Scram_1 is offline   Reply With Quote

Old   March 20, 2016, 05:38
Default
  #16
Senior Member
 
Join Date: Aug 2014
Location: N/A
Posts: 139
Rep Power: 4
BlnPhoenix is on a distinguished road
Hi,

adjustTimeStep is not implemented in icoFoam natively, so you can maybe try to implement it in your custom icoFoam solver for convenience. (i think i saw threads on this topic in the forum)

If you want to re-start your simulation from the latest time with adjusted time step size, you simply check the latest saved time folder (in your cases possibly 12.1 or something) open your controDict file and change the startTime to this last saved time step, where your simulation converged. Don't forget to adjust the time step also.

But as i mentioned adjustable run time is the more convinient way to cope with increasing courant numbers.

Have fun.
BlnPhoenix is offline   Reply With Quote

Old   March 21, 2016, 12:47
Default
  #17
Member
 
Ram
Join Date: Oct 2015
Posts: 35
Rep Power: 3
Scram_1 is on a distinguished road
Hey BlnPhoenix,
I tried doing what you'd suggested but its not working...This is what I tried.
This is my custom solver. And I used setDeltaT in the hope that it will read the deltaT from the controlDict file.

#include "fvCFD.H"

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

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

#include "createTime.H"
#include "createMesh.H"
#include "createFields.H"
#include "initContinuityErrs.H"

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

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

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

#include "readPISOControls.H"
#include "readTimeControls.H"
#include "CourantNo.H"
#include "setDeltaT.H"

runTime() ++;



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

solve(UEqn == -fvc::grad(p));

// --- PISO loop

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

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);

for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
);

pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();

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

#include "continuityErrs.H"

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

fvScalarMatrix TEqn
(
fvm::ddt(T)
+ fvm::div(phi, T)
- fvm::laplacian(DT, T)
);

TEqn.solve();

runTime.write();

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

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

return 0;
}


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

Now here's what I get when I run the solver for my case


Time = 12.15578

Courant Number mean: 0.0111567 max: 0.511585
deltaT = 6.45436e-005
smoothSolver: Solving for Ux, Initial residual = 0.00180382, Final residual = 6.162e-007, No Iterations 2
smoothSolver: Solving for Uy, Initial residual = 0.00295248, Final residual = 2.7079e-007, No Iterations 2
DICPCG: Solving for p, Initial residual = 0.0164652, Final residual = 9.7402e-007, No Iterations 732
DICPCG: Solving for p, Initial residual = 4.28776e-005, Final residual = 8.91207e-007, No Iterations 12
DICPCG: Solving for p, Initial residual = 1.30543e-005, Final residual = 8.37702e-007, No Iterations 5
time step continuity errors : sum local = 5.25956e-011, global = 1.0707e-015, cumulative = 6.64415e-011
DICPCG: Solving for p, Initial residual = 0.000841824, Final residual = 9.98842e-007, No Iterations 450
DICPCG: Solving for p, Initial residual = 4.01403e-006, Final residual = 9.26023e-007, No Iterations 10
DICPCG: Solving for p, Initial residual = 2.30103e-006, Final residual = 8.52151e-007, No Iterations 2
time step continuity errors : sum local = 5.35375e-011, global = -3.18539e-012, cumulative = 6.32561e-011
DILUPBiCG: Solving for T, Initial residual = 0.00547638, Final residual = 1.73926e-009, No Iterations 3
ExecutionTime = 839.743 s ClockTime = 840 s

Time = 12.15584

Courant Number mean: 0.0109212 max: 0.510881
deltaT = 6.3169e-005
smoothSolver: Solving for Ux, Initial residual = 0.00179596, Final residual = 5.92427e-007, No Iterations 2
smoothSolver: Solving for Uy, Initial residual = 0.00296089, Final residual = 2.65592e-007, No Iterations 2
DICPCG: Solving for p, Initial residual = 0.0179838, Final residual = 9.62282e-007, No Iterations 731
DICPCG: Solving for p, Initial residual = 3.90246e-005, Final residual = 8.9584e-007, No Iterations 12
DICPCG: Solving for p, Initial residual = 1.18486e-005, Final residual = 8.32487e-007, No Iterations 5
time step continuity errors : sum local = 5.14033e-011, global = -3.29354e-015, cumulative = 6.32529e-011

The Co is no longer blowing up. But the time is not advancing by the step given in the controlDict. If I let the solver solve for some more time, the significant digits in the time reach an absurdly large 8-10 (for example the time shown in the command terminal becomes 12.16543879...). I want the time to advance by the deltaT mentioned in the controlDict.
Any help is greatly appreciated.

Thanks!!
Ram
Scram_1 is offline   Reply With Quote

Old   March 21, 2016, 13:03
Default
  #18
Senior Member
 
Join Date: Aug 2014
Location: N/A
Posts: 139
Rep Power: 4
BlnPhoenix is on a distinguished road
Hi,

so the time in the terminal 12.16543879 would mean that your time step size gets smaller and smaller i suppose. This on the other hand would mean that you have implentend an adjustable time step into the solver. Unfortunatly i have no experience with custom solvers so i cannot say whether the error may be in the implementation into your custom icoFoam solver or in the problem itself (boundary conditions etc.) (

So yea, can you please check that you have set your controlDict to

adjustTimeStep no;

and

writeControl timeStep;

if u want a fixed time step for your simulation?!
Maybe someone else can be of more help. Good luck.
BlnPhoenix is offline   Reply With Quote

Old   March 21, 2016, 17:17
Default
  #19
Member
 
Ram
Join Date: Oct 2015
Posts: 35
Rep Power: 3
Scram_1 is on a distinguished road
Hey BlnPhoenix,
Thanks for your reply. I changed the write control to timeStep and tried again. Now the solver is giving a warning regarding timePrecision. This is what it says

Time = 12.1401

Courant Number mean: 0.00768437 max: 0.0709925
--> FOAM Warning :
From function Time:perator++()
in file db/Time/Time.C at line 1055
Increased the timePrecision from 6 to 18 to distinguish between timeNames at time 12.1401
smoothSolver: Solving for Ux, Initial residual = 0.000179277, Final residual = 9.51591e-009, No Iterations 1
smoothSolver: Solving for Uy, Initial residual = 0.000461942, Final residual = 1.47774e-008, No Iterations 1
DICPCG: Solving for p, Initial residual = 0.0460253, Final residual = 9.43666e-007, No Iterations 734
DICPCG: Solving for p, Initial residual = 0.00357939, Final residual = 9.96147e-007, No Iterations 315
DICPCG: Solving for p, Initial residual = 0.00136696, Final residual = 9.94625e-007, No Iterations 131
time step continuity errors : sum local = 1.01988e-011, global = -1.34098e-013, cumulative = -1.31505e-013
DICPCG: Solving for p, Initial residual = 0.000789953, Final residual = 9.43314e-007, No Iterations 312
DICPCG: Solving for p, Initial residual = 0.000349991, Final residual = 9.73125e-007, No Iterations 57
DICPCG: Solving for p, Initial residual = 0.000195612, Final residual = 9.82302e-007, No Iterations 76
time step continuity errors : sum local = 1.00649e-011, global = -1.88417e-013, cumulative = -3.19922e-013
DILUPBiCG: Solving for T, Initial residual = 0.000736939, Final residual = 1.67772e-008, No Iterations 1
ExecutionTime = 30.088 s ClockTime = 30 s

Time = 12.1401000000000003

Courant Number mean: 0.00768449 max: 0.0717468
smoothSolver: Solving for Ux, Initial residual = 0.000172211, Final residual = 8.9619e-009, No Iterations 1
smoothSolver: Solving for Uy, Initial residual = 0.000430594, Final residual = 1.20743e-008, No Iterations 1
DICPCG: Solving for p, Initial residual = 0.0289387, Final residual = 9.32201e-007, No Iterations 725


It proceeds but the time precision is now 18!! I'm attaching my solver code and Boundary conditions file as well. The case is a simple laminar flow through a pipe. If someone can figure out why this is happening it'll be of great help!

Solver: myicoFoam.C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.

Application
icoFoam

Description
Transient solver for incompressible, laminar flow of Newtonian fluids.

\*---------------------------------------------------------------------------*/

#include "fvCFD.H"

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

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

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

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

while (runTime.run())
{

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


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

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

solve(UEqn == -fvc::grad(p));

// --- PISO loop

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

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);

for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
);

pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();

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

#include "continuityErrs.H"

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

fvScalarMatrix TEqn
(
fvm::ddt(T)
+ fvm::div(phi, T)
- fvm::laplacian(DT, T)
);

TEqn.solve();

runTime.write();

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

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

return 0;
}


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

controlDict:

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application myicoFoam;

startFrom latestTime;

startTime 0;

stopAt endTime;

endTime 25;

deltaT 0.00005;

writeControl timeStep;

writeInterval 200;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression off;

timeFormat general;

maxCo 0.6;

adjustTimeStep no;

timePrecision 6;

runTimeModifiable true;


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

O folder
P:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 2 -2 0 0 0 0];

internalField uniform 0;

boundaryField
{
INLET
{
type zeroGradient;
}

OUTLET
{
type fixedValue;
value uniform 0;
}

TOP_WALL_STRAIGHT
{
type zeroGradient;
}

BOTTOM_WALL_STRAIGHT
{
type zeroGradient;
}

BOTTOM_WALL_WAVY
{
type zeroGradient;
}

TOP_WALL_WAVY
{
type zeroGradient;
}

frontAndBackPlanes
{
type empty;
}
}

// ************************************************** *********************** //
T:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 0 0 1 0 0 0];

internalField uniform 300;

boundaryField
{

INLET
{
type fixedValue;
value uniform 300;
}

OUTLET
{
type zeroGradient;
}

TOP_WALL_STRAIGHT
{
type fixedValue;
value uniform 330;
}

BOTTOM_WALL_STRAIGHT
{
type fixedValue;
value uniform 330;
}

BOTTOM_WALL_WAVY
{
type fixedValue;
value uniform 330;
}

TOP_WALL_WAVY
{
type fixedValue;
value uniform 330;
}

frontAndBackPlanes
{
type empty;
}
}

// ************************************************** *********************** //
U:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 1 -1 0 0 0 0];

internalField uniform (2 0 0);

boundaryField
{
INLET
{
type fixedValue;
value uniform (2 0 0);
}

OUTLET
{
type zeroGradient;
}

TOP_WALL_STRAIGHT
{
type fixedValue;
value uniform (0 0 0);
}

BOTTOM_WALL_STRAIGHT
{
type fixedValue;
value uniform (0 0 0);
}

BOTTOM_WALL_WAVY
{
type fixedValue;
value uniform (0 0 0);
}

TOP_WALL_WAVY
{
type fixedValue;
value uniform (0 0 0);
}

frontAndBackPlanes
{
type empty;
}
}

// ************************************************** *********************** //
Scram_1 is offline   Reply With Quote

Old   March 21, 2016, 17:23
Default
  #20
Member
 
Ram
Join Date: Oct 2015
Posts: 35
Rep Power: 3
Scram_1 is on a distinguished road
I tried removing timePrecision and maxCo from the controlDict file but still its changing the precision to 18 and proceeding. Thought this might help...
Scram_1 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 1 May 19, 2017 10:13
High Courant Number @ icoFoam Artex85 OpenFOAM Running, Solving & CFD 11 February 16, 2017 14:40
Help for the small implementation in turbulence model shipman OpenFOAM Programming & Development 25 March 19, 2014 11:08
AMI speed performance danny123 OpenFOAM 19 October 24, 2012 07:44
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 bookie56 OpenFOAM Installation 8 August 13, 2011 04:03


All times are GMT -4. The time now is 05:10.