ENH: IOobject headerClassName now initialised to empty value

- was previously populated with "IOobject" (the typeName) but then
  cannot easily detect if the object was actually read.
  Also clear the headerClassName on a failed read

BUG: parallel inconsistency in regIOobject::readHeaderOk

- headerOk() checked with master, but possible parallel operations
  within it
This commit is contained in:
mattijs
2022-11-08 11:17:46 +00:00
committed by Mark Olesen
parent e401e8f132
commit 69be54107d
4 changed files with 17 additions and 15 deletions

View File

@ -272,18 +272,18 @@ void evaluate
);
io.typeHeaderOk<IOobject>(false);
oldFieldType = io.headerClassName();
if (oldFieldType == IOobject::typeName)
if (!io.hasHeaderClass() || io.isHeaderClass<IOobject>())
{
FatalErrorInFunction
<< "Field " << fieldName << "(type: " << oldFieldType
<< ") seems to be missing. Use 'create'" << nl
<< "Field '" << fieldName
<< "' seems to be missing. Use 'create'" << nl
<< exit(FatalError);
}
oldFieldType = io.headerClassName();
Info<< "Modify field: " << fieldName
<< " (type " << oldFieldType << ')';
<< " (type: " << oldFieldType << ')';
}

View File

@ -321,7 +321,7 @@ Foam::IOobject::IOobject
sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
name_(name),
headerClassName_(typeName),
headerClassName_(),
note_(),
instance_(instance),
local_(),
@ -331,8 +331,7 @@ Foam::IOobject::IOobject
if (objectRegistry::debug)
{
InfoInFunction
<< "Constructing IOobject called " << name_
<< " of type " << headerClassName_ << endl;
<< "Constructing IOobject: " << name_ << endl;
}
}
@ -352,7 +351,7 @@ Foam::IOobject::IOobject
sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
name_(name),
headerClassName_(typeName),
headerClassName_(),
note_(),
instance_(instance),
local_(local),
@ -362,8 +361,7 @@ Foam::IOobject::IOobject
if (objectRegistry::debug)
{
InfoInFunction
<< "Constructing IOobject called " << name_
<< " of type " << headerClassName_ << endl;
<< "Constructing IOobject: " << name_ << endl;
}
}
@ -381,7 +379,7 @@ Foam::IOobject::IOobject
sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
name_(),
headerClassName_(typeName),
headerClassName_(),
note_(),
instance_(),
local_(),
@ -398,8 +396,7 @@ Foam::IOobject::IOobject
if (objectRegistry::debug)
{
InfoInFunction
<< "Constructing IOobject called " << name_
<< " of type " << headerClassName_ << endl;
<< "Constructing IOobject: " << name_ << endl;
}
}

View File

@ -120,6 +120,9 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is)
writeHeader(Info);
// Mark as not read
headerClassName_.clear();
return false;
}

View File

@ -60,7 +60,9 @@ bool Foam::regIOobject::readHeaderOk
{
if (Pstream::master())
{
const bool oldParRun = Pstream::parRun(false);
isHeaderOk = headerOk();
Pstream::parRun(oldParRun);
}
Pstream::broadcast(isHeaderOk);
}