diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index 0022525ad45819e137ed86a2a8fe8576b3f691d4..e27e9b001547a1ab2705aae9ea0866256fb11c31 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 <point> as origin for rotations" + "Use specified <point> 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[]) } } - // Output scaling - applyScaling(points, getScalingOpt("scale", args)); - - if (useOrigin) + if (useRotationCentre) { - Info<< "Unset origin for rotations from " << origin << endl; - points += origin; + Info<< "Unset centre of rotation from " << rotationCentre << endl; + points += rotationCentre; } + // Output scaling + applyScaling(points, getScalingOpt("scale", args)); + // 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 6e69f834575542202da17b04904f678ab4687178..c5351daf5d9c54eeb428ff79add2da570a849146 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<class Type> +void correctProcessorPatches +( + GeometricField<Type, fvPatchField, volMesh>& 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<processorFvPatchField<Type>>(bf[patchi])) + { + bf[patchi].initEvaluate(); + } + } + + forAll(bf, patchi) + { + if (isA<processorFvPatchField<Type>>(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<vector>(U); } if (tepsilon.valid()) { tepsilon.ref() = epsilon; + correctProcessorPatches<scalar>(tepsilon.ref()); } if (tk.valid()) { tk.ref() = k; + correctProcessorPatches<scalar>(tk.ref()); } if (tomega.valid()) { const dimensionedScalar k0(sqr(dimLength/dimTime), SMALL); tomega.ref() = Cmu*epsilon/(k + k0); + correctProcessorPatches<scalar>(tomega.ref()); } if (tR.valid()) @@ -475,6 +514,7 @@ int main(int argc, char *argv[]) { R[celli] = Rdiag[celli]; } + correctProcessorPatches<symmTensor>(R); } diff --git a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C index dcee32d3d417b637ff298b19155428253505743d..4db518c5bfee3c4fe1e71abd9c630ac2d0b67836 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 <point> as origin for rotations" + "Use specified <point> 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); } - // Output scaling - applyScaling(points, getScalingOpt("write-scale", args)); - - if (useOrigin) + if (useRotationCentre) { - Info<< "Unset origin for rotations from " << origin << endl; - points += origin; + Info<< "Unset centre of rotation from " << rotationCentre << endl; + points += rotationCentre; } + // Output scaling + applyScaling(points, getScalingOpt("write-scale", args)); + surf1.movePoints(points); surf1.write(exportName, writeFileType); diff --git a/etc/caseDicts/postProcessing/pressure/pressureDifference.cfg b/etc/caseDicts/postProcessing/pressure/pressureDifference.cfg index ef3c1f8d7f0b40d60c0c0efe21ea9ecc73a60efa..2548174692ee6d25d3b01a6136f1707ebdd90d11 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 71134ca909b23c276f88abc68687b57360bc5979..36c21c87299e7d8b523d1f13eb0d4f3b5e8494c0 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 873b616d1d897e7fd0b3b4445093660598322f57..204715339dfdab188d095d90634540606ff70293 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 a530af913b26eb07090b936292e03e04b619017a..04aeb65704cf961e63d88caed00c2b944806eb13 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<word>("solidBodyMotionFunction") + "Coeffs" + dict.get<word>("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 c36fb0ae518c93fbb3c3f62fdba28b3de13b4a78..e29fa7336744f603c6086ab3bf5b48e044993ad7 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<areaScalarField>::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 cf74aa1de167b8b0b4a61896bfc65d87a50601aa..049860f116a45ca6d0731aa98f1c43d18f625327 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<wordRes>("patches")); fieldNames_ = dict.get<wordHashSet>("fields").sortedToc(); diff --git a/src/functionObjects/field/binField/binModels/singleDirectionUniformBin/singleDirectionUniformBinTemplates.C b/src/functionObjects/field/binField/binModels/singleDirectionUniformBin/singleDirectionUniformBinTemplates.C index 5fedd25a11483a38da197ee0f3afecd3c8920000..ad5024263c7abf88f10e02072d8ca7e26787d089 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<Type>(filePtrs_[fieldi]); } @@ -183,7 +183,12 @@ bool Foam::binModels::singleDirectionUniformBin::processField } } - if (Pstream::master()) + for (auto& binList : data) + { + reduce(binList, sumOp<List<Type>>()); + } + + 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 8f7c1c103e180ba82ab9ae198343a0b982f27d57..c9edd55a137162bb464e7bd0b4f68f3425b11483 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<Type>(filePtrs_[fieldi]); } @@ -166,7 +166,12 @@ bool Foam::binModels::uniformBin::processField(const label fieldi) } } - if (Pstream::master()) + for (auto& binList : data) + { + reduce(binList, sumOp<List<Type>>()); + } + + if (writeToFile()) { writeBinnedData(data, filePtrs_[fieldi]); } diff --git a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C index f793922e4c9b99e4ae3f2458e61bcbbfcf45fddf..7dc901d3d6a82a7921f896f231f44c8f9fbf582e 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_) ); }