Commit 438271b4 authored by Mark Olesen's avatar Mark Olesen

ENH: update to use OpenFOAM-1706 methods

parent 0df6e8b0
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -37,23 +37,12 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
const Foam::Enum<Foam::adiosCore::readType> Foam::adiosCore::readMethodNames
{
template<>
const char* Foam::NamedEnum
<
Foam::adiosCore::readType,
2
>::names[] =
{
"BP",
"BP_AGGREGATE"
};
}
{ readType::READ_BP, "BP"},
{ readType::READ_BP_AGGREGATE, "BP_AGGREGATE" },
};
const Foam::NamedEnum<Foam::adiosCore::readType, 2>
Foam::adiosCore::readMethod;
const Foam::word
Foam::adiosCore::dataDirectory("adiosData");
......@@ -148,16 +137,12 @@ Foam::instantList Foam::adiosCore::findTimes
// Check for "constant" - not yet useful
bool haveConstant = false;
forAll(dirEntries, i)
for (const auto& dirEntry : dirEntries)
{
if
(
dirEntries[i].ext() == fileExt
&& dirEntries[i].lessExt() == constantName
)
if (dirEntry.ext() == fileExt && dirEntry.lessExt() == constantName)
{
Times[nTimes].value() = 0;
Times[nTimes].name() = dataDirectory/dirEntries[i];
Times[nTimes].name() = dataDirectory/dirEntry;
++nTimes;
haveConstant = true;
break;
......@@ -165,20 +150,17 @@ Foam::instantList Foam::adiosCore::findTimes
}
// Read and parse all the entries in the directory
forAll(dirEntries, i)
for (const auto& dirEntry : dirEntries)
{
if
(
dirEntries[i].ext() == fileExt
)
if (dirEntry.ext() == fileExt)
{
IStringStream timeStream(dirEntries[i].lessExt());
IStringStream timeStream(dirEntry.lessExt());
token timeToken(timeStream);
if (timeToken.isNumber() && timeStream.eof())
{
Times[nTimes].value() = timeToken.number();
Times[nTimes].name() = dataDirectory/dirEntries[i];
Times[nTimes].name() = dataDirectory/dirEntry;
++nTimes;
}
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -39,7 +39,7 @@ SourceFiles
#include "word.H"
#include "instantList.H"
#include "IOstreams.H"
#include "NamedEnum.H"
#include "Enum.H"
#include "CStringList.H"
#include "DynamicCharList.H"
......@@ -77,7 +77,7 @@ public:
// Static data
static const NamedEnum<readType, 2> readMethod;
static const Enum<readType> readMethodNames;
private:
......
......@@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 Norbert Podhorszki
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 Norbert Podhorszki
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -271,25 +271,25 @@ void Foam::adiosCoreWrite::putTimeAttributes(const TimeState& t)
{
putIntAttribute
(
adiosTime::attr[adiosTime::INDEX],
adiosTime::attrNames[adiosTime::INDEX],
adiosCore::timeAttribute,
t.timeIndex()
);
putScalarAttribute
(
adiosTime::attr[adiosTime::VALUE],
adiosTime::attrNames[adiosTime::VALUE],
adiosCore::timeAttribute,
t.timeOutputValue()
);
putScalarAttribute
(
adiosTime::attr[adiosTime::DT],
adiosTime::attrNames[adiosTime::DT],
adiosCore::timeAttribute,
t.deltaTValue()
);
putScalarAttribute
(
adiosTime::attr[adiosTime::DT0],
adiosTime::attrNames[adiosTime::DT0],
adiosCore::timeAttribute,
t.deltaT0Value()
);
......
......@@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 Norbert Podhorszki
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 Norbert Podhorszki
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......
......@@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 Norbert Podhorszki
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 Norbert Podhorszki
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -37,18 +37,16 @@ void Foam::adiosCoreWrite::putPatchAttributes(const polyMesh& mesh)
stringList pNames(patches.size());
stringList pTypes(patches.size());
label nPatches = 0;
forAll(patches, patchI)
for (const polyPatch& p : patches)
{
const polyPatch& p = patches[patchI];
// Only count 'real' (non-processor patches)
if (isA<processorPolyPatch>(p))
{
break;
}
pNames[patchI] = p.name();
pTypes[patchI] = p.type();
pNames[nPatches] = p.name();
pTypes[nPatches] = p.type();
++nPatches;
}
......@@ -125,10 +123,8 @@ void Foam::adiosCoreWrite::writeMeshFaces(const polyMesh& mesh)
// calculate content as per CompactIOList.C:
label elemI = 0;
forAll(faces, faceI)
for (const face& f : faces)
{
const face& f = faces[faceI];
forAll(f, i)
{
elems[elemI++] = f[i];
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -149,20 +149,19 @@ int64_t Foam::adiosCoreWrite::writeGeometricField
// Attributes are global - only passed via the master
stringList pTypes(bfield.size());
label nPatches = 0;
forAll(bfield, patchI)
forAll(bfield, patchi)
{
// Only count 'real' (non-processor patches)
if
(
isA<processorFvPatch>(bmesh[patchI])
|| isA<processorPointPatch>(bmesh[patchI])
isA<processorFvPatch>(bmesh[patchi])
|| isA<processorPointPatch>(bmesh[patchi])
)
{
break;
}
pTypes[patchI] = bfield[patchI].type();
++nPatches;
pTypes[nPatches++] = bfield[patchi].type();
}
pTypes.setSize(nPatches);
......@@ -237,12 +236,9 @@ void Foam::adiosCoreWrite::writeMeshZones
const ZoneMeshType& zones
)
{
forAll(zones, zonei)
for (const zone& zn : zones)
{
const zone& zn = zones[zonei];
const word& zoneName = zn.name();
putListVariable(zonePath/zoneName, zn);
putListVariable(zonePath/zn.name(), zn);
}
}
......
......@@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 Norbert Podhorszki
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 Norbert Podhorszki
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -96,10 +96,8 @@ void Foam::adiosReader::scan(bool verbose)
);
// optional: regionName/nClouds, regionName/clouds
forAll(regionNames_, regI)
for (const word& regName : regionNames_)
{
const word& regName = regionNames_[regI];
wordList names;
if
(
......@@ -242,7 +240,7 @@ Foam::adiosReader::getFieldInfo(const word& regName) const
(
varName.count('/') == 2 && varName.path() == startsWith
// Ignore "_0" fields, they are addressed separately
&& varName(varName.size()-2, 2) != "_0"
&& !varName.endsWith("_0")
)
{
// matches regName/field/xxx, but not regName/field/xxx_0
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright(C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -59,11 +59,11 @@ Foam::label Foam::adiosReader::copyList
// Component-wise copy
label srcindex = 0;
forAll(dst, i)
for (Type& dstItem : dst)
{
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; ++cmpt)
{
setComponent(dst[i], cmpt) = src[srcindex++];
setComponent(dstItem, cmpt) = src[srcindex++];
}
}
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -28,25 +28,13 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
const Foam::Enum<Foam::adiosTime::attrType> Foam::adiosTime::attrNames
{
template<>
const char* Foam::NamedEnum
<
Foam::adiosTime::attrType,
4
>::names[] =
{
"index",
"value",
"deltaT",
"deltaT0"
};
}
const Foam::NamedEnum<Foam::adiosTime::attrType, 4>
Foam::adiosTime::attr;
{ attrType::INDEX, "index" },
{ attrType::VALUE, "value" },
{ attrType::DT, "deltaT" },
{ attrType::DT0, "deltaT0" },
};
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -71,10 +59,10 @@ Foam::adiosTime::adiosTime(const TimeState& t)
Foam::adiosTime::adiosTime(const adiosReader& r)
:
index_(r.getIntAttribute(adiosCore::timeAttribute/attr[INDEX])),
value_(r.getScalarAttribute(adiosCore::timeAttribute/attr[VALUE])),
deltaT_(r.getScalarAttribute(adiosCore::timeAttribute/attr[DT])),
deltaT0_(r.getScalarAttribute(adiosCore::timeAttribute/attr[DT0]))
index_(r.getIntAttribute(adiosCore::timeAttribute/attrNames[INDEX])),
value_(r.getScalarAttribute(adiosCore::timeAttribute/attrNames[VALUE])),
deltaT_(r.getScalarAttribute(adiosCore::timeAttribute/attrNames[DT])),
deltaT0_(r.getScalarAttribute(adiosCore::timeAttribute/attrNames[DT0]))
{}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -36,7 +36,7 @@ SourceFiles
#include "adiosCore.H"
#include "NamedEnum.H"
#include "Enum.H"
#include "TimeState.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -77,7 +77,7 @@ public:
//- General time variables within ADIOS file
static const NamedEnum<attrType, 4> attr;
static const Enum<attrType> attrNames;
// Constructors
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright(C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright(C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -47,50 +47,51 @@ Foam::adiosTime Foam::adiosWrite::readData(const fileName& bpFile)
// but have to trick the compiler not to get the const-version.
// - instead, get the names and do the lookup ourselves
wordList meshNames = time().names<fvMesh>();
sort(meshNames);
const wordList meshNames = time().sortedNames<fvMesh>();
// this is somewhat like demand-driven loading
forAll(meshNames, regI)
for (const word& regName : meshNames)
{
const word& regName = meshNames[regI];
fvMesh& mesh = time().lookupObjectRef<fvMesh>(regName);
HashTable<adiosReader::fieldInfo> readerFields = reader.getFieldInfo(regName);
HashTable<adiosReader::cloudInfo> readerClouds = reader.getCloudInfo(regName);
HashTable<adiosReader::fieldInfo> readerFields =
reader.getFieldInfo(regName);
wordList fieldNames = readerFields.sortedToc();
wordList cloudNames = readerClouds.sortedToc();
HashTable<adiosReader::cloudInfo> readerClouds =
reader.getCloudInfo(regName);
const wordList fieldNames = readerFields.sortedToc();
const wordList cloudNames = readerClouds.sortedToc();
Info<<"region " << regName << " has reader:" << nl
<< " fields: " << flatOutput(fieldNames) << nl
<< " clouds: " << flatOutput(cloudNames) << endl;
// fields
forAll(fieldNames, fieldI)
for (const word& name : fieldNames)
{
const word& name = fieldNames[fieldI];
auto iter = static_cast<objectRegistry&>(mesh).find(name);
if ((static_cast<objectRegistry&>(mesh)).found(name))
if (iter.found())
{
reader.readFieldObject
(
*(mesh.find(name)()),
*(iter.object()),
readerFields[name]
);
}
}
// clouds
forAll(cloudNames, fieldI)
for (const word& name : cloudNames)
{
const word& name = cloudNames[fieldI];
auto iter = static_cast<objectRegistry&>(mesh).find(name);
if ((static_cast<objectRegistry&>(mesh)).found(name))
if (iter.found())
{
readCloudObject
(
*(mesh.find(name)()),
*(iter.object()),
reader,
readerClouds[name]
);
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -69,10 +69,8 @@ void Foam::adiosWrite::regionInfo::read
// Check if the requested fields are actually accessible
DynamicList<word> missing(requestedFields_.size());
forAll(requestedFields_, i)
for (const wordRe& what : requestedFields_)
{
const wordRe& what = requestedFields_[i];
if (!what.isPattern())
{
if (mesh.foundObject<regIOobject>(what))
......@@ -87,9 +85,9 @@ void Foam::adiosWrite::regionInfo::read
}
// Also print the cloud names
forAll(requestedClouds_, i)
for (const auto& name : requestedClouds_)
{
Info<< ' ' << requestedClouds_[i];
Info<< ' ' << name;
}
Info<< nl << endl;
......@@ -177,8 +175,7 @@ bool Foam::adiosWrite::regionInfo::acceptFieldObject
(autoWrite() && obj.writeOpt() == IOobject::AUTO_WRITE)
|| findStrings(requestedFields_, name)
)
// ignore _0 fields
&& !(name.size() > 2 && name(name.size()-2, 2) == "_0")
&& !name.endsWith("_0") // ignore _0 fields
);
}
......
......@@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 Norbert Podhorszki
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 Norbert Podhorszki
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -259,15 +259,16 @@ bool Foam::adiosWrite::read(const dictionary& dict)
wordList warn(regionsDict.size());
label nwarn = 0;
forAllConstIter(dictionary, regionsDict, iter)
forAllConstIters(regionsDict, iter)
{
const word& regName = iter().keyword();
const entry& e = iter();
const word& regName = e.keyword();
if (!regionNames.contains(regName))
{
warn[nwarn++] = regName;
}
if (!iter().isDict())
if (!e.isDict())
{
bad[nbad++] = regName;
}
......@@ -299,10 +300,9 @@ bool Foam::adiosWrite::read(const dictionary& dict)
// For each region
// - uses "explicit" entry and "write" and "ignore" sub-dictionaries
forAll(regionNames, regI)
for (const word& regName : regionNames)
{
// cannot fail since the region name came from previous lookup
const word& regName = regionNames[regI];
const fvMesh& mesh = time().lookupObject<fvMesh>(regName);
const entry* dictPtr =
......
......@@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 Norbert Podhorszki
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015 Norbert Podhorszki
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -48,7 +48,7 @@ void Foam::adiosWrite::writeData()
DynamicList<double> faceTimes(regions_.size());
DynamicList<double> pointTimes(regions_.size());
forAllConstIter(RegionInfoContainer, regions_, iter)
forAllConstIters(regions_, iter)
{
const regionInfo& rInfo = iter();
const fvMesh& mesh = time().lookupObject<fvMesh>(rInfo.name());
......@@ -112,10 +112,10 @@ Foam::label Foam::adiosWrite::writeFields
HashTable<word> wroteFields;
HashTable<word> badFields;
wordList sortedNames = mesh.sortedNames();
forAll(sortedNames, i)
const wordList sortedNames = mesh.sortedNames();
for (const word& objName : sortedNames)
{
const regIOobject& obj = *(mesh.find(sortedNames[i])());
const regIOobject& obj = *(mesh.find(objName).object());
const word& name = obj.name();
const word& type = obj.type();
......@@ -136,22 +136,22 @@ Foam::label Foam::adiosWrite::writeFields
if (verbose)
{
wordList names = wroteFields.sortedToc();
forAll(names, fieldI)
const wordList names = wroteFields.sortedToc();
for (const word& name : names)
{
Info<< " " << names[fieldI] << " ("
<< wroteFields[names[fieldI]] << ")" << endl;
Info<< " " << name << " (" << wroteFields[name] << ")" << endl;
}
}
if (!badFields.empty())
{
wordList names = badFields.sortedToc();
const wordList names = badFields.sortedToc();
wordList types(names.size());
forAll(names, fieldI)
label nBad = 0;
for (const word& name : names)
{
types[fieldI] = badFields[names[fieldI]];
types[nBad++] = badFields[name];
}
WarningInFunction
......@@ -169,20 +169,20 @@ Foam::label Foam::adiosWrite::writeFields
Foam::label Foam::adiosWrite::writeClouds(const regionInfo& rInfo)
{
const fvMesh& mesh = time().lookupObject<fvMesh>(rInfo.name());
HashTable<const cloud*> allClouds = mesh.lookupClass<cloud>();
auto allClouds = mesh.lookupClass<cloud>();
if (!allClouds.empty())
{
Info<< " adiosWrite::writeClouds: " << rInfo.info() << endl;
}
wordList sortedNames = mesh.sortedNames<cloud>();
const wordList sortedNames = mesh.sortedNames<cloud>();
HashTable<word> badClouds;
DynamicList<word> cloudNames(allClouds.size());
forAll(sortedNames, i)
for (const word& objName : sortedNames)
{
const regIOobject& obj = *(mesh.find(sortedNames[i])());
const regIOobject& obj = *(mesh.find(objName).object());
const word& name = obj.name();
const word& type = obj.type();
......@@ -212,12 +212,13 @@ Foam::label Foam::adiosWrite::writeClouds(const regionInfo& rInfo)
if (!badClouds.empty())
{
wordList names = badClouds.sortedToc();
const wordList names = badClouds.sortedToc();
wordList types(names.size());
forAll(names, nameI)
label nBad = 0;
for (const word& name : names)
{
types[nameI] = badClouds[names[nameI]];
types[nBad++] = badClouds[name];
}
WarningInFunction
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment