diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index 0022525ad4..e27e9b0015 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C +++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C @@ -62,8 +62,8 @@ Usage -rotate-z angle Rotate (degrees) about z-axis. - or -yawPitchRoll (yawdegrees pitchdegrees rolldegrees) - or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees) + or -yawPitchRoll : (yaw pitch roll) degrees + or -rollPitchYaw : (roll pitch yaw) degrees -scale scalar|vector Scale the points by the given scalar or vector on output. @@ -268,15 +268,18 @@ int main(int argc, char *argv[]) ); argList::addBoolOption ( - "auto-origin", - "Use bounding box centre as origin for rotations" + "auto-centre", + "Use bounding box centre as centre for rotations" ); argList::addOption ( - "origin", + "centre", "point", - "Use specified as origin for rotations" + "Use specified as centre for rotations" ); + argList::addOptionCompat("auto-centre", {"auto-origin", 2206}); + argList::addOptionCompat("centre", {"origin", 2206}); + argList::addOption ( "rotate", @@ -437,18 +440,18 @@ int main(int argc, char *argv[]) points += v; } - vector origin; - bool useOrigin = args.readIfPresent("origin", origin); - if (args.found("auto-origin") && !useOrigin) + vector rotationCentre; + bool useRotationCentre = args.readIfPresent("centre", rotationCentre); + if (args.found("auto-centre") && !useRotationCentre) { - useOrigin = true; - origin = boundBox(points).centre(); + useRotationCentre = true; + rotationCentre = boundBox(points).centre(); } - if (useOrigin) + if (useRotationCentre) { - Info<< "Set origin for rotations to " << origin << endl; - points -= origin; + Info<< "Set centre of rotation to " << rotationCentre << endl; + points -= rotationCentre; } @@ -545,15 +548,15 @@ int main(int argc, char *argv[]) } } + if (useRotationCentre) + { + Info<< "Unset centre of rotation from " << rotationCentre << endl; + points += rotationCentre; + } + // Output scaling applyScaling(points, getScalingOpt("scale", args)); - if (useOrigin) - { - Info<< "Unset origin for rotations from " << origin << endl; - points += origin; - } - // Set the precision of the points data to 10 IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); diff --git a/applications/utilities/preProcessing/setTurbulenceFields/setTurbulenceFields.C b/applications/utilities/preProcessing/setTurbulenceFields/setTurbulenceFields.C index 6e69f83457..c5351daf5d 100644 --- a/applications/utilities/preProcessing/setTurbulenceFields/setTurbulenceFields.C +++ b/applications/utilities/preProcessing/setTurbulenceFields/setTurbulenceFields.C @@ -109,6 +109,7 @@ Note #include "singlePhaseTransportModel.H" #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" +#include "processorFvPatchField.H" #include "wallFvPatch.H" #include "fixedValueFvPatchFields.H" @@ -122,6 +123,40 @@ void InfoField(const word& fldName) } +template +void correctProcessorPatches +( + GeometricField& vf +) +{ + if (!Pstream::parRun()) + { + return; + } + + // Not possible to use correctBoundaryConditions on fields as they may + // use local info as opposed to the constraint values employed here, + // but still need to update processor patches + auto& bf = vf.boundaryFieldRef(); + + forAll(bf, patchi) + { + if (isA>(bf[patchi])) + { + bf[patchi].initEvaluate(); + } + } + + forAll(bf, patchi) + { + if (isA>(bf[patchi])) + { + bf[patchi].evaluate(); + } + } +} + + IOobject createIOobject ( const fvMesh& mesh, @@ -447,22 +482,26 @@ int main(int argc, char *argv[]) // (M:Eq. 9) const dimensionedScalar maxU(dimVelocity, SMALL); U *= min(scalar(1), fRei*uTau/max(mag(U), maxU)); + correctProcessorPatches(U); } if (tepsilon.valid()) { tepsilon.ref() = epsilon; + correctProcessorPatches(tepsilon.ref()); } if (tk.valid()) { tk.ref() = k; + correctProcessorPatches(tk.ref()); } if (tomega.valid()) { const dimensionedScalar k0(sqr(dimLength/dimTime), SMALL); tomega.ref() = Cmu*epsilon/(k + k0); + correctProcessorPatches(tomega.ref()); } if (tR.valid()) @@ -475,6 +514,7 @@ int main(int argc, char *argv[]) { R[celli] = Rdiag[celli]; } + correctProcessorPatches(R); } diff --git a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C index dcee32d3d4..4db518c5bf 100644 --- a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C +++ b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C @@ -188,15 +188,18 @@ int main(int argc, char *argv[]) ); argList::addBoolOption ( - "auto-origin", - "Use bounding box centre as origin for rotations" + "auto-centre", + "Use bounding box centre as centre for rotations" ); argList::addOption ( - "origin", + "centre", "point", - "Use specified as origin for rotations" + "Use specified as centre for rotations" ); + argList::addOptionCompat("auto-centre", {"auto-origin", 2206}); + argList::addOptionCompat("centre", {"origin", 2206}); + argList::addOption ( "rotate", @@ -352,18 +355,18 @@ int main(int argc, char *argv[]) points += v; } - vector origin; - bool useOrigin = args.readIfPresent("origin", origin); - if (args.found("auto-origin") && !useOrigin) + vector rotationCentre; + bool useRotationCentre = args.readIfPresent("centre", rotationCentre); + if (args.found("auto-centre") && !useRotationCentre) { - useOrigin = true; - origin = boundBox(points).centre(); + useRotationCentre = true; + rotationCentre = boundBox(points).centre(); } - if (useOrigin) + if (useRotationCentre) { - Info<< "Set origin for rotations to " << origin << endl; - points -= origin; + Info<< "Set centre of rotation to " << rotationCentre << endl; + points -= rotationCentre; } @@ -455,15 +458,15 @@ int main(int argc, char *argv[]) transform(points, rot, points); } + if (useRotationCentre) + { + Info<< "Unset centre of rotation from " << rotationCentre << endl; + points += rotationCentre; + } + // Output scaling applyScaling(points, getScalingOpt("write-scale", args)); - if (useOrigin) - { - Info<< "Unset origin for rotations from " << origin << endl; - points += origin; - } - surf1.movePoints(points); surf1.write(exportName, writeFileType); diff --git a/etc/caseDicts/postProcessing/pressure/pressureDifference.cfg b/etc/caseDicts/postProcessing/pressure/pressureDifference.cfg index ef3c1f8d7f..2548174692 100644 --- a/etc/caseDicts/postProcessing/pressure/pressureDifference.cfg +++ b/etc/caseDicts/postProcessing/pressure/pressureDifference.cfg @@ -22,12 +22,14 @@ functions #includeEtc "caseDicts/postProcessing/surfaceFieldValue/surfaceRegion.cfg" operation areaAverage; fields (p); + $region1; } region2 { #includeEtc "caseDicts/postProcessing/surfaceFieldValue/surfaceRegion.cfg" operation areaAverage; fields (p); + $region2; } } diff --git a/etc/caseDicts/postProcessing/pressure/pressureDifferencePatch.cfg b/etc/caseDicts/postProcessing/pressure/pressureDifferencePatch.cfg index 71134ca909..36c21c8729 100644 --- a/etc/caseDicts/postProcessing/pressure/pressureDifferencePatch.cfg +++ b/etc/caseDicts/postProcessing/pressure/pressureDifferencePatch.cfg @@ -6,8 +6,6 @@ \\/ M anipulation | \*---------------------------------------------------------------------------*/ -#includeEtc "caseDicts/postProcessing/pressure/pressureDifference.cfg" - region1 { regionType patch; @@ -19,4 +17,6 @@ region2 name $patch2; } +#includeEtc "caseDicts/postProcessing/pressure/pressureDifference.cfg" + // ************************************************************************* // diff --git a/etc/caseDicts/postProcessing/pressure/pressureDifferenceSurface.cfg b/etc/caseDicts/postProcessing/pressure/pressureDifferenceSurface.cfg index 873b616d1d..204715339d 100644 --- a/etc/caseDicts/postProcessing/pressure/pressureDifferenceSurface.cfg +++ b/etc/caseDicts/postProcessing/pressure/pressureDifferenceSurface.cfg @@ -6,16 +6,14 @@ \\/ M anipulation | \*---------------------------------------------------------------------------*/ -#includeEtc "caseDicts/postProcessing/pressure/pressureDifference.cfg" - region1 { - regionType sampledSurface; - + regionType sampledSurface; + name $triSurface1; sampledSurfaceDict { type meshedSurface; - regionType cells; + source cells; interpolate true; surface $triSurface1; } @@ -24,10 +22,13 @@ region1 region2 { $region1; + name $triSurface2; sampledSurfaceDict { surface $triSurface2; } } +#includeEtc "caseDicts/postProcessing/pressure/pressureDifference.cfg" + // ************************************************************************* // diff --git a/src/dynamicMesh/motionSolvers/displacement/solidBody/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunction.C b/src/dynamicMesh/motionSolvers/displacement/solidBody/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunction.C index a530af913b..04aeb65704 100644 --- a/src/dynamicMesh/motionSolvers/displacement/solidBody/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunction.C +++ b/src/dynamicMesh/motionSolvers/displacement/solidBody/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunction.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,16 +41,18 @@ namespace Foam Foam::solidBodyMotionFunction::solidBodyMotionFunction ( - const dictionary& SBMFCoeffs, + const dictionary& dict, const Time& runTime ) : SBMFCoeffs_ ( - SBMFCoeffs.optionalSubDict + dict.found("solidBodyMotionFunction") + ? dict.optionalSubDict ( - SBMFCoeffs.get("solidBodyMotionFunction") + "Coeffs" + dict.get("solidBodyMotionFunction") + "Coeffs" ) + : dict ), time_(runTime) {} @@ -57,9 +60,9 @@ Foam::solidBodyMotionFunction::solidBodyMotionFunction // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // -bool Foam::solidBodyMotionFunction::read(const dictionary& SBMFCoeffs) +bool Foam::solidBodyMotionFunction::read(const dictionary& dict) { - SBMFCoeffs_ = SBMFCoeffs.optionalSubDict(type() + "Coeffs"); + SBMFCoeffs_ = dict.optionalSubDict(type() + "Coeffs"); return true; } diff --git a/src/faOptions/sources/derived/externalHeatFluxSource/externalHeatFluxSource.C b/src/faOptions/sources/derived/externalHeatFluxSource/externalHeatFluxSource.C index c36fb0ae51..e29fa73367 100644 --- a/src/faOptions/sources/derived/externalHeatFluxSource/externalHeatFluxSource.C +++ b/src/faOptions/sources/derived/externalHeatFluxSource/externalHeatFluxSource.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -110,14 +110,14 @@ void Foam::fa::externalHeatFluxSource::addSup false ); - auto tQ = new areaScalarField + auto tQ = tmp::New ( io, regionMesh(), dimensionedScalar("q", dimPower/sqr(dimLength), 0), zeroGradientFaPatchScalarField::typeName ); - areaScalarField& Q = *tQ; + areaScalarField& Q = tQ.ref(); switch (mode_) { diff --git a/src/functionObjects/field/binField/binModels/binModel/binModel.C b/src/functionObjects/field/binField/binModels/binModel/binModel.C index cf74aa1de1..049860f116 100644 --- a/src/functionObjects/field/binField/binModels/binModel/binModel.C +++ b/src/functionObjects/field/binField/binModels/binModel/binModel.C @@ -148,6 +148,11 @@ Foam::binModel::binModel bool Foam::binModel::read(const dictionary& dict) { + if (!functionObjects::writeFile::read(dict)) + { + return false; + } + patchSet_ = mesh_.boundaryMesh().patchSet(dict.get("patches")); fieldNames_ = dict.get("fields").sortedToc(); diff --git a/src/functionObjects/field/binField/binModels/singleDirectionUniformBin/singleDirectionUniformBinTemplates.C b/src/functionObjects/field/binField/binModels/singleDirectionUniformBin/singleDirectionUniformBinTemplates.C index 5fedd25a11..ad5024263c 100644 --- a/src/functionObjects/field/binField/binModels/singleDirectionUniformBin/singleDirectionUniformBinTemplates.C +++ b/src/functionObjects/field/binField/binModels/singleDirectionUniformBin/singleDirectionUniformBinTemplates.C @@ -104,7 +104,7 @@ bool Foam::binModels::singleDirectionUniformBin::processField return false; } - if (Pstream::master() && !writtenHeader_) + if (writeToFile() && !writtenHeader_) { writeFileHeader(filePtrs_[fieldi]); } @@ -183,7 +183,12 @@ bool Foam::binModels::singleDirectionUniformBin::processField } } - if (Pstream::master()) + for (auto& binList : data) + { + reduce(binList, sumOp>()); + } + + if (writeToFile()) { writeBinnedData(data, filePtrs_[fieldi]); } diff --git a/src/functionObjects/field/binField/binModels/uniformBin/uniformBinTemplates.C b/src/functionObjects/field/binField/binModels/uniformBin/uniformBinTemplates.C index 8f7c1c103e..c9edd55a13 100644 --- a/src/functionObjects/field/binField/binModels/uniformBin/uniformBinTemplates.C +++ b/src/functionObjects/field/binField/binModels/uniformBin/uniformBinTemplates.C @@ -98,7 +98,7 @@ bool Foam::binModels::uniformBin::processField(const label fieldi) return false; } - if (Pstream::master() && !writtenHeader_) + if (writeToFile() && !writtenHeader_) { writeFileHeader(filePtrs_[fieldi]); } @@ -166,7 +166,12 @@ bool Foam::binModels::uniformBin::processField(const label fieldi) } } - if (Pstream::master()) + for (auto& binList : data) + { + reduce(binList, sumOp>()); + } + + if (writeToFile()) { writeBinnedData(data, filePtrs_[fieldi]); } diff --git a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C index f793922e4c..7dc901d3d6 100644 --- a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -171,8 +171,8 @@ void Foam::functionObjects::forceCoeffs::calcForceCoeffs() Cf_.reset ( - forceScaling.value()*coordSys.localVector(sumPatchForcesV_), forceScaling.value()*coordSys.localVector(sumPatchForcesP_), + forceScaling.value()*coordSys.localVector(sumPatchForcesV_), forceScaling.value()*coordSys.localVector(sumInternalForces_) ); }