Skip to content
Snippets Groups Projects
Commit 6059bc7c authored by mattijs's avatar mattijs
Browse files

reduce synchronisation

parent c635b44a
Branches
Tags
No related merge requests found
......@@ -7,5 +7,6 @@ wmake libso forces
wmake libso IO
wmake libso utilities
wmake libso systemCall
wmake libso zones
# ----------------------------------------------------------------- end-of-file
......@@ -197,13 +197,13 @@ void Foam::fieldMinMax::calcMinMaxFields<Foam::scalar>
{
if (obr_.foundObject<volScalarField>(fieldName))
{
const volScalarField& field =
obr_.lookupObject<volScalarField>(fieldName);
scalar minValue = min(field).value();
scalar maxValue = max(field).value();
if (Pstream::master())
{
const volScalarField& field =
obr_.lookupObject<volScalarField>(fieldName);
scalar minValue = min(field).value();
scalar maxValue = max(field).value();
fieldMinMaxFilePtr_() << obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue << endl;
......
......@@ -38,16 +38,16 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
if (obr_.foundObject<fieldType>(fieldName))
{
if (Pstream::master())
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
switch (mode_)
{
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
switch (mode_)
case mdMag:
{
case mdMag:
{
scalar minValue = min(mag(field)).value();
scalar maxValue = max(mag(field)).value();
scalar minValue = min(mag(field)).value();
scalar maxValue = max(mag(field)).value();
if (Pstream::master())
{
fieldMinMaxFilePtr_() << obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue
<< endl;
......@@ -61,13 +61,16 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
<< maxValue << nl
<< endl;
}
break;
}
case mdCmpt:
{
Type minValue = min(field).value();
Type maxValue = max(field).value();
break;
}
case mdCmpt:
{
Type minValue = min(field).value();
Type maxValue = max(field).value();
if (Pstream::master())
{
fieldMinMaxFilePtr_() << obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue
<< endl;
......@@ -81,17 +84,17 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
<< maxValue << nl
<< endl;
}
break;
}
default:
{
FatalErrorIn
(
"Foam::fieldMinMax::calcMinMaxFields"
"(const word& fieldName)"
)<< "Unknown min/max mode: " << modeTypeNames_[mode_]
<< exit(FatalError);
}
break;
}
default:
{
FatalErrorIn
(
"Foam::fieldMinMax::calcMinMaxFields"
"(const word& fieldName)"
)<< "Unknown min/max mode: " << modeTypeNames_[mode_]
<< exit(FatalError);
}
}
}
......
......@@ -191,7 +191,7 @@ void Foam::faceZonesIntegration::write()
if (active_)
{
makeFile();
scalar dm = 0.0;
forAll(fItems_, fieldI)
{
const word& fieldName = fItems_[fieldI];
......@@ -201,8 +201,30 @@ void Foam::faceZonesIntegration::write()
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;
// 2. Write only on master
if
(
Pstream::master()
......@@ -213,26 +235,14 @@ void Foam::faceZonesIntegration::write()
os << obr_.time().value();
const faceZoneMesh& faceZoneList = mesh.faceZones();
forAll(faceZonesSet_, zoneI)
forAll(integralVals, setI)
{
const word name = faceZonesSet_[zoneI];
label zoneID = faceZoneList.findZoneID(name);
const faceZone& fz = mesh.faceZones()[zoneID];
dm = calcFaceZonesIntegral(fD, fz);
reduce(dm, sumOp<scalar>());
os << ' ' << setw(w) << dm;
os << ' ' << setw(w) << integralVals[setI];
if (log_)
{
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 (fz.flipMap()[faceI])
if (fz.flipMap()[i])
{
dm -= fD[faceI];
}
......@@ -275,7 +285,7 @@ Foam::scalar Foam::faceZonesIntegration::calcFaceZonesIntegral
{
if (refCast<const processorPolyPatch>(pp).owner())
{
if (fz.flipMap()[faceI])
if (fz.flipMap()[i])
{
dm -= fD.boundaryField()[patchI][pp.whichFace(faceI)];
}
......@@ -290,7 +300,7 @@ Foam::scalar Foam::faceZonesIntegration::calcFaceZonesIntegral
label patchFaceI = faceI - pp.start();
if (patchFaceI < pp.size()/2)
{
if (fz.flipMap()[patchFaceI])
if (fz.flipMap()[i])
{
dm -= fD.boundaryField()[patchI][patchFaceI];
}
......@@ -303,7 +313,7 @@ Foam::scalar Foam::faceZonesIntegration::calcFaceZonesIntegral
else if (!isA<emptyPolyPatch>(pp))
{
label patchFaceI = faceI - pp.start();
if (fz.flipMap()[patchFaceI])
if (fz.flipMap()[i])
{
dm -= fD.boundaryField()[patchI][patchFaceI];
}
......
......@@ -73,16 +73,13 @@ protected:
const objectRegistry& obr_;
//- on/off switch
bool active_;
// Read from dictionary
//- Switch to send output to Info as well as to file
Switch log_;
//- on/off switch
bool active_;
//- Current open files
HashPtrTable<OFstream> faceZonesIntegrationFilePtr_;
// Read from dictionary
//- Switch to send output to Info as well as to file
Switch log_;
//- faceZones to integrate over
wordList faceZonesSet_;
......@@ -91,6 +88,11 @@ protected:
wordList fItems_;
//- Current open files
HashPtrTable<OFstream> faceZonesIntegrationFilePtr_;
// Private Member Functions
//- If the integration file has not been created create it
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment