本文整理汇总了C++中IOdictionary::subDict方法的典型用法代码示例。如果您正苦于以下问题:C++ IOdictionary::subDict方法的具体用法?C++ IOdictionary::subDict怎么用?C++ IOdictionary::subDict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOdictionary
的用法示例。
在下文中一共展示了IOdictionary::subDict方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Foam::flameletModelA::flameletModelA
(
volScalarField& rho,
volVectorField& U,
volScalarField& Su,
volScalarField& Sigma,
volScalarField& b,
psiuReactionThermo& thermo,
compressible::turbulenceModel& turbulence,
IOdictionary& mdData
)
:
flameletModel
(
rho
),
dictionary_(mdData.subDict("flameletModelACoeffs")),
alphaSigma_(readScalar(dictionary_.lookup("alphaSigma"))),
GammaK_(readScalar(dictionary_.lookup("GammaK"))),
betaSigma_(readScalar(dictionary_.lookup("betaSigma"))),
rho_(rho),
U_(U),
Su_(Su),
Sigma_(Sigma),
b_(b),
thermo_(thermo),
turbulence_(turbulence)
{}
示例2: idList
void Foam::moleculeCloud::buildConstProps()
{
Info<< nl << "Reading moleculeProperties dictionary." << endl;
const List<word>& idList(pot_.idList());
constPropList_.setSize(idList.size());
const List<word>& siteIdList(pot_.siteIdList());
IOdictionary moleculePropertiesDict
(
IOobject
(
"moleculeProperties",
mesh_.time().constant(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
forAll(idList, i)
{
const word& id(idList[i]);
const dictionary& molDict(moleculePropertiesDict.subDict(id));
List<word> siteIdNames = molDict.lookup("siteIds");
List<label> siteIds(siteIdNames.size());
forAll(siteIdNames, sI)
{
const word& siteId = siteIdNames[sI];
siteIds[sI] = findIndex(siteIdList, siteId);
if (siteIds[sI] == -1)
{
FatalErrorIn("moleculeCloud.C") << nl
<< siteId << " site not found."
<< nl << abort(FatalError);
}
}
molecule::constantProperties& constProp = constPropList_[i];
constProp = molecule::constantProperties(molDict);
constProp.siteIds() = siteIds;
}
}
示例3: main
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
// Reading faMeshDefinition dictionary
IOdictionary faMeshDefinition
(
IOobject
(
"faMeshDefinition",
runTime.constant(),
"faMesh",
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
wordList polyMeshPatches
(
faMeshDefinition.lookup("polyMeshPatches")
);
dictionary bndDict = faMeshDefinition.subDict("boundary");
wordList faPatchNames = bndDict.toc();
List<faPatchData> faPatches(faPatchNames.size()+1);
forAll (faPatchNames, patchI)
{
dictionary curPatchDict =
bndDict.subDict(faPatchNames[patchI]);
faPatches[patchI].name_ = faPatchNames[patchI];
faPatches[patchI].type_ =
word(curPatchDict.lookup("type"));
faPatches[patchI].ownPolyPatchID_ =
mesh.boundaryMesh().findPatchID
(
word(curPatchDict.lookup("ownerPolyPatch"))
);
faPatches[patchI].ngbPolyPatchID_ =
mesh.boundaryMesh().findPatchID
(
word(curPatchDict.lookup("neighbourPolyPatch"))
);
}
示例4:
Foam::CantPopeBray::CantPopeBray
(
volScalarField& rho,
volVectorField& U,
volScalarField& Su,
volScalarField& Sigma,
volScalarField& b,
psiuReactionThermo& thermo,
compressible::turbulenceModel& turbulence,
IOdictionary& mdData
)
:
flameletModel
(
rho
),
dictionary_(mdData.subDict("CantPopeBrayCoeffs")),
alphaSigma_
(
dictionary_.lookupOrDefault
(
"alphaSigma",
0.28
)
),
betaSigma_
(
dictionary_.lookupOrDefault
(
"betaSigma",
1.0
)
),
aCoeff_
(
dictionary_.lookupOrDefault
(
"aCoeff",
10.0
)
),
rho_(rho),
U_(U),
Su_(Su),
Sigma_(Sigma),
b_(b),
thermo_(thermo),
turbulence_(turbulence)
{}
示例5: isTDAC
Foam::autoPtr<ChemistryModel> Foam::basicChemistryModel::New
(
const fvMesh& mesh
)
{
IOdictionary chemistryDict
(
IOobject
(
"chemistryProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
word chemistryTypeName;
if (chemistryDict.isDict("chemistryType"))
{
const dictionary& chemistryTypeDict
(
chemistryDict.subDict("chemistryType")
);
Info<< "Selecting chemistry type " << chemistryTypeDict << endl;
const int nCmpt = 8;
const char* cmptNames[nCmpt] =
{
"chemistrySolver",
"chemistryModel",
"chemistryThermo",
"transport",
"thermo",
"equationOfState",
"specie",
"energy"
};
IOdictionary thermoDict
(
IOobject
(
"thermophysicalProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
word thermoTypeName;
if (thermoDict.isDict("thermoType"))
{
const dictionary& thermoTypeDict(thermoDict.subDict("thermoType"));
thermoTypeName =
word(thermoTypeDict.lookup("transport")) + '<'
+ word(thermoTypeDict.lookup("thermo")) + '<'
+ word(thermoTypeDict.lookup("equationOfState")) + '<'
+ word(thermoTypeDict.lookup("specie")) + ">>,"
+ word(thermoTypeDict.lookup("energy")) + ">";
}
else
{
FatalIOErrorIn
(
(ChemistryModel::typeName + "::New(const mesh&)").c_str(),
thermoDict
) << "thermoType is in the old format and must be upgraded"
<< exit(FatalIOError);
}
Switch isTDAC(chemistryTypeDict.lookupOrDefault("TDAC",false));
// Construct the name of the chemistry type from the components
if (isTDAC)
{
chemistryTypeName =
word(chemistryTypeDict.lookup("chemistrySolver")) + '<'
+ "TDACChemistryModel<"
+ word(chemistryTypeDict.lookup("chemistryThermo")) + ','
+ thermoTypeName + ">>";
}
else
{
chemistryTypeName =
word(chemistryTypeDict.lookup("chemistrySolver")) + '<'
+ "chemistryModel<"
+ word(chemistryTypeDict.lookup("chemistryThermo")) + ','
+ thermoTypeName + ">>";
}
typename ChemistryModel::fvMeshConstructorTable::iterator cstrIter =
ChemistryModel::fvMeshConstructorTablePtr_->find(chemistryTypeName);
if (cstrIter == ChemistryModel::fvMeshConstructorTablePtr_->end())
//.........这里部分代码省略.........
示例6: tabdict
Foam::autoPtr<Foam::chemistryTabulationMethod<CompType, ThermoType>>
Foam::chemistryTabulationMethod<CompType, ThermoType>::New
(
const IOdictionary& dict,
TDACChemistryModel<CompType, ThermoType>& chemistry
)
{
IOdictionary thermoDict
(
IOobject
(
"thermophysicalProperties",
dict.db().time().constant(),
dict.db(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
word thermoTypeName;
if (thermoDict.isDict("thermoType"))
{
const dictionary& thermoTypeDict(thermoDict.subDict("thermoType"));
thermoTypeName =
word(thermoTypeDict.lookup("transport")) + '<'
+ word(thermoTypeDict.lookup("thermo")) + '<'
+ word(thermoTypeDict.lookup("equationOfState")) + '<'
+ word(thermoTypeDict.lookup("specie")) + ">>,"
+ word(thermoTypeDict.lookup("energy")) + ">";
}
else
{
FatalIOErrorInFunction(thermoDict)
<< "thermoType is in the old format and must be upgraded"
<< exit(FatalIOError);
}
dictionary tabdict(dict.subDict("tabulation"));
word chemistryTabulationMethodName =
word(tabdict.lookup("method")) + '<'
+ word(dict.subDict("chemistryType").lookup("chemistryThermo")) + ','
+ thermoTypeName + '>';
typename dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(chemistryTabulationMethodName);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown chemistryTabulationMethodType type "
<< chemistryTabulationMethodName
<< endl << endl
<< "Valid chemistryTabulationMethodType types are :" << endl
<< dictionaryConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<chemistryTabulationMethod<CompType, ThermoType>>
(
cstrIter()(dict, chemistry)
);
}
示例7: main
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
// Get times list
instantList Times = runTime.times();
const label startTime = 1;
const label endTime = Times.size();
const label nSnapshots = Times.size() - 1;
Info << "Number of snapshots: " << nSnapshots << endl;
// Create a list of snapshots
PtrList<volScalarField> fields(nSnapshots);
runTime.setTime(Times[startTime], startTime);
# include "createMesh.H"
IOdictionary PODsolverDict
(
IOobject
(
"PODsolverDict",
runTime.system(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
scalar accuracy =
readScalar
(
PODsolverDict.subDict("scalarTransportCoeffs").lookup("accuracy")
);
Info << "Seeking accuracy: " << accuracy << endl;
word fieldName
(
PODsolverDict.subDict("scalarTransportCoeffs").lookup("field")
);
label snapI = 0;
labelList timeIndices(nSnapshots);
for (label i = startTime; i < endTime; i++)
{
runTime.setTime(Times[i], i);
Info<< "Time = " << runTime.timeName() << endl;
mesh.readUpdate();
Info<< " Reading " << fieldName << endl;
fields.set
(
snapI,
new volScalarField
(
IOobject
(
fieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
mesh
)
);
// Rename the field
fields[snapI].rename(fieldName + name(i));
timeIndices[snapI] = i;
snapI++;
Info<< endl;
}
timeIndices.setSize(snapI);
// Read accurary
Info<< "Reading \n" << endl;
scalarPODOrthoNormalBase eb(fields, accuracy);
const scalarRectangularMatrix& coeffs = eb.interpolationCoeffs();
// Check all snapshots
forAll (fields, fieldI)
{
runTime.setTime(Times[timeIndices[fieldI]], timeIndices[fieldI]);
volScalarField pReconstruct
//.........这里部分代码省略.........
示例8: main
int main(int argc, char *argv[])
{
# include "addTimeOptions.H"
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
IOdictionary stlDefs
(
IOobject
(
"stlDefinitions",
runTime.constant(),
"triSurface",
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
wordList toc = stlDefs.toc();
forAll (toc, item)
{
if (stlDefs.isDict(toc[item]))
{
Info << "\nCreates the STL surface for " << toc[item] << endl;
pointField pp ( stlDefs.subDict(toc[item]).lookup("points") );
faceList faces( stlDefs.subDict(toc[item]).lookup("faces") );
triFaceList tfl(0);
label count(0);
if (
stlDefs.subDict(toc[item])
.lookupOrDefault<Switch>("extrude", false )
)
{
if (faces.size() <= 1)
{
extrudeFacesAndPoints
(
stlDefs.subDict(toc[item]),
faces,
pp
);
}
else
{
Info << "\nWARNING: Using extrude, but"
<< " multiple faces are defined\n" << endl;
}
}
forAll (faces, facei)
{
faceTriangulation triangulation(pp, faces[facei], true );
tfl.setSize( count + triangulation.size() );
forAll (triangulation, triI)
{
tfl[count++] = triangulation[triI];
}
}
triSurface ts( tfl, pp );
Info << "Writes the STL surface for " << toc[item] << endl;
ts.write( "constant/triSurface/"+toc[item]+".stl" );
}
示例9: main
int main(int argc, char *argv[])
{
argList::validOptions.insert("overwrite", "");
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
# include "createMesh.H"
Info<< "Read mesh in = "
<< runTime.cpuTimeIncrement() << " s" << endl;
const bool overwrite = args.optionFound("overwrite");
// Check patches and faceZones are synchronised
mesh.boundaryMesh().checkParallelSync(true);
meshRefinement::checkCoupledFaceZones(mesh);
// Read decomposePar dictionary
IOdictionary decomposeDict
(
IOobject
(
"decomposeParDict",
runTime.system(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
// Read meshing dictionary
IOdictionary meshDict
(
IOobject
(
"snappyHexMeshDict",
runTime.system(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
// all surface geometry
const dictionary& geometryDict = meshDict.subDict("geometry");
// refinement parameters
const dictionary& refineDict = meshDict.subDict("castellatedMeshControls");
// mesh motion and mesh quality parameters
const dictionary& motionDict = meshDict.subDict("meshQualityControls");
// snap-to-surface parameters
const dictionary& snapDict = meshDict.subDict("snapControls");
// layer addition parameters
const dictionary& layerDict = meshDict.subDict("addLayersControls");
const scalar mergeDist = getMergeDistance
(
mesh,
readScalar(meshDict.lookup("mergeTolerance"))
);
// Debug
// ~~~~~
const label debug(readLabel(meshDict.lookup("debug")));
if (debug > 0)
{
meshRefinement::debug = debug;
autoRefineDriver::debug = debug;
autoSnapDriver::debug = debug;
autoLayerDriver::debug = debug;
}
// Read geometry
// ~~~~~~~~~~~~~
searchableSurfaces allGeometry
(
IOobject
(
"abc", // dummy name
mesh.time().constant(), // instance
//mesh.time().findInstance("triSurface", word::null),// instance
"triSurface", // local
mesh.time(), // registry
IOobject::MUST_READ,
IOobject::NO_WRITE
),
geometryDict
);
//.........这里部分代码省略.........
示例10: getCellTable
void getCellTable(const fvMesh & mesh)
{
cellTableMap_.clear();
cellTableId_.setSize(mesh.nCells(), 1);
IOdictionary cellTableDict
(
IOobject
(
"cellTable",
"constant",
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
)
);
volScalarField volField
(
IOobject
(
"cellTableId",
mesh.time().timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
),
mesh,
dimensionedScalar("cellTableId", dimless, 1.0)
);
// get cellTableId information from the volScalarField if possible
if (volField.headerOk())
{
const scalarField & field = volField.internalField();
forAll(field, cellI)
{
cellTableId_[cellI] = static_cast<int>(field[cellI]);
}
if (cellTableDict.headerOk())
{
// convert dictionary to map
wordList toc = cellTableDict.toc();
forAll(toc, i)
{
word keyword = toc[i];
if (!cellTableDict.isDict(keyword)) continue;
const dictionary & dict = cellTableDict.subDict(keyword);
if (dict.found("Id") && dict.found("MaterialType"))
{
label Id;
dict["Id"] >> Id;
dict["MaterialType"] >> keyword;
if (keyword == "fluid")
{
cellTableMap_.insert(Id, 1);
}
else if (keyword == "solid")
{
cellTableMap_.insert(Id, 2);
}
}
}
示例11:
Foam::coherentFlameModel2b::coherentFlameModel2b
(
volScalarField& rho,
volVectorField& U,
volScalarField& Su,
volScalarField& Sigma,
volScalarField& b,
psiuReactionThermo& thermo,
compressible::turbulenceModel& turbulence,
IOdictionary& mdData
)
:
flameletModel
(
rho
),
dictionary_(mdData.subDict("coherentFlameModel2bCoeffs")),
alphaSigma_
(
dictionary_.lookupOrDefault
(
"alphaSigma",
2.1
)
),
betaSigma_
(
dictionary_.lookupOrDefault
(
"betaSigma",
1.0
)
),
CSigma_
(
dictionary_.lookupOrDefault
(
"CSigma",
0.5
)
),
Clt_
(
dictionary_.lookupOrDefault
(
"Coeff_lt",
1.0
)
),
quenchingCoeff_
(
dictionary_.lookupOrDefault
(
"quenchingCoeff",
1.0
)
),
fittedGammaK_
(
dictionary_.lookupOrDefault
(
"fittedGammaK",
false
)
),
rho_(rho),
U_(U),
Su_(Su),
Sigma_(Sigma),
b_(b),
thermo_(thermo),
turbulence_(turbulence)
{}
示例12: pairDict
polyIdPairs::polyIdPairs
(
const polyMesh& mesh,
const potential& pot
)
:
coeffVals_(),
coeffNames_(),
coeffNumIds_(),
nIds_(0),
coeffSize_(0),
coeffType_("")
{
IOdictionary potentialDict
(
IOobject
(
"potentialDict",
mesh.time().system(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
//obtain information about pairs from pair subdict inside potentialdict
const dictionary& pairDict(potentialDict.subDict("pair"));
List<word> pairs(pairDict.toc());//generate list of pairs
nIds_ = pot.siteIdList().size();//obtain size of siteidlist
label coeffsize = 0;
/**
* traverse throught the list of pairs excluding electrostatic
* further checking for interactions in pairs to take the total number
* of species found which essentially provides a size of dynamic array
* to be formed
* loop until the first existing of coefficients are found after that
* the loop is broken and no further traversal is done.
*/
for(int i = 0;i<pairs.size();i++){
if(pairs[i] != "electrostatic")
{
word pp = pairDict.subDict(pairs[i]).lookup("pairPotential");
if(pp!="noInteraction"){
List<word> coeff(pairDict.subDict(pairs[i]).subDict(pp+"Coeffs").toc());
//get the number of coeff's available
coeffsize = coeff.size();
//set the size of coeffnames followed by generating
//coeff names into coeffnames array
coeffNames_.setSize(coeffsize);
coeffVals_.setSize(coeffsize);//set the size of variables
coeffNumIds_.setSize(coeffsize);
coeffSize_ = coeffsize;
coeffType_ = pp;
for(int k=0; k<coeffsize;++k){
coeffNames_[k] = coeff[k];
coeffNumIds_[k] = k;
}
break;//break if the first existence of coeff found
}
}
}
int c = 0;
for(;c < coeffsize; ++c)
coeffVals_[c].setSize(nIds_);
for(c = 0; c < coeffsize; ++c)
for(int b = 0; b < nIds_; b++)
coeffVals_[c][b].setSize(nIds_);
//make the coeffs zero
for(c=0;c < coeffsize; ++c){
for(int i=0; i<nIds_; ++i){
for(int j=0; j<nIds_; ++j){
coeffVals_[c][i][j] = 0;
}
}
}
/*
* loop over each potential site id list to form pairs of each site id with another
* essentially two loops a and b will be running on each site id to form pairs.
*
* for each pair created it will be checked with corresponding pairs inside potentialDict
* if found pairPotential value for that pair will be obtained.
*
* if the obtained pair potential is not "noInteraction" then the resultant pairPotential value
* will be used to form coeff string to determine "*Coeffs" value which could correspond to
* 'lennardJonesCoeffs', 'morseCoeffs', '*Coeffs' anything related with pairPotential value for that
* particular pair.
*
* further to read each value for the N species inside the coeffs we will be using coeffsize variable
* value obtained at the beginning which essentially consists of number of Species inside coeffs, subsequently
* we will be traversing the loop and will use the list of species name inside coeffsNames_ array
*/
for(int a=0; a<nIds_; a++)
//.........这里部分代码省略.........
示例13: main
int main(int argc, char *argv[])
{
argList::noParallel();
argList::addBoolOption("rewrite");
argList::addBoolOption("show");
argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName());
const word dictName("fvSolution");
bool optRewrite = args.optionFound("rewrite");
bool optShow = args.optionFound("show");
IOdictionary solutionDict
(
IOobject
(
dictName,
"system",
runTime,
IOobject::MUST_READ_IF_MODIFIED,
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;
}
}
//.........这里部分代码省略.........
示例14: exit
Foam::autoPtr<Foam::laminarModel<BasicTurbulenceModel>>
Foam::laminarModel<BasicTurbulenceModel>::New
(
const alphaField& alpha,
const rhoField& rho,
const volVectorField& U,
const surfaceScalarField& alphaRhoPhi,
const surfaceScalarField& phi,
const transportModel& transport,
const word& propertiesName
)
{
IOdictionary modelDict
(
IOobject
(
IOobject::groupName(propertiesName, U.group()),
U.time().constant(),
U.db(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
if (modelDict.found("laminar"))
{
// get model name, but do not register the dictionary
// otherwise it is registered in the database twice
const word modelType
(
modelDict.subDict("laminar").lookup("laminarModel")
);
Info<< "Selecting laminar stress model " << modelType << endl;
typename dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown laminarModel type "
<< modelType << nl << nl
<< "Valid laminarModel types:" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<laminarModel>
(
cstrIter()
(
alpha,
rho,
U,
alphaRhoPhi,
phi,
transport, propertiesName)
);
}
else
{
Info<< "Selecting laminar stress model "
<< laminarModels::Stokes<BasicTurbulenceModel>::typeName << endl;
return autoPtr<laminarModel>
(
new laminarModels::Stokes<BasicTurbulenceModel>
(
alpha,
rho,
U,
alphaRhoPhi,
phi,
transport,
propertiesName
)
);
}
}
示例15: 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
{
//.........这里部分代码省略.........