|
[Sponsors] |
October 17, 2008, 10:38 |
Hi,
I am writing a tool wit
|
#1 |
Senior Member
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17 |
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 |
|
October 20, 2008, 09:35 |
Problem solved, there seem to
|
#2 |
Senior Member
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17 |
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.
|
|
October 20, 2008, 12:07 |
Another thing, if the destinat
|
#3 |
Senior Member
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17 |
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.
|
|
October 20, 2008, 15:34 |
Bit strange usage. Split the .
|
#4 |
Senior Member
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26 |
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.
|
|
December 1, 2008, 12:21 |
Hi,
I would like to get rid
|
#5 |
Senior Member
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17 |
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 ? |
|
December 1, 2008, 13:27 |
I also tried using std::vector
|
#6 |
Senior Member
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17 |
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 |
|
December 1, 2008, 13:58 |
Finally,
using initializers
|
#7 |
Senior Member
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17 |
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... |
|
December 2, 2008, 03:20 |
John,
Why don't you try a P
|
#8 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,679
Rep Power: 40 |
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] ) ); } |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
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 07:11 |
New to writing UDF | Sandilya | FLUENT | 0 | May 31, 2007 13:03 |
Problem seeing new case in case browser | alan_fergus | OpenFOAM Pre-Processing | 9 | June 22, 2006 04:46 |
Pb with writing the Case and Dat files | Sam | FLUENT | 2 | May 14, 2004 12:16 |