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

IOobject

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 1 Post By alimea
  • 1 Post By alimea
  • 2 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 23, 2017, 03:23
Default IOobject
  #1
Senior Member
 
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12
alimea is on a distinguished road
Hi
I'm a new user in OpenFoam.
plz tell me about what these lines of "creatFields.H" files do:

volScalarField T
(
IOobject //What is it?
(
"omega",
runTime.timeName(),
mesh,
IOobject::MUST_READ, //What's the meaning?
IOobject::AUTO_WRITE //What's the meaning?
),
mesh //What is it?
);
granzer likes this.
alimea is offline   Reply With Quote

Old   January 23, 2017, 04:46
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Documentation is useful from time to time: http://cpp.openfoam.org/v4/a01196.html#details

And mesh is mesh object created within createMesh.H file, which is included before createFields.H.
alexeym is offline   Reply With Quote

Old   January 23, 2017, 05:30
Default
  #3
Senior Member
 
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12
alimea is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Hi,

Documentation is useful from time to time: http://cpp.openfoam.org/v4/a01196.html#details

And mesh is mesh object created within createMesh.H file, which is included before createFields.H.

Dear Alexey
According to what I have found out, we call the mesh file by using this command. is it true? If yes, why do we need mesh at the middle of reading T from initial condition?

another question:
I want to change laplacianFoam to solve this equation:
laplacian(sai)=omega
is this procedure true:
1- defining sai and omega in createFilelds.H:

volScalarField sai
(
IOobject
(
"sai",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);


volScalarField omega
(
IOobject
(
"omega",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);


2- in file mylaplacian.C :

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------

#include "fvCFD.H"
#include "simpleControl.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
#include "setRootCase.H"

#include "createTime.H"
#include "createMesh.H"
#include "createFields.H"

simpleControl simple(mesh);

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Info<< "\nCalculating temperature distribution\n" << endl;

while (simple.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;

while (simple.correctNonOrthogonal())
{
solve(fvm::laplacian(sai) == omega);

#include "write.H"

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}

Info<< "End\n" << endl;

return 0;
}



3- debuging the code
granzer likes this.
alimea is offline   Reply With Quote

Old   January 23, 2017, 05:42
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Not quite sure I have got what you tried to say, in particular

Quote:
Originally Posted by alimea View Post
According to what I have found out, we call the mesh file by using this command. is it true? If yes, why do we need mesh at the middle of reading T from initial condition?
This one is completely beyond my mental capabilities. Every volume field needs reference to mesh, since inside the file only list of values is stored. That is why mesh is one of the parameters in volScalarField constructor.

Quote:
another question:
I want to change laplacianFoam to solve this equation:
laplacian(sai)=omega
is this procedure true:
...
You have problem with brackets in your code. write.H header in laplacianFoam assumes that diffused scalar if called T, calculates gradient of T and then writes results. Since you would like to operate on the field called sai, you do not need write.H, just use runTime.write(). The rest is more or less correct for the problem you have described.
alexeym is offline   Reply With Quote

Old   January 24, 2017, 06:59
Default
  #5
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by alimea View Post
Dear Alexey
According to what I have found out, we call the mesh file by using this command. is it true? If yes, why do we need mesh at the middle of reading T from initial condition?

Code:
volScalarField sai
( 
     IOobject
     ( 
        "sai", 
        runTime.timeName(), 
        mesh, 
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
     ), 
     mesh
);


The first 'mesh' (as part of the IOobject) provides the object-registry where the field will be read/written - the path of the case, the mesh region (normally defaultRegion, but could be multi-region).
The second 'mesh' is the reference where your field will be attached to.

/mark
granzer and CorbinMG like this.
olesen is offline   Reply With Quote

Old   January 24, 2017, 08:52
Default
  #6
Senior Member
 
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12
alimea is on a distinguished road
Quote:
Originally Posted by olesen View Post
The first 'mesh' (as part of the IOobject) provides the object-registry where the field will be read/written - the path of the case, the mesh region (normally defaultRegion, but could be multi-region).
The second 'mesh' is the reference where your field will be attached to.

/mark
I think I have to learn more about objectRegistry.
Thanks
alimea is offline   Reply With Quote

Reply

Tags
ioobject


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
Read a vector list with IFstream and create IOobject from it Sylv OpenFOAM Programming & Development 1 October 9, 2017 16:25
Creating a new field from terms of the turbulence model HaZe OpenFOAM Programming & Development 15 November 24, 2014 14:51
IOobject Function+interPhaseChangeFoam nimasam OpenFOAM 1 July 21, 2010 22:56
reconstructParMesh not working with an axisymetric case francesco OpenFOAM Bugs 4 May 8, 2009 06:49
Saving patch motion as an IOobject jaswi OpenFOAM Running, Solving & CFD 1 June 26, 2007 14:07


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