STYLE: use Ostream writeEntry when writing key/value entries

- makes for clearer code

ENH: make writeIfDifferent part of Ostream
This commit is contained in:
Mark Olesen
2017-11-06 00:49:24 +01:00
parent 0ca0a6264b
commit c0ba7bf05a
232 changed files with 854 additions and 1291 deletions

View File

@ -592,8 +592,7 @@ void Foam::cyclicACMIPolyPatch::write(Ostream& os) const
{
cyclicAMIPolyPatch::write(os);
os.writeKeyword("nonOverlapPatch") << nonOverlapPatchName_
<< token::END_STATEMENT << nl;
os.writeEntry("nonOverlapPatch", nonOverlapPatchName_);
}

View File

@ -1058,8 +1058,7 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
coupledPolyPatch::write(os);
if (!nbrPatchName_.empty())
{
os.writeKeyword("neighbourPatch") << nbrPatchName_
<< token::END_STATEMENT << nl;
os.writeEntry("neighbourPatch", nbrPatchName_);
}
coupleGroup_.write(os);
@ -1067,23 +1066,19 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
{
case ROTATIONAL:
{
os.writeKeyword("rotationAxis") << rotationAxis_
<< token::END_STATEMENT << nl;
os.writeKeyword("rotationCentre") << rotationCentre_
<< token::END_STATEMENT << nl;
os.writeEntry("rotationAxis", rotationAxis_);
os.writeEntry("rotationCentre", rotationCentre_);
if (rotationAngleDefined_)
{
os.writeKeyword("rotationAngle") << radToDeg(rotationAngle_)
<< token::END_STATEMENT << nl;
os.writeEntry("rotationAngle", radToDeg(rotationAngle_));
}
break;
}
case TRANSLATIONAL:
{
os.writeKeyword("separationVector") << separationVector_
<< token::END_STATEMENT << nl;
os.writeEntry("separationVector", separationVector_);
break;
}
case NOORDERING:
@ -1098,30 +1093,29 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
if (AMIMethod_ != AMIPatchToPatchInterpolation::imFaceAreaWeight)
{
os.writeKeyword("method")
<< AMIPatchToPatchInterpolation::interpolationMethodToWord
(
AMIMethod_
)
<< token::END_STATEMENT << nl;
os.writeEntry
(
"method",
AMIPatchToPatchInterpolation::interpolationMethodToWord
(
AMIMethod_
)
);
}
if (AMIReverse_)
{
os.writeKeyword("flipNormals") << AMIReverse_
<< token::END_STATEMENT << nl;
os.writeEntry("flipNormals", AMIReverse_);
}
if (AMILowWeightCorrection_ > 0)
{
os.writeKeyword("lowWeightCorrection") << AMILowWeightCorrection_
<< token::END_STATEMENT << nl;
os.writeEntry("lowWeightCorrection", AMILowWeightCorrection_);
}
if (!surfDict_.empty())
{
os.writeKeyword(surfDict_.dictName());
os << surfDict_;
surfDict_.writeEntry(surfDict_.dictName(), os);
}
}

View File

@ -709,25 +709,10 @@ void Foam::cyclicPeriodicAMIPolyPatch::write(Ostream& os) const
{
cyclicAMIPolyPatch::write(os);
os.writeKeyword("periodicPatch") << periodicPatchName_
<< token::END_STATEMENT << nl;
if (nTransforms_ != 0)
{
os.writeKeyword("nTransforms") << nTransforms_ <<
token::END_STATEMENT << nl;
}
if (nSectors_ != 0)
{
os.writeKeyword("nSectors") << nSectors_ <<
token::END_STATEMENT << nl;
}
if (maxIter_ != 36)
{
os.writeKeyword("maxIter") << maxIter_ << token::END_STATEMENT << nl;
}
os.writeEntry("periodicPatch", periodicPatchName_);
os.writeEntryIfDifferent<label>("nTransforms", 0, nTransforms_);
os.writeEntryIfDifferent<label>("nSectors", 0, nSectors_);
os.writeEntryIfDifferent<label>("maxIter", 36, maxIter_);
}

View File

@ -297,25 +297,23 @@ void Foam::coordinateSystem::writeDict(Ostream& os, bool subDict) const
{
if (subDict)
{
os << indent << name_ << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
os.beginBlock(name_);
}
os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
os.writeEntry("type", type());
// The note entry is optional
if (note_.size())
{
os.writeKeyword("note") << note_ << token::END_STATEMENT << nl;
// note is optional
os.writeEntry("note", note_);
}
os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl;
os.writeEntry("origin", origin_);
R_->write(os);
if (subDict)
{
os << decrIndent << indent << token::END_BLOCK << endl;
os.endBlock();
}
}

View File

@ -1432,8 +1432,7 @@ void Foam::mappedPatchBase::write(Ostream& os) const
if (!surfDict_.empty())
{
os.writeKeyword(surfDict_.dictName());
os << surfDict_;
surfDict_.writeEntry(surfDict_.dictName(), os);
}
}
}

View File

@ -167,7 +167,7 @@ Foam::mappedVariableThicknessWallPolyPatch::
void Foam::mappedVariableThicknessWallPolyPatch::
write(Foam::Ostream& os) const
{
os.writeKeyword("thickness") << thickness_ << token::END_STATEMENT << nl;
os.writeEntry("thickness", thickness_);
}

View File

@ -331,21 +331,17 @@ bool Foam::regionCoupledBase::order
void Foam::regionCoupledBase::write(Ostream& os) const
{
os.writeKeyword("neighbourPatch") << nbrPatchName_
<< token::END_STATEMENT << nl;
os.writeKeyword("neighbourRegion") << nbrRegionName_
<< token::END_STATEMENT << nl;
os.writeEntry("neighbourPatch", nbrPatchName_);
os.writeEntry("neighbourRegion", nbrRegionName_);
if (AMIReverse_)
{
os.writeKeyword("flipNormals") << AMIReverse_
<< token::END_STATEMENT << nl;
os.writeEntry("flipNormals", AMIReverse_);
}
if (!surfDict_.empty())
{
os.writeKeyword(surfDict_.dictName());
os << surfDict_;
surfDict_.writeEntry(surfDict_.dictName(), os);
}
}