mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
refactoring
This commit is contained in:
@ -57,7 +57,7 @@ Foam::faceZonesIntegration::faceZonesIntegration
|
|||||||
log_(false),
|
log_(false),
|
||||||
faceZonesSet_(),
|
faceZonesSet_(),
|
||||||
fItems_(),
|
fItems_(),
|
||||||
faceZonesIntegrationFilePtr_(NULL)
|
filePtr_(NULL)
|
||||||
{
|
{
|
||||||
// Check if the available mesh is an fvMesh otherise deactivate
|
// Check if the available mesh is an fvMesh otherise deactivate
|
||||||
if (!isA<fvMesh>(obr_))
|
if (!isA<fvMesh>(obr_))
|
||||||
@ -104,7 +104,7 @@ void Foam::faceZonesIntegration::read(const dictionary& dict)
|
|||||||
void Foam::faceZonesIntegration::makeFile()
|
void Foam::faceZonesIntegration::makeFile()
|
||||||
{
|
{
|
||||||
// Create the face Zone file if not already created
|
// Create the face Zone file if not already created
|
||||||
if (faceZonesIntegrationFilePtr_.empty())
|
if (filePtr_.empty())
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -132,7 +132,7 @@ void Foam::faceZonesIntegration::makeFile()
|
|||||||
mkDir(faceZonesIntegrationDir);
|
mkDir(faceZonesIntegrationDir);
|
||||||
|
|
||||||
// Open new file at start up
|
// Open new file at start up
|
||||||
faceZonesIntegrationFilePtr_.resize(fItems_.size());
|
filePtr_.resize(fItems_.size());
|
||||||
|
|
||||||
forAll(fItems_, Ifields)
|
forAll(fItems_, Ifields)
|
||||||
{
|
{
|
||||||
@ -143,7 +143,7 @@ void Foam::faceZonesIntegration::makeFile()
|
|||||||
faceZonesIntegrationDir/fieldName
|
faceZonesIntegrationDir/fieldName
|
||||||
);
|
);
|
||||||
|
|
||||||
faceZonesIntegrationFilePtr_.insert(fieldName, sPtr);
|
filePtr_.insert(fieldName, sPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add headers to output data
|
// Add headers to output data
|
||||||
@ -155,11 +155,11 @@ void Foam::faceZonesIntegration::makeFile()
|
|||||||
|
|
||||||
void Foam::faceZonesIntegration::writeFileHeader()
|
void Foam::faceZonesIntegration::writeFileHeader()
|
||||||
{
|
{
|
||||||
forAllIter(HashPtrTable<OFstream>, faceZonesIntegrationFilePtr_, iter)
|
forAllIter(HashPtrTable<OFstream>, filePtr_, iter)
|
||||||
{
|
{
|
||||||
unsigned int w = IOstream::defaultPrecision() + 7;
|
unsigned int w = IOstream::defaultPrecision() + 7;
|
||||||
|
|
||||||
OFstream& os = *faceZonesIntegrationFilePtr_[iter.key()];
|
OFstream& os = *filePtr_[iter.key()];
|
||||||
|
|
||||||
os << "#Time " << setw(w);
|
os << "#Time " << setw(w);
|
||||||
|
|
||||||
@ -196,10 +196,10 @@ void Foam::faceZonesIntegration::write()
|
|||||||
{
|
{
|
||||||
const word& fieldName = fItems_[fieldI];
|
const word& fieldName = fItems_[fieldI];
|
||||||
|
|
||||||
const surfaceScalarField& fD =
|
const surfaceScalarField& sField =
|
||||||
obr_.lookupObject<surfaceScalarField>(fieldName);
|
obr_.lookupObject<surfaceScalarField>(fieldName);
|
||||||
|
|
||||||
const fvMesh& mesh = fD.mesh();
|
const fvMesh& mesh = sField.mesh();
|
||||||
|
|
||||||
// 1. integrate over all face zones
|
// 1. integrate over all face zones
|
||||||
|
|
||||||
@ -211,11 +211,11 @@ void Foam::faceZonesIntegration::write()
|
|||||||
|
|
||||||
label zoneID = mesh.faceZones().findZoneID(name);
|
label zoneID = mesh.faceZones().findZoneID(name);
|
||||||
|
|
||||||
const faceZone& fz = mesh.faceZones()[zoneID];
|
const faceZone& fZone = mesh.faceZones()[zoneID];
|
||||||
|
|
||||||
integralVals[setI] = returnReduce
|
integralVals[setI] = returnReduce
|
||||||
(
|
(
|
||||||
calcFaceZonesIntegral(fD, fz),
|
calcIntegral(sField, fZone),
|
||||||
sumOp<scalar>()
|
sumOp<scalar>()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -225,13 +225,9 @@ void Foam::faceZonesIntegration::write()
|
|||||||
|
|
||||||
// 2. Write only on master
|
// 2. Write only on master
|
||||||
|
|
||||||
if
|
if (Pstream::master() && filePtr_.found(fieldName))
|
||||||
(
|
|
||||||
Pstream::master()
|
|
||||||
&& faceZonesIntegrationFilePtr_.found(fieldName)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
OFstream& os = *faceZonesIntegrationFilePtr_(fieldName);
|
OFstream& os = *filePtr_(fieldName);
|
||||||
|
|
||||||
os << obr_.time().value();
|
os << obr_.time().value();
|
||||||
|
|
||||||
@ -242,7 +238,8 @@ void Foam::faceZonesIntegration::write()
|
|||||||
if (log_)
|
if (log_)
|
||||||
{
|
{
|
||||||
Info<< "faceZonesIntegration output:" << nl
|
Info<< "faceZonesIntegration output:" << nl
|
||||||
<< " Integration" << integralVals[setI] << endl;
|
<< " Integration[" << setI << "] "
|
||||||
|
<< integralVals[setI] << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,45 +250,47 @@ void Foam::faceZonesIntegration::write()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::scalar Foam::faceZonesIntegration::calcFaceZonesIntegral
|
Foam::scalar Foam::faceZonesIntegration::calcIntegral
|
||||||
(
|
(
|
||||||
const surfaceScalarField& fD,
|
const surfaceScalarField& sField,
|
||||||
const faceZone& fz
|
const faceZone& fZone
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
scalar dm = 0.0;
|
scalar sum = 0.0;
|
||||||
const fvMesh& mesh = fD.mesh();
|
const fvMesh& mesh = sField.mesh();
|
||||||
|
|
||||||
forAll (fz, i)
|
forAll (fZone, i)
|
||||||
{
|
{
|
||||||
label faceI = fz[i];
|
label faceI = fZone[i];
|
||||||
|
|
||||||
if (mesh.isInternalFace(faceI))
|
if (mesh.isInternalFace(faceI))
|
||||||
{
|
{
|
||||||
if (fz.flipMap()[i])
|
if (fZone.flipMap()[i])
|
||||||
{
|
{
|
||||||
dm -= fD[faceI];
|
sum -= sField[faceI];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dm += fD[faceI];
|
sum += sField[faceI];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
label patchI = mesh.boundaryMesh().whichPatch(faceI);
|
label patchI = mesh.boundaryMesh().whichPatch(faceI);
|
||||||
const polyPatch& pp = mesh.boundaryMesh()[patchI];
|
const polyPatch& pp = mesh.boundaryMesh()[patchI];
|
||||||
|
const fvsPatchScalarField& bField = sField.boundaryField()[patchI];
|
||||||
if (isA<processorPolyPatch>(pp))
|
if (isA<processorPolyPatch>(pp))
|
||||||
{
|
{
|
||||||
if (refCast<const processorPolyPatch>(pp).owner())
|
if (refCast<const processorPolyPatch>(pp).owner())
|
||||||
{
|
{
|
||||||
if (fz.flipMap()[i])
|
label patchFaceI = pp.whichFace(faceI);
|
||||||
|
if (fZone.flipMap()[i])
|
||||||
{
|
{
|
||||||
dm -= fD.boundaryField()[patchI][pp.whichFace(faceI)];
|
sum -= bField[patchFaceI];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dm += fD.boundaryField()[patchI][pp.whichFace(faceI)];
|
sum += bField[patchFaceI];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,32 +299,32 @@ Foam::scalar Foam::faceZonesIntegration::calcFaceZonesIntegral
|
|||||||
label patchFaceI = faceI - pp.start();
|
label patchFaceI = faceI - pp.start();
|
||||||
if (patchFaceI < pp.size()/2)
|
if (patchFaceI < pp.size()/2)
|
||||||
{
|
{
|
||||||
if (fz.flipMap()[i])
|
if (fZone.flipMap()[i])
|
||||||
{
|
{
|
||||||
dm -= fD.boundaryField()[patchI][patchFaceI];
|
sum -= bField[patchFaceI];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dm += fD.boundaryField()[patchI][patchFaceI];
|
sum += bField[patchFaceI];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!isA<emptyPolyPatch>(pp))
|
else if (!isA<emptyPolyPatch>(pp))
|
||||||
{
|
{
|
||||||
label patchFaceI = faceI - pp.start();
|
label patchFaceI = faceI - pp.start();
|
||||||
if (fz.flipMap()[i])
|
if (fZone.flipMap()[i])
|
||||||
{
|
{
|
||||||
dm -= fD.boundaryField()[patchI][patchFaceI];
|
sum -= bField[patchFaceI];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dm += fD.boundaryField()[patchI][patchFaceI];
|
sum += bField[patchFaceI];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dm;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -65,17 +65,18 @@ class faceZonesIntegration
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Private data
|
// Protected data
|
||||||
|
|
||||||
//- Name of this set of face zone integration,
|
//- Name of this set of face zone integration,
|
||||||
// Also used as the name of the probes directory.
|
// Also used as the name of the output directory.
|
||||||
word name_;
|
word name_;
|
||||||
|
|
||||||
const objectRegistry& obr_;
|
const objectRegistry& obr_;
|
||||||
|
|
||||||
|
|
||||||
// Read from dictionary
|
// Read from dictionary
|
||||||
|
|
||||||
//- on/off switch
|
//- On/off switch
|
||||||
bool active_;
|
bool active_;
|
||||||
|
|
||||||
//- Switch to send output to Info as well as to file
|
//- Switch to send output to Info as well as to file
|
||||||
@ -89,19 +90,19 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
//- Current open files
|
//- Current open files
|
||||||
HashPtrTable<OFstream> faceZonesIntegrationFilePtr_;
|
HashPtrTable<OFstream> filePtr_;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
//- If the integration file has not been created create it
|
//- If the integration file has not been created create it
|
||||||
void makeFile();
|
void makeFile();
|
||||||
|
|
||||||
scalar calcFaceZonesIntegral
|
scalar calcIntegral
|
||||||
(
|
(
|
||||||
const surfaceScalarField& fD,
|
const surfaceScalarField& sField,
|
||||||
const faceZone& fz
|
const faceZone& fZone
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -134,8 +135,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Destructor
|
//- Destructor
|
||||||
|
|
||||||
virtual ~faceZonesIntegration();
|
virtual ~faceZonesIntegration();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user