reduce synchronisation

This commit is contained in:
mattijs
2009-08-10 11:39:51 +01:00
parent c635b44ae5
commit 6059bc7cc1
5 changed files with 72 additions and 56 deletions

View File

@ -7,5 +7,6 @@ wmake libso forces
wmake libso IO wmake libso IO
wmake libso utilities wmake libso utilities
wmake libso systemCall wmake libso systemCall
wmake libso zones
# ----------------------------------------------------------------- end-of-file # ----------------------------------------------------------------- end-of-file

View File

@ -196,14 +196,14 @@ void Foam::fieldMinMax::calcMinMaxFields<Foam::scalar>
) )
{ {
if (obr_.foundObject<volScalarField>(fieldName)) if (obr_.foundObject<volScalarField>(fieldName))
{
if (Pstream::master())
{ {
const volScalarField& field = const volScalarField& field =
obr_.lookupObject<volScalarField>(fieldName); obr_.lookupObject<volScalarField>(fieldName);
scalar minValue = min(field).value(); scalar minValue = min(field).value();
scalar maxValue = max(field).value(); scalar maxValue = max(field).value();
if (Pstream::master())
{
fieldMinMaxFilePtr_() << obr_.time().value() << tab fieldMinMaxFilePtr_() << obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue << endl; << fieldName << tab << minValue << tab << maxValue << endl;

View File

@ -37,8 +37,6 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
if (obr_.foundObject<fieldType>(fieldName)) if (obr_.foundObject<fieldType>(fieldName))
{
if (Pstream::master())
{ {
const fieldType& field = obr_.lookupObject<fieldType>(fieldName); const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
switch (mode_) switch (mode_)
@ -48,6 +46,8 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
scalar minValue = min(mag(field)).value(); scalar minValue = min(mag(field)).value();
scalar maxValue = max(mag(field)).value(); scalar maxValue = max(mag(field)).value();
if (Pstream::master())
{
fieldMinMaxFilePtr_() << obr_.time().value() << tab fieldMinMaxFilePtr_() << obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue << fieldName << tab << minValue << tab << maxValue
<< endl; << endl;
@ -61,6 +61,7 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
<< maxValue << nl << maxValue << nl
<< endl; << endl;
} }
}
break; break;
} }
case mdCmpt: case mdCmpt:
@ -68,6 +69,8 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
Type minValue = min(field).value(); Type minValue = min(field).value();
Type maxValue = max(field).value(); Type maxValue = max(field).value();
if (Pstream::master())
{
fieldMinMaxFilePtr_() << obr_.time().value() << tab fieldMinMaxFilePtr_() << obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue << fieldName << tab << minValue << tab << maxValue
<< endl; << endl;
@ -81,6 +84,7 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
<< maxValue << nl << maxValue << nl
<< endl; << endl;
} }
}
break; break;
} }
default: default:
@ -95,7 +99,6 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -191,7 +191,7 @@ void Foam::faceZonesIntegration::write()
if (active_) if (active_)
{ {
makeFile(); makeFile();
scalar dm = 0.0;
forAll(fItems_, fieldI) forAll(fItems_, fieldI)
{ {
const word& fieldName = fItems_[fieldI]; const word& fieldName = fItems_[fieldI];
@ -201,8 +201,30 @@ void Foam::faceZonesIntegration::write()
const fvMesh& mesh = fD.mesh(); const fvMesh& mesh = fD.mesh();
// 1. integrate over all face zones
scalarField integralVals(faceZonesSet_.size());
forAll(faceZonesSet_, setI)
{
const word name = faceZonesSet_[setI];
label zoneID = mesh.faceZones().findZoneID(name);
const faceZone& fz = mesh.faceZones()[zoneID];
integralVals[setI] = returnReduce
(
calcFaceZonesIntegral(fD, fz),
sumOp<scalar>()
);
}
unsigned int w = IOstream::defaultPrecision() + 7; unsigned int w = IOstream::defaultPrecision() + 7;
// 2. Write only on master
if if
( (
Pstream::master() Pstream::master()
@ -213,26 +235,14 @@ void Foam::faceZonesIntegration::write()
os << obr_.time().value(); os << obr_.time().value();
const faceZoneMesh& faceZoneList = mesh.faceZones(); forAll(integralVals, setI)
forAll(faceZonesSet_, zoneI)
{ {
const word name = faceZonesSet_[zoneI]; os << ' ' << setw(w) << integralVals[setI];
label zoneID = faceZoneList.findZoneID(name);
const faceZone& fz = mesh.faceZones()[zoneID];
dm = calcFaceZonesIntegral(fD, fz);
reduce(dm, sumOp<scalar>());
os << ' ' << setw(w) << dm;
if (log_) if (log_)
{ {
Info<< "faceZonesIntegration output:" << nl Info<< "faceZonesIntegration output:" << nl
<< " Integration" << dm << endl; << " Integration" << integralVals[setI] << endl;
} }
} }
@ -258,7 +268,7 @@ Foam::scalar Foam::faceZonesIntegration::calcFaceZonesIntegral
if (mesh.isInternalFace(faceI)) if (mesh.isInternalFace(faceI))
{ {
if (fz.flipMap()[faceI]) if (fz.flipMap()[i])
{ {
dm -= fD[faceI]; dm -= fD[faceI];
} }
@ -275,7 +285,7 @@ Foam::scalar Foam::faceZonesIntegration::calcFaceZonesIntegral
{ {
if (refCast<const processorPolyPatch>(pp).owner()) if (refCast<const processorPolyPatch>(pp).owner())
{ {
if (fz.flipMap()[faceI]) if (fz.flipMap()[i])
{ {
dm -= fD.boundaryField()[patchI][pp.whichFace(faceI)]; dm -= fD.boundaryField()[patchI][pp.whichFace(faceI)];
} }
@ -290,7 +300,7 @@ 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()[patchFaceI]) if (fz.flipMap()[i])
{ {
dm -= fD.boundaryField()[patchI][patchFaceI]; dm -= fD.boundaryField()[patchI][patchFaceI];
} }
@ -303,7 +313,7 @@ Foam::scalar Foam::faceZonesIntegration::calcFaceZonesIntegral
else if (!isA<emptyPolyPatch>(pp)) else if (!isA<emptyPolyPatch>(pp))
{ {
label patchFaceI = faceI - pp.start(); label patchFaceI = faceI - pp.start();
if (fz.flipMap()[patchFaceI]) if (fz.flipMap()[i])
{ {
dm -= fD.boundaryField()[patchI][patchFaceI]; dm -= fD.boundaryField()[patchI][patchFaceI];
} }

View File

@ -73,17 +73,14 @@ protected:
const objectRegistry& obr_; const objectRegistry& obr_;
// 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
Switch log_; Switch log_;
//- Current open files
HashPtrTable<OFstream> faceZonesIntegrationFilePtr_;
// Read from dictionary
//- faceZones to integrate over //- faceZones to integrate over
wordList faceZonesSet_; wordList faceZonesSet_;
@ -91,6 +88,11 @@ protected:
wordList fItems_; wordList fItems_;
//- Current open files
HashPtrTable<OFstream> faceZonesIntegrationFilePtr_;
// Private Member Functions // Private Member Functions
//- If the integration file has not been created create it //- If the integration file has not been created create it