mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: use weighted average/sum in a few places
- minor adjustments to some BCs construction: * ensure origin/axis are zero-initialized * use dictionary get<> instead of lookup
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -679,7 +679,7 @@ void Foam::radiation::laserDTRM::calculate()
|
||||
}
|
||||
}
|
||||
|
||||
scalar totalQ = gSum(Q_.primitiveFieldRef()*mesh_.V());
|
||||
scalar totalQ = gWeightedSum(mesh_.V(), Q_.primitiveField());
|
||||
Info << "Total energy absorbed [W]: " << totalQ << endl;
|
||||
|
||||
if (mesh_.time().writeTime())
|
||||
|
||||
@ -79,7 +79,7 @@ cylindricalInletVelocityFvPatchVectorField
|
||||
:
|
||||
fixedValueFvPatchField<vector>(p, iF, dict),
|
||||
origin_(dict.getCompat<vector>("origin", {{"centre", 1712}})),
|
||||
axis_(dict.lookup("axis")),
|
||||
axis_(dict.get<vector>("axis")),
|
||||
axialVelocity_(Function1<scalar>::New("axialVelocity", dict, &db())),
|
||||
radialVelocity_
|
||||
(
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -109,8 +109,7 @@ void Foam::fixedMeanFvPatchField<Type>::updateCoeffs()
|
||||
Field<Type> newValues(this->patchInternalField());
|
||||
|
||||
Type meanValuePsi =
|
||||
gSum(this->patch().magSf()*newValues)
|
||||
/gSum(this->patch().magSf());
|
||||
gWeightedAverage(this->patch().magSf(), newValues);
|
||||
|
||||
if (mag(meanValue) > SMALL && mag(meanValuePsi) > 0.5*mag(meanValue))
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -117,9 +117,7 @@ void Foam::fixedMeanOutletInletFvPatchField<Type>::updateCoeffs()
|
||||
|
||||
Field<Type> newValues(this->patchInternalField());
|
||||
|
||||
Type meanValuePsi =
|
||||
gSum(this->patch().magSf()*newValues)
|
||||
/gSum(this->patch().magSf());
|
||||
Type meanValuePsi = gWeightedAverage(this->patch().magSf(), newValues);
|
||||
|
||||
if (mag(meanValue) > SMALL && mag(meanValuePsi) > 0.5*mag(meanValue))
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -285,7 +285,7 @@ Foam::PatchFunction1Types::Sampled<Type>::value
|
||||
(
|
||||
mag(this->mappedPatchBase::patch_.faceAreas())
|
||||
);
|
||||
averagePsi = gSum(magSf*newValues)/gSum(magSf);
|
||||
averagePsi = gWeightedAverage(magSf, newValues);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -788,8 +788,7 @@ Foam::mappedPatchFieldBase<Type>::mappedField
|
||||
if (setAverage_)
|
||||
{
|
||||
Type averagePsi =
|
||||
gSum(patchField_.patch().magSf()*newValues)
|
||||
/gSum(patchField_.patch().magSf());
|
||||
gWeightedAverage(patchField_.patch().magSf(), newValues);
|
||||
|
||||
if (mag(averagePsi) > 0.5*mag(average_))
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -369,7 +369,7 @@ void Foam::outletMappedUniformInletFvPatchField<Type>::updateCoeffs()
|
||||
|
||||
mapField.append
|
||||
(
|
||||
gSum(outlet.magSf()*outletFld)/gSum(outlet.magSf())
|
||||
gWeightedAverage(outlet.magSf(), outletFld)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,8 +130,8 @@ void Foam::outletPhaseMeanVelocityFvPatchVectorField::updateCoeffs()
|
||||
patch().lookupPatchField<volScalarField>(alphaName_)
|
||||
);
|
||||
|
||||
alphap = max(alphap, scalar(0));
|
||||
alphap = min(alphap, scalar(1));
|
||||
// Clamp to 0-1 range
|
||||
alphap.clamp_range(Foam::zero_one{});
|
||||
|
||||
// Get the patchInternalField (zero-gradient field)
|
||||
vectorField Uzg(patchInternalField());
|
||||
|
||||
@ -211,7 +211,7 @@ void Foam::plenumPressureFvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
if (hasRho_)
|
||||
{
|
||||
massFlowRate = - gSum(rho_*phi);
|
||||
massFlowRate = - rho_*gSum(phi);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -243,7 +243,7 @@ void Foam::pressurePIDControlInletVelocityFvPatchVectorField::updateCoeffs()
|
||||
{
|
||||
const auto& rhop = patch().lookupPatchField<volScalarField>(rhoName_);
|
||||
|
||||
rho = gSum(rhop*patch().magSf())/gSum(patch().magSf());
|
||||
rho = gWeightedAverage(patch().magSf(), rhop);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -41,7 +41,7 @@ rotatingWallVelocityFvPatchVectorField
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(p, iF),
|
||||
origin_(),
|
||||
origin_(Zero),
|
||||
axis_(Zero),
|
||||
omega_(nullptr)
|
||||
{}
|
||||
@ -56,8 +56,8 @@ rotatingWallVelocityFvPatchVectorField
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(p, iF, dict, IOobjectOption::NO_READ),
|
||||
origin_(dict.lookup("origin")),
|
||||
axis_(dict.lookup("axis")),
|
||||
origin_(dict.get<vector>("origin")),
|
||||
axis_(dict.get<vector>("axis")),
|
||||
omega_(Function1<scalar>::New("omega", dict, &db()))
|
||||
{
|
||||
if (!this->readValueEntry(dict))
|
||||
|
||||
@ -57,8 +57,7 @@ void Foam::swirlFanVelocityFvPatchField::calcFanJump()
|
||||
deltaP /= patch().lookupPatchField<volScalarField>(rhoName_);
|
||||
}
|
||||
|
||||
const vector axisHat =
|
||||
gSum(patch().nf()*patch().magSf())/gSum(patch().magSf());
|
||||
const vector axisHat = gSum(patch().Sf())/gSum(patch().magSf());
|
||||
|
||||
vectorField tanDir
|
||||
(
|
||||
@ -131,7 +130,7 @@ Foam::swirlFanVelocityFvPatchField::swirlFanVelocityFvPatchField
|
||||
phiName_("phi"),
|
||||
pName_("p"),
|
||||
rhoName_("rho"),
|
||||
origin_(),
|
||||
origin_(Zero),
|
||||
rpm_(nullptr),
|
||||
fanEff_(1),
|
||||
rEff_(0),
|
||||
@ -158,7 +157,7 @@ Foam::swirlFanVelocityFvPatchField::swirlFanVelocityFvPatchField
|
||||
(
|
||||
"origin",
|
||||
returnReduceOr(patch().size())
|
||||
? gSum(patch().Cf()*patch().magSf())/gSum(patch().magSf())
|
||||
? gWeightedAverage(patch().magSf(), patch().Cf())
|
||||
: Zero
|
||||
)
|
||||
),
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -45,7 +45,7 @@ swirlFlowRateInletVelocityFvPatchVectorField
|
||||
fixedValueFvPatchField<vector>(p, iF),
|
||||
phiName_("phi"),
|
||||
rhoName_("rho"),
|
||||
origin_(),
|
||||
origin_(Zero),
|
||||
axis_(Zero),
|
||||
flowRate_(),
|
||||
rpm_()
|
||||
@ -69,7 +69,7 @@ swirlFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
"origin",
|
||||
returnReduceOr(patch().size())
|
||||
? gSum(patch().Cf()*patch().magSf())/gSum(patch().magSf())
|
||||
? gWeightedAverage(patch().magSf(), patch().Cf())
|
||||
: Zero
|
||||
)
|
||||
),
|
||||
|
||||
@ -74,8 +74,8 @@ swirlInletVelocityFvPatchVectorField
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(p, iF, dict),
|
||||
origin_(dict.lookup("origin")),
|
||||
axis_(dict.lookup("axis")),
|
||||
origin_(dict.get<vector>("origin")),
|
||||
axis_(dict.get<vector>("axis")),
|
||||
axialVelocity_(Function1<scalar>::New("axialVelocity", dict, &db())),
|
||||
radialVelocity_
|
||||
(
|
||||
|
||||
@ -895,8 +895,7 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::updateCoeffs()
|
||||
// (PCR:p. 522)
|
||||
const vector UBulk
|
||||
(
|
||||
gSum(UMean()*patch().magSf())
|
||||
/(gSum(patch().magSf()) + ROOTVSMALL)
|
||||
gWeightedAverage(patch().magSf(), UMean())
|
||||
);
|
||||
|
||||
// Move eddies using bulk velocity
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -174,11 +174,7 @@ void Foam::turbulentDigitalFilterInletFvPatchField<Type>::mapMean
|
||||
const vectorField& mean = tmean.cref();
|
||||
|
||||
// Calculate flow-rate correction factor for vector fields (KCX:Eq. 8)
|
||||
const vector bulk
|
||||
(
|
||||
gSum(mean*this->patch().magSf())
|
||||
/(gSum(this->patch().magSf()) + ROOTVSMALL)
|
||||
);
|
||||
const vector bulk = gWeightedAverage(this->patch().magSf(), mean);
|
||||
|
||||
const scalar correct
|
||||
(
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -125,14 +125,14 @@ void Foam::variableHeightFlowRateInletVelocityFvPatchVectorField::updateCoeffs()
|
||||
|
||||
scalarField alphap(alpha.boundaryField()[patch().index()]);
|
||||
|
||||
alphap = max(alphap, scalar(0));
|
||||
alphap = min(alphap, scalar(1));
|
||||
// Clamp to 0-1 range
|
||||
alphap.clamp_range(Foam::zero_one{});
|
||||
|
||||
const scalar t = db().time().timeOutputValue();
|
||||
scalar flowRate = flowRate_->value(t);
|
||||
|
||||
// a simpler way of doing this would be nice
|
||||
scalar avgU = -flowRate/gSum(patch().magSf()*alphap);
|
||||
const scalar avgU = -flowRate/gWeightedSum(patch().magSf(), alphap);
|
||||
|
||||
vectorField n(patch().nf());
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -110,23 +110,18 @@ bool Foam::functionObjects::DESModelRegions::execute()
|
||||
{
|
||||
Log << type() << " " << name() << " execute:" << nl;
|
||||
|
||||
volScalarField& DESModelRegions =
|
||||
lookupObjectRef<volScalarField>(resultName_);
|
||||
auto& regions = lookupObjectRef<volScalarField>(resultName_);
|
||||
|
||||
|
||||
if (foundObject<DESModelBase>(turbulenceModel::propertiesName))
|
||||
if
|
||||
(
|
||||
const auto* modelp
|
||||
= cfindObject<DESModelBase>(turbulenceModel::propertiesName)
|
||||
)
|
||||
{
|
||||
const DESModelBase& model =
|
||||
lookupObject<DESModelBase>
|
||||
(
|
||||
turbulenceModel::propertiesName
|
||||
);
|
||||
|
||||
DESModelRegions == model.LESRegion();
|
||||
regions == (*modelp).LESRegion();
|
||||
|
||||
const scalar prc =
|
||||
gSum(DESModelRegions.primitiveField()*mesh_.V())
|
||||
/gSum(mesh_.V())*100.0;
|
||||
gWeightedAverage(mesh_.V(), regions.primitiveField())*100.0;
|
||||
|
||||
file() << time_.value()
|
||||
<< token::TAB << prc
|
||||
@ -149,14 +144,13 @@ bool Foam::functionObjects::DESModelRegions::execute()
|
||||
|
||||
bool Foam::functionObjects::DESModelRegions::write()
|
||||
{
|
||||
const volScalarField& DESModelRegions =
|
||||
lookupObject<volScalarField>(resultName_);
|
||||
const auto& regions = lookupObject<volScalarField>(resultName_);
|
||||
|
||||
Log << type() << " " << name() << " output:" << nl
|
||||
<< " writing field " << DESModelRegions.name() << nl
|
||||
<< " writing field " << regions.name() << nl
|
||||
<< endl;
|
||||
|
||||
DESModelRegions.write();
|
||||
regions.write();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenFOAM Foundation
|
||||
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -89,12 +89,15 @@ Foam::dimensionedScalar Foam::functionObjects::comfort::Trad() const
|
||||
|
||||
if (isType<wallFvPatch>(pTBf))
|
||||
{
|
||||
areaIntegral += gSum(pSf);
|
||||
TareaIntegral += gSum(pSf*pT);
|
||||
areaIntegral += sum(pSf);
|
||||
TareaIntegral += weightedSum(pSf, pT);
|
||||
}
|
||||
}
|
||||
|
||||
Trad.value() = TareaIntegral/areaIntegral;
|
||||
reduce(TareaIntegral, sumOp<scalar>());
|
||||
reduce(areaIntegral, sumOp<scalar>());
|
||||
|
||||
Trad.value() = TareaIntegral/(areaIntegral + VSMALL);
|
||||
}
|
||||
|
||||
// Bounds based on EN ISO 7730
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -272,7 +272,7 @@ bool Foam::functionObjects::wallHeatFlux::execute()
|
||||
const scalarField& hfp = wallHeatFlux.boundaryField()[patchi];
|
||||
|
||||
const MinMax<scalar> limits = gMinMax(hfp);
|
||||
const scalar integralHfp = gSum(magSf[patchi]*hfp);
|
||||
const scalar integralHfp = gWeightedSum(magSf[patchi], hfp);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
|
||||
@ -64,8 +64,8 @@ angularOscillatingDisplacementPointPatchVectorField
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(p, iF, dict),
|
||||
axis_(dict.lookup("axis")),
|
||||
origin_(dict.lookup("origin")),
|
||||
axis_(dict.get<vector>("axis")),
|
||||
origin_(dict.get<vector>("origin")),
|
||||
angle0_(dict.get<scalar>("angle0")),
|
||||
amplitude_(dict.get<scalar>("amplitude")),
|
||||
omega_(dict.get<scalar>("omega"))
|
||||
|
||||
@ -64,8 +64,8 @@ angularOscillatingVelocityPointPatchVectorField
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(p, iF, dict),
|
||||
axis_(dict.lookup("axis")),
|
||||
origin_(dict.lookup("origin")),
|
||||
axis_(dict.get<vector>("axis")),
|
||||
origin_(dict.get<vector>("origin")),
|
||||
angle0_(dict.get<scalar>("angle0")),
|
||||
amplitude_(dict.get<scalar>("amplitude")),
|
||||
omega_(dict.get<scalar>("omega"))
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -337,7 +337,7 @@ void Foam::fv::directionalPressureGradientExplicitSource::correct
|
||||
);
|
||||
const scalarField rho(turbModel.rho(),cells_);
|
||||
const scalarField cv(mesh_.V(), cells_);
|
||||
scalar rhoAve = gSumProd(rho, cv)/gSum(cv);
|
||||
scalar rhoAve = gWeightedAverage(cv, rho);
|
||||
volFlowRate = mag(totalphi)/rhoAve;
|
||||
}
|
||||
|
||||
|
||||
@ -2687,7 +2687,7 @@ Foam::label Foam::snappyRefineDriver::directionalSmooth
|
||||
|
||||
const vectorField residual(baseNewPoints - baseMeshPoints);
|
||||
{
|
||||
scalar res(gSum(mag(residual)));
|
||||
scalar res(gSumMag(residual));
|
||||
|
||||
if (iter == 0)
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -700,8 +700,7 @@ Foam::PatchFunction1Types::MappedFile<Type>::value
|
||||
|
||||
if (this->faceValues())
|
||||
{
|
||||
const scalarField magSf(mag(this->patch_.faceAreas()));
|
||||
averagePsi = gSum(magSf*fld)/gSum(magSf);
|
||||
averagePsi = gWeightedAverage(this->patch_.magFaceAreas(), fld);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -39,7 +39,7 @@ adjointRotatingWallVelocityFvPatchVectorField
|
||||
)
|
||||
:
|
||||
adjointWallVelocityFvPatchVectorField(p, iF),
|
||||
origin_(),
|
||||
origin_(Zero),
|
||||
axis_(Zero),
|
||||
omega_(nullptr)
|
||||
{}
|
||||
|
||||
@ -71,17 +71,17 @@ objectiveTopOSolidVolume::objectiveTopOSolidVolume
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
scalar objectiveTopOSolidVolume::J()
|
||||
{
|
||||
J_ = Zero;
|
||||
if (mesh_.foundObject<volScalarField>("beta"))
|
||||
|
||||
if (const auto* betap = mesh_.cfindObject<volScalarField>("beta"))
|
||||
{
|
||||
const volScalarField& beta = mesh_.lookupObject<volScalarField>("beta");
|
||||
const DimensionedField<scalar, volMesh>& V = mesh_.V();
|
||||
const auto& beta = *betap;
|
||||
const scalar time = mesh_.time().timeOutputValue();
|
||||
|
||||
J_ =
|
||||
gSum(beta.primitiveField()*V)/gSum(V)
|
||||
gWeightedAverage(mesh_.V(), beta.primitiveField())
|
||||
- targetPercentage_->value(time);
|
||||
if (percentInDenom_)
|
||||
{
|
||||
@ -101,6 +101,7 @@ scalar objectiveTopOSolidVolume::J()
|
||||
void objectiveTopOSolidVolume::update_dJdb()
|
||||
{
|
||||
const scalar time = mesh_.time().timeOutputValue();
|
||||
|
||||
dJdbPtr_().primitiveFieldRef() = scalar(1)/gSum(mesh_.V());
|
||||
if (percentInDenom_)
|
||||
{
|
||||
|
||||
@ -71,17 +71,17 @@ objectiveTopOVolume::objectiveTopOVolume
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
scalar objectiveTopOVolume::J()
|
||||
{
|
||||
J_ = Zero;
|
||||
if (mesh_.foundObject<volScalarField>("beta"))
|
||||
|
||||
if (const auto* betap = mesh_.cfindObject<volScalarField>("beta"))
|
||||
{
|
||||
const volScalarField& beta = mesh_.lookupObject<volScalarField>("beta");
|
||||
const DimensionedField<scalar, volMesh>& V = mesh_.V();
|
||||
const auto& beta = *betap;
|
||||
const scalar time = mesh_.time().timeOutputValue();
|
||||
|
||||
J_ =
|
||||
scalar(1) - gSum(beta.primitiveField()*V)/gSum(V)
|
||||
scalar(1) - gWeightedAverage(mesh_.V(), beta.primitiveField())
|
||||
- targetPercentage_->value(time);
|
||||
if (percentInDenom_)
|
||||
{
|
||||
@ -101,6 +101,7 @@ scalar objectiveTopOVolume::J()
|
||||
void objectiveTopOVolume::update_dJdb()
|
||||
{
|
||||
const scalar time = mesh_.time().timeOutputValue();
|
||||
|
||||
dJdbPtr_().primitiveFieldRef() = -scalar(1)/gSum(mesh_.V());
|
||||
if (percentInDenom_)
|
||||
{
|
||||
|
||||
@ -62,8 +62,9 @@ Foam::scalar Foam::betaMax::computeLength(const dictionary& dict) const
|
||||
for (const label pI : inletPatches)
|
||||
{
|
||||
const fvPatch& patch = mesh_.boundary()[pI];
|
||||
length += gSum(patch.magSf());
|
||||
length += sum(patch.magSf());
|
||||
}
|
||||
reduce(length, sumOp<scalar>());
|
||||
|
||||
// Divide with the span in the empty direction
|
||||
const Vector<label>& geometricD = mesh_.geometricD();
|
||||
|
||||
@ -513,7 +513,7 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
|
||||
Info<< " qEffVap: " << gMin(qEff) << " - "
|
||||
<< gMax(qEff) << endl;
|
||||
|
||||
scalar Qeff = gSum(qEff*patch().magSf());
|
||||
scalar Qeff = gWeightedSum(patch().magSf(), qEff);
|
||||
Info<< " Effective heat transfer rate to vapor:" << Qeff
|
||||
<< nl << endl;
|
||||
}
|
||||
@ -1111,7 +1111,7 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
|
||||
Info<< " alphatlEff: " << gMin(liquidw*(*this + alphaw))
|
||||
<< " - " << gMax(liquidw*(*this + alphaw)) << endl;
|
||||
|
||||
scalar Qeff = gSum(qEff*patch().magSf());
|
||||
scalar Qeff = gWeightedSum(patch().magSf(), qEff);
|
||||
Info<< " Effective heat transfer rate to liquid: " << Qeff
|
||||
<< endl << nl;
|
||||
|
||||
@ -1166,7 +1166,7 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
|
||||
*hew.snGrad()
|
||||
);
|
||||
|
||||
scalar Qc = gSum(qc*patch().magSf());
|
||||
scalar Qc = gWeightedSum(patch().magSf(), qc);
|
||||
Info<< " Convective heat transfer: " << Qc << endl;
|
||||
|
||||
const scalarField qFilm
|
||||
@ -1174,7 +1174,7 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
|
||||
relax*fLiquid*nFilms*htcFilmBoiling*(Tw - Tsatw)
|
||||
);
|
||||
|
||||
scalar QFilm = gSum(qFilm*patch().magSf());
|
||||
scalar QFilm = gWeightedSum(patch().magSf(), qFilm);
|
||||
Info<< " Film boiling heat transfer: " << QFilm << endl;
|
||||
|
||||
Info<< " Htc Film Boiling coeff: "
|
||||
@ -1199,7 +1199,7 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
|
||||
)
|
||||
);
|
||||
|
||||
scalar QsubCool = gSum(qSubCool*patch().magSf());
|
||||
scalar QsubCool = gWeightedSum(patch().magSf(), qSubCool);
|
||||
|
||||
Info<< " Sub Cool boiling heat transfer: " << QsubCool
|
||||
<< endl;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2020 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -157,9 +157,11 @@ void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::updateCoeffs()
|
||||
|
||||
if (debug)
|
||||
{
|
||||
MinMax<scalar> limits = gMinMax(Q);
|
||||
|
||||
Info<< patch().name() << " " << ": overall heat flux "
|
||||
<< gMin(Q) << " - " << gMax(Q) << " W/m2, power: "
|
||||
<< gSum(patch().magSf()*Q) << " W" << endl;
|
||||
<< limits.min() << " - " << limits.max() << " W/m2, power: "
|
||||
<< gWeightedSum(patch().magSf(), Q) << " W" << endl;
|
||||
}
|
||||
|
||||
operator==((scalar(1) - relax_)*Tp + relax_*max(Tmin_,(q_ + A)/(B)));
|
||||
|
||||
@ -402,10 +402,12 @@ void filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::updateCoeffs()
|
||||
|
||||
if (debug)
|
||||
{
|
||||
scalar Qc = gSum(qConv*patch().magSf());
|
||||
scalar qr = gSum(qRad*patch().magSf());
|
||||
scalar Qc = gWeightedSum(patch().magSf(), qConv);
|
||||
scalar qr = gWeightedSum(patch().magSf(), qRad);
|
||||
scalar Qt = gSum((qConv + qRad)*patch().magSf());
|
||||
|
||||
MinMax<scalar> limits = gMinMax(*this);
|
||||
|
||||
Info<< mesh.name() << ':'
|
||||
<< patch().name() << ':'
|
||||
<< this->internalField().name() << " <- "
|
||||
@ -416,8 +418,8 @@ void filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::updateCoeffs()
|
||||
<< " radiative heat [W] : " << qr << nl
|
||||
<< " total heat [W] : " << Qt << nl
|
||||
<< " wall temperature "
|
||||
<< " min:" << gMin(*this)
|
||||
<< " max:" << gMax(*this)
|
||||
<< " min:" << limits.min()
|
||||
<< " max:" << limits.max()
|
||||
<< " avg:" << gAverage(*this)
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -1048,15 +1048,20 @@ void kinematicSingleLayer::info()
|
||||
outputProperties().readIfPresent("addedMassTotal", addedMassTotal);
|
||||
addedMassTotal += returnReduce(addedMassTotal_, sumOp<scalar>());
|
||||
|
||||
MinMax<scalar> limits_U = gMinMaxMag(Uinternal);
|
||||
MinMax<scalar> limits_delta = gMinMax(deltaInternal);
|
||||
|
||||
Info<< indent << "added mass = " << addedMassTotal << nl
|
||||
<< indent << "current mass = "
|
||||
<< gSum((deltaRho_*magSf())()) << nl
|
||||
<< indent << "min/max(mag(U)) = " << gMin(mag(Uinternal)) << ", "
|
||||
<< gMax(mag(Uinternal)) << nl
|
||||
<< indent << "min/max(delta) = " << gMin(deltaInternal) << ", "
|
||||
<< gMax(deltaInternal) << nl
|
||||
<< gWeightedSum(magSf(), deltaRho_) << nl
|
||||
<< indent << "min/max(mag(U)) = "
|
||||
<< limits_U.min() << ", "
|
||||
<< limits_U.max() << nl
|
||||
<< indent << "min/max(delta) = "
|
||||
<< limits_delta.min() << ", "
|
||||
<< limits_delta.max() << nl
|
||||
<< indent << "coverage = "
|
||||
<< gSum(alpha_.primitiveField()*magSf())/gSum(magSf()) << nl;
|
||||
<< gWeightedAverage(magSf(), alpha_.primitiveField()) << nl;
|
||||
|
||||
injection_.info(Info);
|
||||
transfer_.info(Info);
|
||||
|
||||
@ -170,14 +170,16 @@ void Foam::radiation::fixedIncidentRadiationFvPatchScalarField::updateCoeffs()
|
||||
|
||||
if (debug)
|
||||
{
|
||||
MinMax<scalar> limits = gMinMax(*this);
|
||||
|
||||
scalar qr = gSum(kappa(*this)*gradient()*patch().magSf());
|
||||
Info<< patch().boundaryMesh().mesh().name() << ':'
|
||||
<< patch().name() << ':'
|
||||
<< this->internalField().name() << " -> "
|
||||
<< " radiativeFlux:" << qr
|
||||
<< " walltemperature "
|
||||
<< " min:" << gMin(*this)
|
||||
<< " max:" << gMax(*this)
|
||||
<< " min:" << limits.min()
|
||||
<< " max:" << limits.max()
|
||||
<< " avg:" << gAverage(*this)
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -733,11 +733,13 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::updateCoeffs()
|
||||
|
||||
if (debug && fluid_)
|
||||
{
|
||||
scalar Qdm = gSum(dm*magSf);
|
||||
scalar Qdm = gWeightedSum(magSf, dm);
|
||||
scalar QMass = gSum(mass_);
|
||||
scalar Qt = gSum(myKDelta_*(Tp - Tin)*magSf);
|
||||
scalar QtSolid = gSum(KDeltaNbr*(Tp - nbrIntFld)*magSf);
|
||||
|
||||
MinMax<scalar> limits = gMinMax(*this);
|
||||
|
||||
Info<< mesh.name() << ':'
|
||||
<< patch().name() << ':'
|
||||
<< internalField().name() << " <- "
|
||||
@ -751,8 +753,8 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::updateCoeffs()
|
||||
<< " Total heat (>0 leaving the wall to the solid) [W] : "
|
||||
<< QtSolid << nl
|
||||
<< " wall temperature "
|
||||
<< " min:" << gMin(*this)
|
||||
<< " max:" << gMax(*this)
|
||||
<< " min:" << limits.min()
|
||||
<< " max:" << limits.max()
|
||||
<< " avg:" << gAverage(*this)
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ void Foam::lumpedMassWallTemperatureFvPatchScalarField::updateCoeffs()
|
||||
const scalarField q(tkappa.ref()*snGrad());
|
||||
|
||||
// Total heat in or out of the wall
|
||||
const scalar Q = gSum(q*magSf);
|
||||
const scalar Q = gWeightedSum(magSf, q);
|
||||
|
||||
Tp += -(Q/mass_/Cp_)*deltaT;
|
||||
|
||||
|
||||
@ -212,7 +212,7 @@ void Foam::outletMachNumberPressureFvPatchScalarField::updateCoeffs()
|
||||
}
|
||||
|
||||
const scalarField r(pBack_/ptot);
|
||||
const scalar area = gSum(mag(patch().Sf()));
|
||||
const scalar area = gSum(patch().magSf());
|
||||
M =
|
||||
A1_/(c1_*area)
|
||||
*sqrt(2/(gamma-1)*(pow(r, 2/gamma) - pow(r, (gamma+1)/gamma)));
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -153,7 +153,7 @@ void Foam::outletMappedUniformInletHeatAdditionFvPatchField::updateCoeffs()
|
||||
db().lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
const scalarField& outletPatchPhi = phi.boundaryField()[outletPatchID];
|
||||
scalar sumOutletPatchPhi = gSum(outletPatchPhi);
|
||||
const scalar sumOutletPatchPhi = gSum(outletPatchPhi);
|
||||
|
||||
if (sumOutletPatchPhi > SMALL)
|
||||
{
|
||||
@ -164,22 +164,21 @@ void Foam::outletMappedUniformInletHeatAdditionFvPatchField::updateCoeffs()
|
||||
const scalarField& pT = thermo.T().boundaryField()[outletPatchID];
|
||||
|
||||
scalar averageOutletField =
|
||||
gSum(outletPatchPhi*outletPatchField)/sumOutletPatchPhi;
|
||||
gWeightedSum(outletPatchPhi, outletPatchField)/sumOutletPatchPhi;
|
||||
|
||||
// Calculate Q as a function of average outlet temperature
|
||||
const scalar Q = Qptr_->value(averageOutletField);
|
||||
|
||||
const scalarField Cpf(thermo.Cp(pp, pT, outletPatchID));
|
||||
|
||||
scalar totalPhiCp = gSum(outletPatchPhi)*gAverage(Cpf);
|
||||
scalar totalPhiCp = sumOutletPatchPhi*gAverage(Cpf);
|
||||
|
||||
operator==(clamp(averageOutletField + Q/totalPhiCp, TMin_, TMax_));
|
||||
}
|
||||
else
|
||||
{
|
||||
scalar averageOutletField =
|
||||
gSum(outletPatch.magSf()*outletPatchField)
|
||||
/gSum(outletPatch.magSf());
|
||||
gWeightedAverage(outletPatch.magSf(), outletPatchField);
|
||||
|
||||
operator==(averageOutletField);
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ void Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::updateCoeffs()
|
||||
|
||||
if (debug)
|
||||
{
|
||||
scalar phi = gSum(-phip*(*this));
|
||||
scalar phi = -gWeightedSum(phip, *this);
|
||||
|
||||
Info<< patch().boundaryMesh().mesh().name() << ':'
|
||||
<< patch().name() << ':'
|
||||
|
||||
@ -690,7 +690,7 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs()
|
||||
htc[i] = qField[i]/deltaT[i];
|
||||
}
|
||||
}
|
||||
const scalar aveHtc = gSum(htc*patch().magSf())/max(magSf, SMALL);
|
||||
const scalar aveHtc = gWeightedAverage(patch().magSf(), htc);
|
||||
|
||||
|
||||
// Calculate heat-transfer coeff based on the second definition
|
||||
@ -704,8 +704,7 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs()
|
||||
htcPatch[i] = qField[i]/deltaTPatch[i];
|
||||
}
|
||||
}
|
||||
const scalar aveHtcPatch =
|
||||
gSum(htcPatch*patch().magSf())/max(magSf, SMALL);
|
||||
const scalar aveHtcPatch = gWeightedAverage(patch().magSf(), htcPatch);
|
||||
|
||||
// Calculate various averages of temperature
|
||||
const scalarMinMax TpMinMax = gMinMax(Tp);
|
||||
|
||||
@ -140,15 +140,17 @@ updateCoeffs()
|
||||
|
||||
if (debug)
|
||||
{
|
||||
scalar Q = gSum((*this)*patch().magSf());
|
||||
scalar Q = gWeightedSum(patch().magSf(), *this);
|
||||
|
||||
MinMax<scalar> limits = gMinMax(*this);
|
||||
|
||||
Info<< patch().boundaryMesh().mesh().name() << ':'
|
||||
<< patch().name() << ':'
|
||||
<< this->internalField().name() << " <- "
|
||||
<< " heat transfer rate:" << Q
|
||||
<< " wall radiative heat flux "
|
||||
<< " min:" << gMin(*this)
|
||||
<< " max:" << gMax(*this)
|
||||
<< " min:" << limits.min()
|
||||
<< " max:" << limits.max()
|
||||
<< " avg:" << gAverage(*this)
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -1118,7 +1118,7 @@ void Foam::radiation::viewFactor::calculate()
|
||||
{
|
||||
const scalarField& qrp = qrBf[patchID];
|
||||
const scalarField& magSf = mesh_.magSf().boundaryField()[patchID];
|
||||
const scalar heatFlux = gSum(qrp*magSf);
|
||||
const scalar heatFlux = gWeightedSum(magSf, qrp);
|
||||
|
||||
Info<< "Total heat transfer rate at patch: "
|
||||
<< patchID << " "
|
||||
|
||||
Reference in New Issue
Block a user