STYLE: prefer isHeaderClass<Type>() check instead of Type::typeName
- use typeHeaderOk<regIOobject>(false) for some generic file existence checks. Often had something like labelIOField as a placeholder, but that may be construed to have a particular something.
This commit is contained in:
parent
bdd384c767
commit
f41d1879b9
@ -218,7 +218,7 @@ bool writeOptionalMeshObject
|
||||
);
|
||||
|
||||
bool writeOk = false;
|
||||
const bool haveFile = io.typeHeaderOk<IOField<label>>(false);
|
||||
const bool haveFile = io.typeHeaderOk<regIOobject>(false);
|
||||
|
||||
// Make sure all know if there is a valid class name
|
||||
wordList classNames(1, io.headerClassName());
|
||||
@ -375,41 +375,41 @@ int main(int argc, char *argv[])
|
||||
|
||||
forAllConstIters(objects, iter)
|
||||
{
|
||||
const word& headerClassName = (*iter)->headerClassName();
|
||||
const IOobject& io = *(iter.val());
|
||||
|
||||
if
|
||||
(
|
||||
headerClassName == volScalarField::typeName
|
||||
|| headerClassName == volVectorField::typeName
|
||||
|| headerClassName == volSphericalTensorField::typeName
|
||||
|| headerClassName == volSymmTensorField::typeName
|
||||
|| headerClassName == volTensorField::typeName
|
||||
io.isHeaderClass<volScalarField>()
|
||||
|| io.isHeaderClass<volVectorField>()
|
||||
|| io.isHeaderClass<volSphericalTensorField>()
|
||||
|| io.isHeaderClass<volSymmTensorField>()
|
||||
|| io.isHeaderClass<volTensorField>()
|
||||
|
||||
|| headerClassName == surfaceScalarField::typeName
|
||||
|| headerClassName == surfaceVectorField::typeName
|
||||
|| headerClassName == surfaceSphericalTensorField::typeName
|
||||
|| headerClassName == surfaceSymmTensorField::typeName
|
||||
|| headerClassName == surfaceTensorField::typeName
|
||||
|| io.isHeaderClass<surfaceScalarField>()
|
||||
|| io.isHeaderClass<surfaceVectorField>()
|
||||
|| io.isHeaderClass<surfaceSphericalTensorField>()
|
||||
|| io.isHeaderClass<surfaceSymmTensorField>()
|
||||
|| io.isHeaderClass<surfaceTensorField>()
|
||||
|
||||
|| headerClassName == pointScalarField::typeName
|
||||
|| headerClassName == pointVectorField::typeName
|
||||
|| headerClassName == pointSphericalTensorField::typeName
|
||||
|| headerClassName == pointSymmTensorField::typeName
|
||||
|| headerClassName == pointTensorField::typeName
|
||||
|| io.isHeaderClass<pointScalarField>()
|
||||
|| io.isHeaderClass<pointVectorField>()
|
||||
|| io.isHeaderClass<pointSphericalTensorField>()
|
||||
|| io.isHeaderClass<pointSymmTensorField>()
|
||||
|| io.isHeaderClass<pointTensorField>()
|
||||
|
||||
|| headerClassName == volScalarField::Internal::typeName
|
||||
|| headerClassName == volVectorField::Internal::typeName
|
||||
|| headerClassName == volSphericalTensorField::Internal::typeName
|
||||
|| headerClassName == volSymmTensorField::Internal::typeName
|
||||
|| headerClassName == volTensorField::Internal::typeName
|
||||
|| io.isHeaderClass<volScalarField::Internal>()
|
||||
|| io.isHeaderClass<volVectorField::Internal>()
|
||||
|| io.isHeaderClass<volSphericalTensorField::Internal>()
|
||||
|| io.isHeaderClass<volSymmTensorField::Internal>()
|
||||
|| io.isHeaderClass<volTensorField::Internal>()
|
||||
)
|
||||
{
|
||||
Info<< " Reading " << headerClassName
|
||||
<< " : " << (*iter)->name() << endl;
|
||||
Info<< " Reading " << io.headerClassName()
|
||||
<< " : " << io.name() << endl;
|
||||
|
||||
fieldDictionary fDict(*iter(), headerClassName);
|
||||
fieldDictionary fDict(io, io.headerClassName());
|
||||
|
||||
Info<< " Writing " << (*iter)->name() << endl;
|
||||
Info<< " Writing " << io.name() << endl;
|
||||
fDict.regIOobject::write();
|
||||
}
|
||||
}
|
||||
|
@ -39,9 +39,9 @@ Foam::wordList Foam::helpTypes::helpBoundary::fieldConditions
|
||||
const bool write
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
if (io.headerClassName() == fieldType::typeName)
|
||||
if (io.isHeaderClass<VolFieldType>())
|
||||
{
|
||||
wordList types
|
||||
(
|
||||
@ -74,6 +74,8 @@ void Foam::helpTypes::helpBoundary::fixedValueFieldConditions
|
||||
const IOobject& io
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
wordList types(fieldConditions<Type>(io, false));
|
||||
|
||||
if (!types.size())
|
||||
@ -81,11 +83,9 @@ void Foam::helpTypes::helpBoundary::fixedValueFieldConditions
|
||||
return;
|
||||
}
|
||||
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
const fvMesh& mesh = dynamic_cast<const fvMesh&>(io.db());
|
||||
|
||||
fieldType fld
|
||||
VolFieldType fld
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
|
@ -39,7 +39,7 @@ void Foam::addToFieldList
|
||||
const typename GeoField::Mesh& mesh
|
||||
)
|
||||
{
|
||||
if (obj.headerClassName() == GeoField::typeName)
|
||||
if (obj.isHeaderClass<GeoField>())
|
||||
{
|
||||
fieldList.set
|
||||
(
|
||||
|
@ -107,12 +107,12 @@ IOobjectList preFilterFields
|
||||
if
|
||||
(
|
||||
//OR: fieldTypes::basic.found(io.headerClassName())
|
||||
io.headerClassName() == IOField<label>::typeName
|
||||
|| io.headerClassName() == IOField<scalar>::typeName
|
||||
|| io.headerClassName() == IOField<vector>::typeName
|
||||
|| io.headerClassName() == IOField<sphericalTensor>::typeName
|
||||
|| io.headerClassName() == IOField<symmTensor>::typeName
|
||||
|| io.headerClassName() == IOField<tensor>::typeName
|
||||
io.isHeaderClass<IOField<label>>()
|
||||
|| io.isHeaderClass<IOField<scalar>>()
|
||||
|| io.isHeaderClass<IOField<vector>>()
|
||||
|| io.isHeaderClass<IOField<sphericalTensor>>()
|
||||
|| io.isHeaderClass<IOField<symmTensor>>()
|
||||
|| io.isHeaderClass<IOField<tensor>>()
|
||||
)
|
||||
{
|
||||
// Transfer from cloudObjects -> filteredObjects
|
||||
|
@ -52,9 +52,9 @@ autoPtr<GeoFieldType> loadField
|
||||
const IOobject* io
|
||||
)
|
||||
{
|
||||
if (io && io->headerClassName() == GeoFieldType::typeName)
|
||||
if (io && io->isHeaderClass<GeoFieldType>())
|
||||
{
|
||||
Info<< "Reading " << GeoFieldType::typeName
|
||||
Info<< "Reading " << io->headerClassName()
|
||||
<< ' ' << io->name() << endl;
|
||||
|
||||
return autoPtr<GeoFieldType>::New
|
||||
|
@ -121,15 +121,14 @@ class readFieldsHandler
|
||||
(
|
||||
fieldName,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
mesh_.thisDb(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
const bool ok =
|
||||
(
|
||||
io.typeHeaderOk<regIOobject>(false) // Preload header info
|
||||
&& io.hasHeaderClass() // Extra safety
|
||||
io.typeHeaderOk<regIOobject>(false)
|
||||
&&
|
||||
(
|
||||
loadField<scalar>(io)
|
||||
|
@ -121,15 +121,14 @@ class readFieldsHandler
|
||||
(
|
||||
fieldName,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
mesh_.thisDb(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
const bool ok =
|
||||
(
|
||||
io.typeHeaderOk<regIOobject>(false) // Preload header info
|
||||
&& io.hasHeaderClass() // Extra safety
|
||||
io.typeHeaderOk<regIOobject>(false)
|
||||
&&
|
||||
(
|
||||
loadField<scalar>(io)
|
||||
|
@ -270,9 +270,8 @@ void evaluate
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
io.typeHeaderOk<IOobject>(false);
|
||||
|
||||
if (!io.hasHeaderClass() || io.isHeaderClass<IOobject>())
|
||||
if (!io.typeHeaderOk<regIOobject>(false))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Field '" << fieldName
|
||||
|
@ -28,7 +28,6 @@ License
|
||||
|
||||
#include "IOobjectList.H"
|
||||
#include "Time.H"
|
||||
#include "IOList.H"
|
||||
#include "predicates.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
@ -135,7 +134,7 @@ Foam::IOobjectList::IOobjectList
|
||||
try
|
||||
{
|
||||
// Use object with local scope and current instance (no searching)
|
||||
ok = objectPtr->typeHeaderOk<IOList<label>>(false, false);
|
||||
ok = objectPtr->typeHeaderOk<regIOobject>(false, false);
|
||||
}
|
||||
catch (const Foam::IOerror& err)
|
||||
{
|
||||
|
@ -199,7 +199,7 @@ Foam::word Foam::expressions::fvExprDriver::getHeaderClassName
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
io.typeHeaderOk<IOobject>(false);
|
||||
io.typeHeaderOk<regIOobject>(false);
|
||||
|
||||
DebugInfo
|
||||
<< "Registry: " << mesh.path()
|
||||
|
@ -191,8 +191,7 @@ Foam::label Foam::functionObjects::fvExpressionField::loadFields
|
||||
|
||||
const bool ok =
|
||||
(
|
||||
io.typeHeaderOk<regIOobject>(false) // Preload header info
|
||||
&& io.hasHeaderClass() // Extra safety
|
||||
io.typeHeaderOk<regIOobject>(false)
|
||||
&&
|
||||
(
|
||||
loadField<scalar>(io)
|
||||
|
@ -117,8 +117,7 @@ bool Foam::functionObjects::readFields::execute()
|
||||
|
||||
const bool ok =
|
||||
(
|
||||
io.typeHeaderOk<regIOobject>(false) // Preload header info
|
||||
&& io.hasHeaderClass() // Extra safety
|
||||
io.typeHeaderOk<regIOobject>(false)
|
||||
&&
|
||||
(
|
||||
loadField<scalar>(io)
|
||||
|
@ -36,11 +36,11 @@ License
|
||||
template<class FieldType>
|
||||
bool Foam::functionObjects::readFields::loadAndStore(const IOobject& io)
|
||||
{
|
||||
if (FieldType::typeName == io.headerClassName())
|
||||
if (io.isHeaderClass<FieldType>())
|
||||
{
|
||||
// Store field on mesh database
|
||||
Log << " Reading " << io.name()
|
||||
<< " (" << FieldType::typeName << ')' << endl;
|
||||
<< " (" << io.headerClassName() << ')' << endl;
|
||||
|
||||
mesh_.objectRegistry::store(new FieldType(io, mesh_));
|
||||
return true;
|
||||
|
@ -251,7 +251,7 @@ bool Foam::Cloud<ParticleType>::readStoreFile
|
||||
const IOobject& ioNew
|
||||
) const
|
||||
{
|
||||
if (io.headerClassName() == IOField<Type>::typeName)
|
||||
if (io.isHeaderClass<IOField<Type>>())
|
||||
{
|
||||
IOField<Type> fld(io);
|
||||
auto* fldNewPtr = new IOField<Type>(ioNew, std::move(fld));
|
||||
|
@ -35,38 +35,40 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<class GeoFieldType>
|
||||
static autoPtr<GeoFieldType> loadPointField
|
||||
(
|
||||
const pointMesh::Mesh& mesh,
|
||||
const IOobject* io
|
||||
)
|
||||
|
||||
template<class GeoFieldType>
|
||||
static autoPtr<GeoFieldType> loadPointField
|
||||
(
|
||||
const pointMesh::Mesh& mesh,
|
||||
const IOobject* io
|
||||
)
|
||||
{
|
||||
if (io && io->isHeaderClass<GeoFieldType>())
|
||||
{
|
||||
if (io && io->headerClassName() == GeoFieldType::typeName)
|
||||
{
|
||||
Info<< "Reading " << GeoFieldType::typeName
|
||||
<< ' ' << io->name() << endl;
|
||||
Info<< "Reading " << io->headerClassName()
|
||||
<< ' ' << io->name() << endl;
|
||||
|
||||
return autoPtr<GeoFieldType>::New
|
||||
return autoPtr<GeoFieldType>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
io->name(),
|
||||
io->instance(),
|
||||
io->local(),
|
||||
io->db(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE,
|
||||
io->registerObject()
|
||||
),
|
||||
mesh
|
||||
);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
io->name(),
|
||||
io->instance(),
|
||||
io->local(),
|
||||
io->db(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE,
|
||||
io->registerObject()
|
||||
),
|
||||
mesh
|
||||
);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user