|
[Sponsors] |
![]() |
![]() |
#1 |
Member
Radu Mustata
Join Date: Mar 2009
Location: Zaragoza, Spain
Posts: 99
Rep Power: 18 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 27 ![]() |
- 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 |
|
![]() |
![]() |
![]() |
![]() |
#3 |
Member
Radu Mustata
Join Date: Mar 2009
Location: Zaragoza, Spain
Posts: 99
Rep Power: 18 ![]() |
Try adding before everything you wrote
volVectorField* UmeanPtr; Radu |
|
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 19 ![]() |
The code already contains such declaration. Sorry I just posted some parts of the code.
Regards, Maka |
|
![]() |
![]() |
![]() |
![]() |
#5 |
Senior Member
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 27 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#6 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 19 ![]() |
Thanks Mattijs for your help.
best regards, Maka |
|
![]() |
![]() |
![]() |
![]() |
#7 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 19 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#8 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 19 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#9 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 19 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#10 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 19 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#11 |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 22 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#12 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 19 ![]() |
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; |
|
![]() |
![]() |
![]() |
![]() |
#13 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 19 ![]() |
The header is not read automatically. The solution is to add the following before using header.headerClassName().
// read header Xheader.headerOk(); |
|
![]() |
![]() |
![]() |
![]() |
#14 |
Senior Member
Pierre-Olivier Dallaire
Join Date: Mar 2009
Location: Montreal, Quebec, Canada
Posts: 192
Rep Power: 18 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#15 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 21 ![]() |
Is there a directory called "constant/boundaryData/patchTest" in your case directory?
Dragos |
|
![]() |
![]() |
![]() |
![]() |
#16 |
Senior Member
Pierre-Olivier Dallaire
Join Date: Mar 2009
Location: Montreal, Quebec, Canada
Posts: 192
Rep Power: 18 ![]() |
yes I have it
Thanks PO |
|
![]() |
![]() |
![]() |
![]() |
#17 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 21 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#18 |
Senior Member
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 21 ![]() |
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!" |
|
![]() |
![]() |
![]() |
![]() |
#19 |
Senior Member
Pierre-Olivier Dallaire
Join Date: Mar 2009
Location: Montreal, Quebec, Canada
Posts: 192
Rep Power: 18 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#20 |
Senior Member
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 21 ![]() |
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!" |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
A question on IOObject | ivan_cozza | OpenFOAM | 0 | September 16, 2008 03:24 |
Create GeometricField without IOobject | nadine | OpenFOAM Running, Solving & CFD | 3 | August 15, 2008 09:24 |
IOobject and IOfield in OpenFoam | xiao | OpenFOAM Running, Solving & CFD | 0 | April 2, 2008 21:56 |
Use of IOobject to Output | irishdave | OpenFOAM Pre-Processing | 1 | January 8, 2008 11:12 |
IOobject constructor problem | iyer_arvind | OpenFOAM Running, Solving & CFD | 3 | November 19, 2006 06:39 |