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

Reading old time step

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

Reply
 
LinkBack Thread Tools Display Modes
Old   July 12, 2008, 04:07
Default Hi All, I am trying to modi
  #1
Senior Member
 
Mark Couwenberg
Join Date: Mar 2009
Location: Netherlands
Posts: 130
Rep Power: 8
markc is on a distinguished road
Hi All,

I am trying to modify interFoam solver to my needs.
It is necessary for the new solver to perform an initialisation step (include"initialise.H"). Here, from time = 0 the p field is needed to perform some tasks.
Now my question is: how to make it always reading this time =0?
I tried many things:
In initialise.H add:
//volScalarField p
(
IOobject
(
"p",
runTime.timeName(0),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);

This compiles but when running it reads from the startTime stated in controldict anyway.
Uncommenting the line volScalarField p gives compiler error: p already declared. That is correct, this is done with createrFields.

I moved around with the location in the main solver of the initialisation step, without succes.

I think it is really something trivial, however, not for me apparently.
A more general question (as I have similar questions more often): anyone has advice as where to find some good basic C-programming reading, except for the user manal?

Thanks in advance,

Mark
markc is offline   Reply With Quote

Old   July 14, 2008, 03:20
Default Hi Mark, isn't the pressure
  #2
New Member
 
Tammo Wenterodt
Join Date: Mar 2009
Posts: 24
Rep Power: 8
wenterodt is on a distinguished road
Hi Mark,

isn't the pressure in interFoam called pd? This field is created in createFields.H, you can initialize it right there.

Also when you specify IOobject::MUST_READ, the solver will attempt to read the field upon start. Maybe the combination IOobject::NO_READ, IOobject::AUTO_WRITE is what you are looking for?

Regards,

Tammo
wenterodt is offline   Reply With Quote

Old   July 14, 2008, 04:29
Default Hello Tammo, Thanks for you
  #3
Senior Member
 
Mark Couwenberg
Join Date: Mar 2009
Location: Netherlands
Posts: 130
Rep Power: 8
markc is on a distinguished road
Hello Tammo,

Thanks for your reply. Yes, you are right, pd is usualy used in interFoam. However I created an extra field p which contains hydrostatic pressure. However, this does not matter here. I initialised this in createFields.H as with other fields.
The problem is simply that I can only read it once and that it always uses the startTime from the controlDict, as usual. However I want to read one field (p) one more time but at a different time (always "0" instead of "startTime"). I feel a bit dump about it because I suspect it is really something simple for experienced OF-ers.

Brgds,

Mark
markc is offline   Reply With Quote

Old   July 14, 2008, 04:57
Default How about copying your p-file
  #4
New Member
 
Tammo Wenterodt
Join Date: Mar 2009
Posts: 24
Rep Power: 8
wenterodt is on a distinguished road
How about copying your p-file to "constant" and then use runTime.constant()?
wenterodt is offline   Reply With Quote

Old   July 14, 2008, 06:01
Default Hello Tammo, I think I foun
  #5
Senior Member
 
Mark Couwenberg
Join Date: Mar 2009
Location: Netherlands
Posts: 130
Rep Power: 8
markc is on a distinguished road
Hello Tammo,

I think I found the problem.
The code snippet I posted in the 1st message does not contain the word mesh just before the final bracket.
Now I added this word and it seems to work.
The structure now is:
solver.C
int main(int etc etc)
-
-
#include "createFields.H"
etc etc
#include "initialise.H" (extra header file)
This header file contains amongst others:
(
IOobject
(
"p",
runTime.timeName(0),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
mesh
);

back to solver.C
and further.

It seems to work.
Thanks for your advice,

Mark
markc is offline   Reply With Quote

Old   July 14, 2008, 07:41
Default Recall: no it did not work. In
  #6
Senior Member
 
Mark Couwenberg
Join Date: Mar 2009
Location: Netherlands
Posts: 130
Rep Power: 8
markc is on a distinguished road
Recall: no it did not work. In this setup "initialise.H" still seems to work with the timestep which is stated as "startTime" instead of "0".
We continue trying...
Mark
markc is offline   Reply With Quote

Old   July 14, 2008, 08:27
Default 1. Did you give the runTime.co
  #7
New Member
 
Tammo Wenterodt
Join Date: Mar 2009
Posts: 24
Rep Power: 8
wenterodt is on a distinguished road
1. Did you give the runTime.constant() idea a shot?
2. how about (this is not pretty but might work) creating a field pConst with IOobject::AUTO_WRITE, from which you make a copy "p" (which you can alter as you like) whenever you need it ? The solver should then always find a pConst in the actual time-directory.

Any good?
wenterodt is offline   Reply With Quote

Old   July 14, 2008, 10:00
Default Hello Tammo, 1. Not yet, wi
  #8
Senior Member
 
Mark Couwenberg
Join Date: Mar 2009
Location: Netherlands
Posts: 130
Rep Power: 8
markc is on a distinguished road
Hello Tammo,

1. Not yet, will try asap.
2. Will keep that as emergency exit.

Thanks for your advice,

Mark
markc is offline   Reply With Quote

Old   July 22, 2008, 15:11
Default Hello All, This did the tri
  #9
Senior Member
 
Mark Couwenberg
Join Date: Mar 2009
Location: Netherlands
Posts: 130
Rep Power: 8
markc is on a distinguished road
Hello All,

This did the trick:
>>>
# include "addTimeOptions.H"
# include "setRootCase.H"
# include "createTime.H"

// Get times list
instantList Times = runTime.times();

// set startTime and endTime depending on -time and -latestTime options
# include "checkTimeOptions.H"

runTime.setTime(Times[startTime], 0);
# include "createMesh.H"
# include "createFields.H"
createfields e.g.:
>>>
Info<< "Reading field pd\n" << endl;
volScalarField pd
(
IOobject
(
"pd",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
<<<
<<<
Brgds,

Mark
markc 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
Time step size and max iterations per time step pUl| FLUENT 27 May 12, 2015 20:04
SELECTING TIME STEP SIZE, NUMBER OF TIME STEP NITUL KALITA FLUENT 2 November 22, 2012 09:28
Reading case file at certain time interval Chin Fook FLUENT 1 September 11, 2008 06:54
Long time CHT transient simulation time step.... JP CFX 0 May 9, 2008 03:36
Relation of computational time step with real time Salman Main CFD Forum 2 August 3, 2005 14:13


All times are GMT -4. The time now is 21:07.