Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Mark Olesen 2022-08-19 12:50:50 +02:00
commit 5218bfd721
12 changed files with 125 additions and 58 deletions

View File

@ -62,8 +62,8 @@ Usage
-rotate-z angle -rotate-z angle
Rotate (degrees) about z-axis. Rotate (degrees) about z-axis.
or -yawPitchRoll (yawdegrees pitchdegrees rolldegrees) or -yawPitchRoll : (yaw pitch roll) degrees
or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees) or -rollPitchYaw : (roll pitch yaw) degrees
-scale scalar|vector -scale scalar|vector
Scale the points by the given scalar or vector on output. Scale the points by the given scalar or vector on output.
@ -268,15 +268,18 @@ int main(int argc, char *argv[])
); );
argList::addBoolOption argList::addBoolOption
( (
"auto-origin", "auto-centre",
"Use bounding box centre as origin for rotations" "Use bounding box centre as centre for rotations"
); );
argList::addOption argList::addOption
( (
"origin", "centre",
"point", "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 argList::addOption
( (
"rotate", "rotate",
@ -437,18 +440,18 @@ int main(int argc, char *argv[])
points += v; points += v;
} }
vector origin; vector rotationCentre;
bool useOrigin = args.readIfPresent("origin", origin); bool useRotationCentre = args.readIfPresent("centre", rotationCentre);
if (args.found("auto-origin") && !useOrigin) if (args.found("auto-centre") && !useRotationCentre)
{ {
useOrigin = true; useRotationCentre = true;
origin = boundBox(points).centre(); rotationCentre = boundBox(points).centre();
} }
if (useOrigin) if (useRotationCentre)
{ {
Info<< "Set origin for rotations to " << origin << endl; Info<< "Set centre of rotation to " << rotationCentre << endl;
points -= origin; 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 // Output scaling
applyScaling(points, getScalingOpt("scale", args)); 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 // Set the precision of the points data to 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));

View File

@ -109,6 +109,7 @@ Note
#include "singlePhaseTransportModel.H" #include "singlePhaseTransportModel.H"
#include "turbulentTransportModel.H" #include "turbulentTransportModel.H"
#include "turbulentFluidThermoModel.H" #include "turbulentFluidThermoModel.H"
#include "processorFvPatchField.H"
#include "wallFvPatch.H" #include "wallFvPatch.H"
#include "fixedValueFvPatchFields.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 IOobject createIOobject
( (
const fvMesh& mesh, const fvMesh& mesh,
@ -447,22 +482,26 @@ int main(int argc, char *argv[])
// (M:Eq. 9) // (M:Eq. 9)
const dimensionedScalar maxU(dimVelocity, SMALL); const dimensionedScalar maxU(dimVelocity, SMALL);
U *= min(scalar(1), fRei*uTau/max(mag(U), maxU)); U *= min(scalar(1), fRei*uTau/max(mag(U), maxU));
correctProcessorPatches<vector>(U);
} }
if (tepsilon.valid()) if (tepsilon.valid())
{ {
tepsilon.ref() = epsilon; tepsilon.ref() = epsilon;
correctProcessorPatches<scalar>(tepsilon.ref());
} }
if (tk.valid()) if (tk.valid())
{ {
tk.ref() = k; tk.ref() = k;
correctProcessorPatches<scalar>(tk.ref());
} }
if (tomega.valid()) if (tomega.valid())
{ {
const dimensionedScalar k0(sqr(dimLength/dimTime), SMALL); const dimensionedScalar k0(sqr(dimLength/dimTime), SMALL);
tomega.ref() = Cmu*epsilon/(k + k0); tomega.ref() = Cmu*epsilon/(k + k0);
correctProcessorPatches<scalar>(tomega.ref());
} }
if (tR.valid()) if (tR.valid())
@ -475,6 +514,7 @@ int main(int argc, char *argv[])
{ {
R[celli] = Rdiag[celli]; R[celli] = Rdiag[celli];
} }
correctProcessorPatches<symmTensor>(R);
} }

View File

@ -188,15 +188,18 @@ int main(int argc, char *argv[])
); );
argList::addBoolOption argList::addBoolOption
( (
"auto-origin", "auto-centre",
"Use bounding box centre as origin for rotations" "Use bounding box centre as centre for rotations"
); );
argList::addOption argList::addOption
( (
"origin", "centre",
"point", "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 argList::addOption
( (
"rotate", "rotate",
@ -352,18 +355,18 @@ int main(int argc, char *argv[])
points += v; points += v;
} }
vector origin; vector rotationCentre;
bool useOrigin = args.readIfPresent("origin", origin); bool useRotationCentre = args.readIfPresent("centre", rotationCentre);
if (args.found("auto-origin") && !useOrigin) if (args.found("auto-centre") && !useRotationCentre)
{ {
useOrigin = true; useRotationCentre = true;
origin = boundBox(points).centre(); rotationCentre = boundBox(points).centre();
} }
if (useOrigin) if (useRotationCentre)
{ {
Info<< "Set origin for rotations to " << origin << endl; Info<< "Set centre of rotation to " << rotationCentre << endl;
points -= origin; points -= rotationCentre;
} }
@ -455,15 +458,15 @@ int main(int argc, char *argv[])
transform(points, rot, points); transform(points, rot, points);
} }
if (useRotationCentre)
{
Info<< "Unset centre of rotation from " << rotationCentre << endl;
points += rotationCentre;
}
// Output scaling // Output scaling
applyScaling(points, getScalingOpt("write-scale", args)); applyScaling(points, getScalingOpt("write-scale", args));
if (useOrigin)
{
Info<< "Unset origin for rotations from " << origin << endl;
points += origin;
}
surf1.movePoints(points); surf1.movePoints(points);
surf1.write(exportName, writeFileType); surf1.write(exportName, writeFileType);

