本文整理汇总了C++中IOdictionary::objectPath方法的典型用法代码示例。如果您正苦于以下问题:C++ IOdictionary::objectPath方法的具体用法?C++ IOdictionary::objectPath怎么用?C++ IOdictionary::objectPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOdictionary
的用法示例。
在下文中一共展示了IOdictionary::objectPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
argList::addNote
(
"upgrade the syntax of system/fvSolution::solvers"
);
argList::noParallel();
argList::addBoolOption
(
"test",
"suppress writing the updated system/fvSolution file"
);
# include "setRootCase.H"
# include "createTime.H"
IOdictionary solutionDict
(
IOobject
(
"fvSolution",
runTime.system(),
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
label nChanged = 0;
entry* e = solutionDict.lookupEntryPtr("solvers", false, false);
if (e && e->isDict())
{
nChanged = solution::upgradeSolverDict(e->dict(), true);
}
Info<< nChanged << " solver settings changed" << nl << endl;
if (nChanged)
{
if (args.optionFound("test"))
{
Info<< "-test option: no changes made" << nl << endl;
}
else
{
if (mvBak(solutionDict.objectPath(), "old"))
{
Info<< "Backup to "
<< (solutionDict.objectPath() + ".old") << nl;
}
solutionDict.writeObject
(
IOstream::ASCII,
IOstream::currentVersion,
IOstream::UNCOMPRESSED
);
Info<< "Write to "
<< solutionDict.objectPath() << nl << endl;
}
}
return 0;
}
示例2: forAllConstIter
void rewriteField
(
const bool isTestRun,
const Time& runTime,
const word& fieldName,
const HashTable<word>& thisNames,
const HashTable<word>& nbrNames
)
{
// Read dictionary. (disable class type checking so we can load
// field)
Info<< "Loading field " << fieldName << endl;
const word oldTypeName = IOdictionary::typeName;
const_cast<word&>(IOdictionary::typeName) = word::null;
IOdictionary fieldDict
(
IOobject
(
fieldName,
runTime.timeName(),
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
const_cast<word&>(IOdictionary::typeName) = oldTypeName;
// Fake type back to what was in field
const_cast<word&>(fieldDict.type()) = fieldDict.headerClassName();
dictionary& boundaryField = fieldDict.subDict("boundaryField");
label nChanged = 0;
forAllConstIter(HashTable<word>, thisNames, iter)
{
const word& patchName = iter.key();
const word& newName = iter();
Info<< "Looking for entry for patch " << patchName << endl;
// Find old patch name either direct or through wildcards
// Find new patch name direct only
if
(
boundaryField.found(patchName)
&& !boundaryField.found(newName, false, false)
)
{
Info<< " Changing entry " << patchName << " to " << newName
<< endl;
dictionary& patchDict = boundaryField.subDict(patchName);
if (patchDict.found("value"))
{
// Remove any value field since wrong size.
patchDict.remove("value");
}
boundaryField.changeKeyword(patchName, newName);
boundaryField.add
(
nbrNames[patchName],
patchDict
);
Info<< " Adding entry " << nbrNames[patchName] << endl;
nChanged++;
}
}
// Info<< "New boundaryField:" << boundaryField << endl;
if (returnReduce(nChanged, sumOp<label>()) > 0)
{
if (isTestRun)
{
// Info<< "-test option: no changes made" << endl;
}
else
{
if (mvBak(fieldDict.objectPath(), "old"))
{
Info<< "Backup to "
<< (fieldDict.objectPath() + ".old") << nl;
}
Info<< "Write to "
<< fieldDict.objectPath() << endl;
fieldDict.regIOobject::write();
}
}
else
{
//.........这里部分代码省略.........
示例3: main
//.........这里部分代码省略.........
IOobject::NO_WRITE,
false
)
);
if (!solutionDict.found("solvers"))
{
Info<<"no solvers entry found in : " << dictName << endl;
return 2;
}
if (optRewrite && solutionDict.instance() != "system")
{
Info<<"instance is not 'system' "
"- disabling rewrite for this file" << nl;
optRewrite = false;
}
dictionary& solverDict = solutionDict.subDict("solvers");
wordList names = solverDict.toc();
wordList oldNames = names;
bool changed = false;
for (label orig = 0; orig < names.size()-1; ++orig)
{
// skip patterns or entries that have already been done
if (names[orig].empty() || wordRe::isPattern(names[orig]))
{
continue;
}
const dictionary& dict1 = solverDict.subDict(names[orig]);
for (label check = orig+1; check < names.size(); ++check)
{
// skip patterns or entries that have already been done
if (names[check].empty() || wordRe::isPattern(names[check]))
{
continue;
}
const dictionary& dict2 = solverDict.subDict(names[check]);
// check for identical content
if (checkDictionaryContent(dict1, dict2))
{
names[orig] += "|" + names[check];
names[check].clear();
changed = true;
}
}
}
if (changed)
{
forAll(names, nameI)
{
if (names[nameI].empty())
{
solverDict.remove(oldNames[nameI]);
Info<<" #remove " << oldNames[nameI];
}
else
{
Info<< " " << oldNames[nameI];
if (names[nameI] != oldNames[nameI])
{
// make "(abc|def)" pattern
keyType renamed( "(" + names[nameI] + ")", true);
solverDict.changeKeyword(oldNames[nameI], renamed);
Info<< " -> " << renamed;
}
}
Info<< endl;
}
if (optRewrite)
{
mvBak(solutionDict.objectPath(), "orig");
Info<< "Backup to .orig" << nl
<< "Writing " << solutionDict.objectPath() << nl << endl;
solutionDict.regIOobject::write();
}
else if (optShow)
{
IOobject::writeDivider(Info);
solutionDict.dictionary::write(Info, false);
}
else
{
Info<< "\nFile not rewritten" << endl;
}
}
else
{