ENH: fluxSummary function object - added faceZone area output on construction

This commit is contained in:
Andrew Heather
2015-12-01 15:34:25 +00:00
parent 7fe531bde5
commit bd737621a0

View File

@ -677,120 +677,138 @@ Foam::fluxSummary::~fluxSummary()
void Foam::fluxSummary::read(const dictionary& dict) void Foam::fluxSummary::read(const dictionary& dict)
{ {
if (active_) if (!active_)
{ {
functionObjectFile::read(dict); return;
}
log_ = dict.lookupOrDefault<Switch>("log", true); functionObjectFile::read(dict);
mode_ = modeTypeNames_.read(dict.lookup("mode")); log_ = dict.lookupOrDefault<Switch>("log", true);
phiName_= dict.lookupOrDefault<word>("phiName", "phi");
dict.readIfPresent("scaleFactor", scaleFactor_);
dict.readIfPresent("tolerance", tolerance_);
// initialise with capacity of 10 faceZones mode_ = modeTypeNames_.read(dict.lookup("mode"));
DynamicList<vector> refDir(10); phiName_= dict.lookupOrDefault<word>("phiName", "phi");
DynamicList<word> faceZoneName(refDir.size()); dict.readIfPresent("scaleFactor", scaleFactor_);
DynamicList<List<label> > faceID(refDir.size()); dict.readIfPresent("tolerance", tolerance_);
DynamicList<List<label> > facePatchID(refDir.size());
DynamicList<List<scalar> > faceSign(refDir.size());
switch (mode_) // initialise with capacity of 10 faceZones
DynamicList<vector> refDir(10);
DynamicList<word> faceZoneName(refDir.size());
DynamicList<List<label> > faceID(refDir.size());
DynamicList<List<label> > facePatchID(refDir.size());
DynamicList<List<scalar> > faceSign(refDir.size());
switch (mode_)
{
case mdFaceZone:
{ {
case mdFaceZone: List<word> zones(dict.lookup("faceZones"));
{
List<word> zones(dict.lookup("faceZones"));
forAll(zones, i) forAll(zones, i)
{
initialiseFaceZone
(
zones[i],
faceZoneName,
faceID,
facePatchID,
faceSign
);
}
break;
}
case mdFaceZoneAndDirection:
{ {
List<Tuple2<word, vector> > initialiseFaceZone
zoneAndDirection(dict.lookup("faceZoneAndDirection"));
forAll(zoneAndDirection, i)
{
initialiseFaceZoneAndDirection
(
zoneAndDirection[i].first(),
zoneAndDirection[i].second(),
refDir,
faceZoneName,
faceID,
facePatchID,
faceSign
);
}
break;
}
case mdCellZoneAndDirection:
{
List<Tuple2<word, vector> >
zoneAndDirection(dict.lookup("cellZoneAndDirection"));
forAll(zoneAndDirection, i)
{
initialiseCellZoneAndDirection
(
zoneAndDirection[i].first(),
zoneAndDirection[i].second(),
refDir,
faceZoneName,
faceID,
facePatchID,
faceSign
);
}
break;
}
default:
{
FatalIOErrorIn
( (
"void Foam::fluxSummary::read(const dictionary&)", zones[i],
dict faceZoneName,
) faceID,
<< "unhandled enumeration " << modeTypeNames_[mode_] facePatchID,
<< abort(FatalIOError); faceSign
}
}
faceZoneName_.transfer(faceZoneName);
refDir_.transfer(refDir);
faceID_.transfer(faceID);
facePatchID_.transfer(facePatchID);
faceSign_.transfer(faceSign);
initialiseFaceArea();
if (writeToFile())
{
filePtrs_.setSize(faceZoneName_.size());
forAll(filePtrs_, fileI)
{
const word& fzName = faceZoneName_[fileI];
filePtrs_.set(fileI, createFile(fzName));
writeFileHeader
(
fzName,
faceArea_[fileI],
refDir_[fileI],
filePtrs_[fileI]
); );
} }
break;
} }
case mdFaceZoneAndDirection:
{
List<Tuple2<word, vector> >
zoneAndDirection(dict.lookup("faceZoneAndDirection"));
forAll(zoneAndDirection, i)
{
initialiseFaceZoneAndDirection
(
zoneAndDirection[i].first(),
zoneAndDirection[i].second(),
refDir,
faceZoneName,
faceID,
facePatchID,
faceSign
);
}
break;
}
case mdCellZoneAndDirection:
{
List<Tuple2<word, vector> >
zoneAndDirection(dict.lookup("cellZoneAndDirection"));
forAll(zoneAndDirection, i)
{
initialiseCellZoneAndDirection
(
zoneAndDirection[i].first(),
zoneAndDirection[i].second(),
refDir,
faceZoneName,
faceID,
facePatchID,
faceSign
);
}
break;
}
default:
{
FatalIOErrorIn
(
"void Foam::fluxSummary::read(const dictionary&)",
dict
)
<< "unhandled enumeration " << modeTypeNames_[mode_]
<< abort(FatalIOError);
}
}
faceZoneName_.transfer(faceZoneName);
refDir_.transfer(refDir);
faceID_.transfer(faceID);
facePatchID_.transfer(facePatchID);
faceSign_.transfer(faceSign);
initialiseFaceArea();
if (writeToFile())
{
filePtrs_.setSize(faceZoneName_.size());
forAll(filePtrs_, fileI)
{
const word& fzName = faceZoneName_[fileI];
filePtrs_.set(fileI, createFile(fzName));
writeFileHeader
(
fzName,
faceArea_[fileI],
refDir_[fileI],
filePtrs_[fileI]
);
}
}
// Provide some output
if (log_)
{
Info<< type() << " " << name_ << " output:" << nl;
forAll(faceZoneName_, zoneI)
{
const word& zoneName = faceZoneName_[zoneI];
scalar zoneArea = faceArea_[zoneI];
Info<< " Zone: " << zoneName << ", area: " << zoneArea << nl;
}
Info<< endl;
} }
} }