IOobject class

Here I want to share something about IOobject constructors which is used in the following objects in radiationModelNew.C:

1
2
3
4
5
6
7
8
9
 IOobject radIO
(
"radiationProperties", //this indicates which file in constant folder it is in
T.time().constant(),
T.mesh(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
);

and radiationModel.C

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Foam::IOobject Foam::radiationModel::createIOobject(const fvMesh& mesh) const
{
IOobject io
(
"radiationProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
);
if (io.typeHeaderOk<IOdictionary>(true))
{
io.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
return io;
}
else
{
io.readOpt() = IOobject::NO_READ;
return io;
}
}

They both use the constructor in IOobject.C:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Foam::IOobject::IOobject
(
const word& name,
const fileName& instance,
const objectRegistry& registry,
readOption ro,
writeOption wo,
bool registerObject
)
:
name_(name),
headerClassName_(typeName),
note_(),
instance_(instance),
local_(),
db_(registry),
rOpt_(ro),
wOpt_(wo),
registerObject_(registerObject),
objState_(GOOD)
{
if (objectRegistry::debug)
{
InfoInFunction
<< "Constructing IOobject called " << name_
<< " of type " << headerClassName_
<< endl;
}
}

The readOption and writeOption are both enum member in the IOobject class. For example, in IOobject.H

1
2
3
4
5
6
7
8
//- Enumeration defining the read options
enum readOption
{
MUST_READ,\\0
MUST_READ_IF_MODIFIED,\\1
READ_IF_PRESENT,\\2
NO_READ\\3
};