|
[Sponsors] |
September 16, 2005, 06:28 |
Hi Guys,
If I created an arr
|
#1 |
Member
Radu Mustata
Join Date: Mar 2009
Location: Zaragoza, Spain
Posts: 99
Rep Power: 17 |
Hi Guys,
If I created an array of volScalarFields with this syntax: PtrList<volscalarfield> fields(2); for (int i =0; i<2; i++) { word fieldName = "field" + Foam::name(i); Info<< "Reading field " << fieldName<< endl; fields.hook( volScalarField ( IOobject ( fieldName, runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ) ); } and then I solve some equation for these (two fields for now), at runtime runTime.write(); won´t print out these field values? Am I doing something wrong? Cheers, Radu |
|
September 16, 2005, 14:11 |
- Is 'fields' still in scope b
|
#2 |
Senior Member
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26 |
- Is 'fields' still in scope by the time you call runTime.write() ?
- Do the fields actually get modified? (as far as I can remember only done by some field operators, e.g. assignment, solve) You can set the debug flag for objectRegistry to check if anything gets written |
|
February 9, 2006, 08:48 |
Try adding before everything y
|
#3 |
Member
Radu Mustata
Join Date: Mar 2009
Location: Zaragoza, Spain
Posts: 99
Rep Power: 17 |
Try adding before everything you wrote
volVectorField* UmeanPtr; Radu |
|
February 9, 2006, 09:29 |
The code already contains such
|
#4 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
The code already contains such declaration. Sorry I just posted some parts of the code.
Regards, Maka |
|
February 9, 2006, 15:28 |
outputTime() probably only get
|
#5 |
Senior Member
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26 |
outputTime() probably only gets set if you use the
runTime++ method of incrementing time. This is the way all simulation codes work. Looping over all times like the postprocessing tools do will not (and should not) take notice of the 'writeInterval' setting in the controlDict. So outputTime never gets set. Look at one of the simple postprocessing tools (e.g. magU) on how to forcibly write a field. |
|
February 10, 2006, 11:05 |
Thanks Mattijs for your help.
|
#6 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
Thanks Mattijs for your help.
best regards, Maka |
|
February 14, 2006, 06:56 |
in the following part of the c
|
#7 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
in the following part of the code, Umean.write() only works if it is writen in POSTITION 1 but not 2. The later is the required. It seems that runTime.setTime has some effect.
int main(int argc, char *argv[]) { # include ... # include "createTimeAverages.H" // For each time step read all fields forAll(runTime.times(), i) { Umean.write(); // POSITION 1 runTime.setTime(runTime.times()[i], i); Umean.write(); // POSITION 2 ... } Info<< "end" << endl; return 0; } Umean is defined as : const fileName& local = runTime.timeName(); volVector Field* UmeanPtr = new volVectorField ( IOobject ( "Umean", local, mesh, IOobject::MUST_READ, wo ), mesh ); volVectorField& Umean = *UmeanPtr; I would apreciate any help. Thanks. best Regards, Maka |
|
February 14, 2006, 10:50 |
Umean.write() does not work in
|
#8 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
Umean.write() does not work in POSITION 2 but works outside the loop before main returns. I can live with that. Now, I tried to control the place where Umean.write() writes files by changing:
const fileName& local = "statistics"; but it does not write in statistcs folder, which is a folder that I made to collect all statistics. This makes backup easier since instanous data (big size) and statistics (small size) are separated. any suggestions? Thanks, Maka |
|
February 20, 2006, 09:14 |
forcing a read operation
Wo
|
#9 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
forcing a read operation
Would you please, point to the documentation of write() member function for a volVectorField? is there a read(). I looked into Doxygen docs: I found: GeometricField<vector,> volVectorField Then I looked into all the involved classes, I could not find a write() memeber functions. Thanks, Maka |
|
February 21, 2006, 08:07 |
runTime.end() does not work if
|
#10 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
runTime.end() does not work if you are postprocessing an existing data even if you use runTime.setTime,
This is part of the code: forAll(runTime.times(), i) { runTime.setTime(runTime.times()[i], i); //mesh.readUpdate(); U = volVectorField ( IOobject ( "U", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ), U ); # include "calculateTimeAverages.H" // Average fields over channel down to a line # include "spaceAverageFields.H" if (runTime.end()) { # include "writeTimeAverages.H" } } My question is does any one understand why member functions of Time class works only when the solver is running? What should we do to let them work when we are processing a data? Thanks. Thanks, Maka. |
|
February 21, 2006, 08:16 |
You could just read the end ti
|
#11 |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21 |
You could just read the end time from controlDict and explicitly test for it.
In Time.C line 341 bool Foam::Time::end() const { return (value() > (endTime_ + 0.5*deltaT_)); } So you see your current time has to be at least 0.5 * deltaT larger than endTime to return true. |
|
March 4, 2008, 12:00 |
I expected the following code
|
#12 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
I expected the following code to print: volScalarField T but it prints IOobject T; Is there a way to read the class name that is written in the header file of an IOobject other than headerClassName() (I refer to version 1.3). Thanks.
IOobject Xheader ( "T", runTime.timeName(), mesh, IOobject::MUST_READ ); Info<< "Reading " << Xheader.headerClassName() << " " << varname << endl; |
|
March 4, 2008, 13:06 |
The header is not read automat
|
#13 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
The header is not read automatically. The solution is to add the following before using header.headerClassName().
// read header Xheader.headerOk(); |
|
December 9, 2008, 09:02 |
Good morning,
I'm writting
|
#14 |
Senior Member
Pierre-Olivier Dallaire
Join Date: Mar 2009
Location: Montreal, Quebec, Canada
Posts: 192
Rep Power: 17 |
Good morning,
I'm writting a basic code to produce the necessary files in order to use the timeVaryingMappedFixedValue patch. However, I'm not able to write my object in the specified path. IOobject IOUpatch ( "U", runTime.constant()/"boundaryData"/"patchTest", //runTime.constant(), mesh, IOobject::NO_READ, IOobject::NO_WRITE, false ); vectorIOField Upatch(IOUpatch, sizeMesh); For some reason, when Upatch.write(); is called, the file is written in my initial time step (0). Not sure why - any ideas ? Regards, PO |
|
December 10, 2008, 06:08 |
Is there a directory called "c
|
#15 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
Is there a directory called "constant/boundaryData/patchTest" in your case directory?
Dragos |
|
December 10, 2008, 08:27 |
yes I have it
Thanks
PO
|
#16 |
Senior Member
Pierre-Olivier Dallaire
Join Date: Mar 2009
Location: Montreal, Quebec, Canada
Posts: 192
Rep Power: 17 |
yes I have it
Thanks PO |
|
December 11, 2008, 02:33 |
Hm, then I suggest that right
|
#17 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
Hm, then I suggest that right below the line IOUpatch.write() (I think there is a typo in your post Upatch.write() instead of IOUpatch.write()) insert a new one: system("touch your_case_dir/constant/boundaryData/patchTest/bubu").
See if the file "bubu" gets created! Dragos |
|
July 31, 2009, 13:22 |
|
#18 |
Senior Member
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20 |
I'm currently struggling on the same problem.
I don't know how to specify a particular path when writing a field. Basically I want to do the same as podallaire in his thread from 9. December 2008. Has anybody found a solution to this problem?
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!" |
|
July 31, 2009, 13:37 |
|
#19 |
Senior Member
Pierre-Olivier Dallaire
Join Date: Mar 2009
Location: Montreal, Quebec, Canada
Posts: 192
Rep Power: 17 |
Hi,
Unfortunately I did not solve the issue since groovyBC was the perfect candidate for what I wanted to do. Maybe this program can help you : OpenFOAM-1.5.x/tutorials/interDyMFoam/sloshingTank3D6DoF/gen6DoF Regards, PO |
|
July 31, 2009, 13:48 |
|
#20 |
Senior Member
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20 |
Thanks for your answer. Looks like this file shows me how to write a specific file. But thats what I have already managed to do.
Writing the file with this OFstream command leaves the header, which is essential to the timeVaryingMappedFixedValue boundary condition. Doing this with headers by creating an IOobject I can't choose the right path. Just frustrating!
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!" |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
A question on IOObject | ivan_cozza | OpenFOAM | 0 | September 16, 2008 04:24 |
Create GeometricField without IOobject | nadine | OpenFOAM Running, Solving & CFD | 3 | August 15, 2008 10:24 |
IOobject and IOfield in OpenFoam | xiao | OpenFOAM Running, Solving & CFD | 0 | April 2, 2008 22:56 |
Use of IOobject to Output | irishdave | OpenFOAM Pre-Processing | 1 | January 8, 2008 12:12 |
IOobject constructor problem | iyer_arvind | OpenFOAM Running, Solving & CFD | 3 | November 19, 2006 07:39 |