mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
reduce synchronisation
This commit is contained in:
@ -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
|
||||||
|
|||||||
@ -197,13 +197,13 @@ void Foam::fieldMinMax::calcMinMaxFields<Foam::scalar>
|
|||||||
{
|
{
|
||||||
if (obr_.foundObject<volScalarField>(fieldName))
|
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())
|
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
|
fieldMinMaxFilePtr_() << obr_.time().value() << tab
|
||||||
<< fieldName << tab << minValue << tab << maxValue << endl;
|
<< fieldName << tab << minValue << tab << maxValue << endl;
|
||||||
|
|
||||||
|
|||||||
@ -38,16 +38,16 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
|
|||||||
|
|
||||||
if (obr_.foundObject<fieldType>(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);
|
case mdMag:
|
||||||
switch (mode_)
|
|
||||||
{
|
{
|
||||||
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
|
fieldMinMaxFilePtr_() << obr_.time().value() << tab
|
||||||
<< fieldName << tab << minValue << tab << maxValue
|
<< fieldName << tab << minValue << tab << maxValue
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -61,13 +61,16 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
|
|||||||
<< maxValue << nl
|
<< maxValue << nl
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case mdCmpt:
|
break;
|
||||||
{
|
}
|
||||||
Type minValue = min(field).value();
|
case mdCmpt:
|
||||||
Type maxValue = max(field).value();
|
{
|
||||||
|
Type minValue = min(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,17 +84,17 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
|
|||||||
<< maxValue << nl
|
<< maxValue << nl
|
||||||
<< endl;
|
<< 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_)
|
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];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,17 +73,14 @@ protected:
|
|||||||
|
|
||||||
const objectRegistry& obr_;
|
const objectRegistry& obr_;
|
||||||
|
|
||||||
//- on/off switch
|
|
||||||
bool active_;
|
|
||||||
|
|
||||||
//- Switch to send output to Info as well as to file
|
|
||||||
Switch log_;
|
|
||||||
|
|
||||||
//- Current open files
|
|
||||||
HashPtrTable<OFstream> faceZonesIntegrationFilePtr_;
|
|
||||||
|
|
||||||
// Read from dictionary
|
// Read from dictionary
|
||||||
|
|
||||||
|
//- on/off switch
|
||||||
|
bool active_;
|
||||||
|
|
||||||
|
//- Switch to send output to Info as well as to file
|
||||||
|
Switch log_;
|
||||||
|
|
||||||
//- 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
|
||||||
|
|||||||
Reference in New Issue
Block a user