View File

@ -22,12 +22,14 @@ functions
#includeEtc "caseDicts/postProcessing/surfaceFieldValue/surfaceRegion.cfg" #includeEtc "caseDicts/postProcessing/surfaceFieldValue/surfaceRegion.cfg"
operation areaAverage; operation areaAverage;
fields (p); fields (p);
$region1;
} }
region2 region2
{ {
#includeEtc "caseDicts/postProcessing/surfaceFieldValue/surfaceRegion.cfg" #includeEtc "caseDicts/postProcessing/surfaceFieldValue/surfaceRegion.cfg"
operation areaAverage; operation areaAverage;
fields (p); fields (p);
$region2;
} }
} }

View File

@ -6,8 +6,6 @@
\\/ M anipulation | \\/ M anipulation |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#includeEtc "caseDicts/postProcessing/pressure/pressureDifference.cfg"
region1 region1
{ {
regionType patch; regionType patch;
@ -19,4 +17,6 @@ region2
name $patch2; name $patch2;
} }
#includeEtc "caseDicts/postProcessing/pressure/pressureDifference.cfg"
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,16 +6,14 @@
\\/ M anipulation | \\/ M anipulation |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#includeEtc "caseDicts/postProcessing/pressure/pressureDifference.cfg"
region1 region1
{ {
regionType sampledSurface; regionType sampledSurface;
name $triSurface1;
sampledSurfaceDict sampledSurfaceDict
{ {
type meshedSurface; type meshedSurface;
regionType cells; source cells;
interpolate true; interpolate true;
surface $triSurface1; surface $triSurface1;
} }
@ -24,10 +22,13 @@ region1
region2 region2
{ {
$region1; $region1;
name $triSurface2;
sampledSurfaceDict sampledSurfaceDict
{ {
surface $triSurface2; surface $triSurface2;
} }
} }
#includeEtc "caseDicts/postProcessing/pressure/pressureDifference.cfg"
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -40,16 +41,18 @@ namespace Foam
Foam::solidBodyMotionFunction::solidBodyMotionFunction Foam::solidBodyMotionFunction::solidBodyMotionFunction
( (
const dictionary& SBMFCoeffs, const dictionary& dict,
const Time& runTime const Time& runTime
) )
: :
SBMFCoeffs_ SBMFCoeffs_
( (
SBMFCoeffs.optionalSubDict dict.found("solidBodyMotionFunction")
? dict.optionalSubDict
( (
SBMFCoeffs.get<word>("solidBodyMotionFunction") + "Coeffs" dict.get<word>("solidBodyMotionFunction") + "Coeffs"
) )
: dict
), ),
time_(runTime) time_(runTime)
{} {}
@ -57,9 +60,9 @@ Foam::solidBodyMotionFunction::solidBodyMotionFunction
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * 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; return true;
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -110,14 +110,14 @@ void Foam::fa::externalHeatFluxSource::addSup
false false
); );
auto tQ = new areaScalarField auto tQ = tmp<areaScalarField>::New
( (
io, io,
regionMesh(), regionMesh(),
dimensionedScalar("q", dimPower/sqr(dimLength), 0), dimensionedScalar("q", dimPower/sqr(dimLength), 0),
zeroGradientFaPatchScalarField::typeName zeroGradientFaPatchScalarField::typeName
); );
areaScalarField& Q = *tQ; areaScalarField& Q = tQ.ref();
switch (mode_) switch (mode_)
{ {

View File

@ -148,6 +148,11 @@ Foam::binModel::binModel
bool Foam::binModel::read(const dictionary& dict) bool Foam::binModel::read(const dictionary& dict)
{ {
if (!functionObjects::writeFile::read(dict))
{
return false;
}
patchSet_ = mesh_.boundaryMesh().patchSet(dict.get<wordRes>("patches")); patchSet_ = mesh_.boundaryMesh().patchSet(dict.get<wordRes>("patches"));
fieldNames_ = dict.get<wordHashSet>("fields").sortedToc(); fieldNames_ = dict.get<wordHashSet>("fields").sortedToc();

View File

@ -104,7 +104,7 @@ bool Foam::binModels::singleDirectionUniformBin::processField
return false; return false;
} }
if (Pstream::master() && !writtenHeader_) if (writeToFile() && !writtenHeader_)
{ {
writeFileHeader<Type>(filePtrs_[fieldi]); 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]); writeBinnedData(data, filePtrs_[fieldi]);
} }

View File

@ -98,7 +98,7 @@ bool Foam::binModels::uniformBin::processField(const label fieldi)
return false; return false;
} }
if (Pstream::master() && !writtenHeader_) if (writeToFile() && !writtenHeader_)
{ {
writeFileHeader<Type>(filePtrs_[fieldi]); 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]); writeBinnedData(data, filePtrs_[fieldi]);
} }

View File

@ -171,8 +171,8 @@ void Foam::functionObjects::forceCoeffs::calcForceCoeffs()
Cf_.reset Cf_.reset
( (
forceScaling.value()*coordSys.localVector(sumPatchForcesV_),
forceScaling.value()*coordSys.localVector(sumPatchForcesP_), forceScaling.value()*coordSys.localVector(sumPatchForcesP_),
forceScaling.value()*coordSys.localVector(sumPatchForcesV_),
forceScaling.value()*coordSys.localVector(sumInternalForces_) forceScaling.value()*coordSys.localVector(sumInternalForces_)
); );
} }