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

IOobject

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

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 16, 2005, 06:28
Default Hi Guys, If I created an arr
  #1
Member
 
Radu Mustata
Join Date: Mar 2009
Location: Zaragoza, Spain
Posts: 99
Rep Power: 17
r2d2 is on a distinguished road
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
mm.abdollahzadeh likes this.
r2d2 is offline   Reply With Quote

Old   September 16, 2005, 14:11
Default - Is 'fields' still in scope b
  #2
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
- 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
mattijs is offline   Reply With Quote

Old   February 9, 2006, 08:48
Default Try adding before everything y
  #3
Member
 
Radu Mustata
Join Date: Mar 2009
Location: Zaragoza, Spain
Posts: 99
Rep Power: 17
r2d2 is on a distinguished road
Try adding before everything you wrote
volVectorField* UmeanPtr;
Radu
r2d2 is offline   Reply With Quote

Old   February 9, 2006, 09:29
Default The code already contains such
  #4
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
The code already contains such declaration. Sorry I just posted some parts of the code.

Regards,
Maka
maka is offline   Reply With Quote

Old   February 9, 2006, 15:28
Default outputTime() probably only get
  #5
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
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.
mattijs is offline   Reply With Quote

Old   February 10, 2006, 11:05
Default Thanks Mattijs for your help.
  #6
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
Thanks Mattijs for your help.

best regards,
Maka
maka is offline   Reply With Quote

Old   February 14, 2006, 06:56
Default in the following part of the c
  #7
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
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
maka is offline   Reply With Quote

Old   February 14, 2006, 10:50
Default Umean.write() does not work in
  #8
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
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
maka is offline   Reply With Quote

Old   February 20, 2006, 09:14
Default forcing a read operation Wo
  #9
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
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
maka is offline   Reply With Quote

Old   February 21, 2006, 08:07
Default runTime.end() does not work if
  #10
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
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.
maka is offline   Reply With Quote

Old   February 21, 2006, 08:16
Default You could just read the end ti
  #11
Senior Member
 
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21
eugene is on a distinguished road
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.
eugene is offline   Reply With Quote

Old   March 4, 2008, 12:00
Default I expected the following code
  #12
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
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;
maka is offline   Reply With Quote

Old   March 4, 2008, 13:06
Default The header is not read automat
  #13
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
The header is not read automatically. The solution is to add the following before using header.headerClassName().

// read header
Xheader.headerOk();
maka is offline   Reply With Quote

Old   December 9, 2008, 09:02
Default Good morning, I'm writting
  #14
Senior Member
 
Pierre-Olivier Dallaire
Join Date: Mar 2009
Location: Montreal, Quebec, Canada
Posts: 192
Rep Power: 17
podallaire is on a distinguished road
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
podallaire is offline   Reply With Quote

Old   December 10, 2008, 06:08
Default Is there a directory called "c
  #15
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Is there a directory called "constant/boundaryData/patchTest" in your case directory?

Dragos
dmoroian is offline   Reply With Quote

Old   December 10, 2008, 08:27
Default 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
podallaire is on a distinguished road
yes I have it

Thanks

PO
podallaire is offline   Reply With Quote

Old   December 11, 2008, 02:33
Default Hm, then I suggest that right
  #17
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
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
dmoroian is offline   Reply With Quote

Old   July 31, 2009, 13:22
Default
  #18
Senior Member
 
sega's Avatar
 
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20
sega is on a distinguished road
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!"
sega is offline   Reply With Quote

Old   July 31, 2009, 13:37
Default
  #19
Senior Member
 
Pierre-Olivier Dallaire
Join Date: Mar 2009
Location: Montreal, Quebec, Canada
Posts: 192
Rep Power: 17
podallaire is on a distinguished road
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
podallaire is offline   Reply With Quote

Old   July 31, 2009, 13:48
Default
  #20
Senior Member
 
sega's Avatar
 
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20
sega is on a distinguished road
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!"
sega 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
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


All times are GMT -4. The time now is 08:44.