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

Writing in another case

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

Reply
 
LinkBack Thread Tools Display Modes
Old   October 17, 2008, 09:38
Default Hi, I am writing a tool wit
  #1
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 8
johndeas is on a distinguished road
Hi,

I am writing a tool with which I would like to be able to write in another case than the one used to launched the tool (To do operations between fields obtained in different cases).

Here is the kind of field I use to write at time directory 2 in another case:

volVectorField UBase
(
IOobject
(
"UBase",
"../channel-base/2",
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
UFirst
);

However, a call to UBase.write() did not produce the creation of the file in the corresponding directory. Is this a restriction, and is there a way to bypass it ?

Note: I have already used "../" in a case name for an IOobject to read data, it works, but writing does not.

Thanks !

JD
johndeas is offline   Reply With Quote

Old   October 20, 2008, 08:35
Default Problem solved, there seem to
  #2
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 8
johndeas is on a distinguished road
Problem solved, there seem to be no problem to use "../" . I was just writing the wrong fields in my test case and got the impression that nothing was done.
johndeas is offline   Reply With Quote

Old   October 20, 2008, 11:07
Default Another thing, if the destinat
  #3
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 8
johndeas is on a distinguished road
Another thing, if the destination directory ("2" in my example) exist, the file is written there, otherwise a zero directory is created and files are wrtten into it. I don't understand this behaviour.
johndeas is offline   Reply With Quote

Old   October 20, 2008, 14:34
Default Bit strange usage. Split the .
  #4
Super Moderator
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,416
Rep Power: 16
mattijs is on a distinguished road
Bit strange usage. Split the ../channel-base/2 into a local (directory, "../channel-base") and an instance (time, "2"). Might still not work though. Or have an additional runTime to point to the other directory like e.g. mapFields.
mattijs is offline   Reply With Quote

Old   December 1, 2008, 12:21
Default Hi, I would like to get rid
  #5
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 8
johndeas is on a distinguished road
Hi,

I would like to get rid of the strange usage to get a code similar to mapFields: multiple runTime objects. My problem is different in that the number of cases will only be known at runtime (through command-line argument) and I would like to automatize in a loop calls to the constructors. My first attempt was to use something like this:

Foam::Time * dynRunTime = new Foam::Time[nbCases];

for (label i=1;i<nbCases;i++)
{
dynRunTime[i] = Foam::Time
(
Foam::Time::controlDictName,
args.rootPath(),
args.caseName()
)
}

where args.rootPath() and args.caseName() would have been replaced by apropriate pathnames generated automatically using i as a parameter. This construction is however impossible, because the "new" keyword call the constructors immediately.

Is there a simple way to achieve this ?
johndeas is offline   Reply With Quote

Old   December 1, 2008, 13:27
Default I also tried using std::vector
  #6
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 8
johndeas is on a distinguished road
I also tried using std::vector with

std::vector<foam::time> dynRuntime;

dynRuntime.push_back(
Foam::Time(
Foam::Time::controlDictName,
args.rootPath(),
args.caseName()
)
);

but only got compilation errors: http://pastebin.com/f4de2fe3
johndeas is offline   Reply With Quote

Old   December 1, 2008, 13:58
Default Finally, using initializers
  #7
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 8
johndeas is on a distinguished road
Finally,

using initializers and a fixed size array (having to recompile is not a pb, as the array still provide a benefit for loops further in my code):

Foam::Time dynRunTime[2] = {
Foam::Time
(
Foam::Time::controlDictName,
args.rootPath(),
args.caseName()
),
Foam::Time
(
Foam::Time::controlDictName,
args.rootPath(),
args.caseName()
)
};

I still got compilation error ( http://pastebin.com/f78914746 )

Enough for today... If somebody knowledgeable pass by... please... help...
johndeas is offline   Reply With Quote

Old   December 2, 2008, 03:20
Default John, Why don't you try a P
  #8
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
John,

Why don't you try a PtrList to store your pointers?

eg, (pseudo-code)

PtrList<foam::time> myTimes(nbCases);

forAll(myTimes, timeI)
{
myTimes.set
(
timeI,
new Time
(
Foam::Time::controlDictName,
rootPath[timeI],
caseName[timeI]
)
);
}
olesen 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
Cloning a case or creating a new case for 16 processes mellanoxuser OpenFOAM Running, Solving & CFD 0 February 8, 2008 17:52
New with writing UDF/Need help pls mac FLUENT 6 June 14, 2007 06:11
New to writing UDF Sandilya FLUENT 0 May 31, 2007 12:03
Problem seeing new case in case browser alan_fergus OpenFOAM Pre-Processing 9 June 22, 2006 03:46
Pb with writing the Case and Dat files Sam FLUENT 2 May 14, 2004 11:16


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