CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Questions about the code

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 26, 2010, 04:17
Default Questions about the code
  #1
New Member
 
Alice
Join Date: Nov 2009
Posts: 16
Rep Power: 16
Alicelin is on a distinguished road
Hi everyone,

I got some questions about the code...Can somebody explain what's the meaning of:
1. instantList Times = runTime.times();
2. runTime.setTime(Times[startTime], startTime); ?

Thanks!

Alice
Alicelin is offline   Reply With Quote

Old   January 27, 2010, 04:09
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,677
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by Alicelin View Post
Hi everyone,

I got some questions about the code...Can somebody explain what's the meaning of:
1. instantList Times = runTime.times();
2. runTime.setTime(Times[startTime], startTime); ?
The code states that it get the list of time instants and set the current time to be one of them from the list. What exactly is your question?
olesen is offline   Reply With Quote

Old   January 28, 2010, 01:59
Default
  #3
New Member
 
Alice
Join Date: Nov 2009
Posts: 16
Rep Power: 16
Alicelin is on a distinguished road
Thanks for your reply...I want to know that in
Code:
runTime.setTime(Times[startTime], startTime);
, what's the meaning of the parameters in the blanket(i.e. Times[startTime] and startTime) ? Say if I put 0 or any other time instead of startTime for the second parameter in the blanket, what'll be the changes??

Alice
Alicelin is offline   Reply With Quote

Old   January 28, 2010, 03:42
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,677
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by Alicelin View Post
Thanks for your reply...I want to know that in
Code:
runTime.setTime(Times[startTime], startTime);
, what's the meaning of the parameters in the blanket(i.e. Times[startTime] and startTime) ? Say if I put 0 or any other time instead of startTime for the second parameter in the blanket, what'll be the changes??
If you have "Times[startTime]", that's a time 'instant' and you can see from the corresponding code (in Time.C) what happens:
Code:
void Foam::Time::setTime(const instant& inst, const label newIndex)
{
    value() = inst.value();
    dimensionedScalar::name() = inst.name();
    timeIndex_ = newIndex;

    IOdictionary timeDict
    (
        IOobject
        (
            "time",
            timeName(),
            "uniform",
            *this,
            IOobject::READ_IF_PRESENT,
            IOobject::NO_WRITE,
            false
        )
    );

    timeDict.readIfPresent("deltaT", deltaT_);
    timeDict.readIfPresent("deltaT0", deltaT0_);
    timeDict.readIfPresent("index", timeIndex_);
}
Thus if the specified time instant exists in your results and has the sub-dir with a uniform/time (eg, 0/uniform/time, or 100/uniform/time, etc.) the time index will be read from that file. Otherwise your specified time index will be used.

If you really want to bypass the read dictionary semantics, you could specifying the time value directly as a scalar. For example,
Code:
runTime.setTime(Times[startTime].value(), startTime);
But for most cases, I think that the normal behaviour (with the read dictionary semantics) probably does what you want. For example, suppose you had run a calculation from 0 to 1000 iterations with output every 100 iterations. Your time instantList would have 12 entries (constant, 0, 100 .. 1000). Specifying the following:
Code:
int someTime = 7;
runTime.setTime(Times[someTime], someTime);
This would select the time instance corresponding to '500' with an index of '7'. However, since the uniform/time entry exists, it will be read and the real time index will actually be set to 500. If you wished to continue calculating from here, this is exactly what you want.
olesen is offline   Reply With Quote

Old   January 29, 2010, 02:49
Default
  #5
New Member
 
Alice
Join Date: Nov 2009
Posts: 16
Rep Power: 16
Alicelin is on a distinguished road
Dear olesen,

Thanks for your explanation. It helps

Alice
Alicelin is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
some questions on using unsteady code pangpang Phoenics 0 January 25, 2002 23:22
Design Integration with CFD? John C. Chien Main CFD Forum 19 May 17, 2001 16:56
What is the Better Way to Do CFD? John C. Chien Main CFD Forum 54 April 23, 2001 09:10
own Code vs. commercial code Bernhard Mueck Main CFD Forum 10 February 16, 2000 11:07
public CFD Code development Heinz Wilkening Main CFD Forum 38 March 5, 1999 12:44


All times are GMT -4. The time now is 03:43.