mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'feature-field-functions-SIMD' into 'develop'
Field functions for lerp and clamp. Add clamping as Field methods See merge request Development/openfoam!593
This commit is contained in:
@ -171,10 +171,7 @@ if (ign.ignited())
|
||||
|
||||
fvOptions.correct(Su);
|
||||
|
||||
// Limit the maximum Su
|
||||
// ~~~~~~~~~~~~~~~~~~~~
|
||||
Su.min(SuMax);
|
||||
Su.max(SuMin);
|
||||
Su.clamp_range(SuMin, SuMax);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -218,7 +215,7 @@ if (ign.ignited())
|
||||
+ (
|
||||
scalar(1)
|
||||
+ (2*XiShapeCoef)
|
||||
*(scalar(0.5) - min(max(b, scalar(0)), scalar(1)))
|
||||
*(scalar(0.5) - clamp(b, zero_one{}))
|
||||
)*(XiEqStar - scalar(1.001))
|
||||
);
|
||||
|
||||
|
||||
@ -39,13 +39,13 @@ tmp<fv::convectionScheme<scalar>> mvConvection
|
||||
|
||||
fvOptions.correct(Yi);
|
||||
|
||||
Yi.max(0.0);
|
||||
Yi.clamp_min(0);
|
||||
Yt += Yi;
|
||||
}
|
||||
}
|
||||
|
||||
Y[inertIndex] = scalar(1) - Yt;
|
||||
Y[inertIndex].max(0.0);
|
||||
Y[inertIndex].clamp_min(0);
|
||||
|
||||
radiation->correct();
|
||||
|
||||
|
||||
@ -38,11 +38,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
|
||||
|
||||
fvOptions.correct(Yi);
|
||||
|
||||
Yi.max(0.0);
|
||||
Yi.clamp_min(0);
|
||||
Yt += Yi;
|
||||
}
|
||||
}
|
||||
|
||||
Y[inertIndex] = scalar(1) - Yt;
|
||||
Y[inertIndex].max(0.0);
|
||||
Y[inertIndex].clamp_min(0);
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ if (Y.size())
|
||||
|
||||
fvOptions.correct(Yi);
|
||||
|
||||
Yi.max(0.0);
|
||||
Yi.clamp_min(0);
|
||||
Yt += Yi;
|
||||
}
|
||||
}
|
||||
@ -56,6 +56,6 @@ if (Y.size())
|
||||
if (Y.size())
|
||||
{
|
||||
Y[inertIndex] = scalar(1) - Yt;
|
||||
Y[inertIndex].max(0.0);
|
||||
Y[inertIndex].clamp_min(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,11 +40,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
|
||||
|
||||
fvOptions.correct(Yi);
|
||||
|
||||
Yi.max(0.0);
|
||||
Yi.clamp_min(0);
|
||||
Yt += Yi;
|
||||
}
|
||||
}
|
||||
|
||||
Y[inertIndex] = scalar(1) - Yt;
|
||||
Y[inertIndex].max(0.0);
|
||||
Y[inertIndex].clamp_min(0);
|
||||
}
|
||||
|
||||
@ -41,11 +41,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
|
||||
|
||||
fvOptions.correct(Yi);
|
||||
|
||||
Yi.max(0.0);
|
||||
Yi.clamp_min(0);
|
||||
Yt += Yi;
|
||||
}
|
||||
}
|
||||
|
||||
Y[inertIndex] = scalar(1) - Yt;
|
||||
Y[inertIndex].max(0.0);
|
||||
Y[inertIndex].clamp_min(0);
|
||||
}
|
||||
|
||||
@ -38,11 +38,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
|
||||
|
||||
fvOptions.correct(Yi);
|
||||
|
||||
Yi.max(0.0);
|
||||
Yi.clamp_min(0);
|
||||
Yt += Yi;
|
||||
}
|
||||
}
|
||||
|
||||
Y[inertIndex] = scalar(1) - Yt;
|
||||
Y[inertIndex].max(0.0);
|
||||
Y[inertIndex].clamp_min(0);
|
||||
}
|
||||
|
||||
@ -38,11 +38,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
|
||||
|
||||
fvOptions.correct(Yi);
|
||||
|
||||
Yi.max(0.0);
|
||||
Yi.clamp_min(0);
|
||||
Yt += Yi;
|
||||
}
|
||||
}
|
||||
|
||||
Y[inertIndex] = scalar(1) - Yt;
|
||||
Y[inertIndex].max(0.0);
|
||||
Y[inertIndex].clamp_min(0);
|
||||
}
|
||||
|
||||
@ -39,11 +39,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
|
||||
|
||||
fvOptions.correct(Yi);
|
||||
|
||||
Yi.max(0.0);
|
||||
Yi.clamp_min(0);
|
||||
Yt += Yi;
|
||||
}
|
||||
}
|
||||
|
||||
Y[inertIndex] = scalar(1) - Yt;
|
||||
Y[inertIndex].max(0.0);
|
||||
Y[inertIndex].clamp_min(0);
|
||||
}
|
||||
|
||||
@ -1,14 +1,5 @@
|
||||
{
|
||||
alphav =
|
||||
max
|
||||
(
|
||||
min
|
||||
(
|
||||
(rho - rholSat)/(rhovSat - rholSat),
|
||||
scalar(1)
|
||||
),
|
||||
scalar(0)
|
||||
);
|
||||
alphav = clamp((rho - rholSat)/(rhovSat - rholSat), zero_one{});
|
||||
alphal = 1.0 - alphav;
|
||||
|
||||
Info<< "max-min alphav: " << max(alphav).value()
|
||||
|
||||
@ -99,17 +99,6 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDotAlphal() const
|
||||
Foam::Pair<Foam::tmp<Foam::volScalarField>>
|
||||
Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDot() const
|
||||
{
|
||||
|
||||
volScalarField limitedAlpha1
|
||||
(
|
||||
min(max(mixture_.alpha1(), scalar(0)), scalar(1))
|
||||
);
|
||||
|
||||
volScalarField limitedAlpha2
|
||||
(
|
||||
min(max(mixture_.alpha2(), scalar(0)), scalar(1))
|
||||
);
|
||||
|
||||
const volScalarField& T = mesh_.lookupObject<volScalarField>("T");
|
||||
|
||||
const twoPhaseMixtureEThermo& thermo =
|
||||
@ -124,11 +113,15 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDot() const
|
||||
|
||||
volScalarField mDotE
|
||||
(
|
||||
"mDotE", coeffE_*mixture_.rho1()*limitedAlpha1*max(T - TSat, T0)
|
||||
"mDotE",
|
||||
coeffE_*mixture_.rho1()*clamp(mixture_.alpha1(), zero_one{})
|
||||
* max(T - TSat, T0)
|
||||
);
|
||||
volScalarField mDotC
|
||||
(
|
||||
"mDotC", coeffC_*mixture_.rho2()*limitedAlpha2*max(TSat - T, T0)
|
||||
"mDotC",
|
||||
coeffC_*mixture_.rho2()*clamp(mixture_.alpha2(), zero_one{})
|
||||
* max(TSat - T, T0)
|
||||
);
|
||||
|
||||
if (mesh_.time().outputTime())
|
||||
@ -148,16 +141,6 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDot() const
|
||||
Foam::Pair<Foam::tmp<Foam::volScalarField>>
|
||||
Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDotDeltaT() const
|
||||
{
|
||||
volScalarField limitedAlpha1
|
||||
(
|
||||
min(max(mixture_.alpha1(), scalar(0)), scalar(1))
|
||||
);
|
||||
|
||||
volScalarField limitedAlpha2
|
||||
(
|
||||
min(max(mixture_.alpha2(), scalar(0)), scalar(1))
|
||||
);
|
||||
|
||||
const volScalarField& T = mesh_.lookupObject<volScalarField>("T");
|
||||
|
||||
const twoPhaseMixtureEThermo& thermo =
|
||||
@ -170,8 +153,14 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDotDeltaT() const
|
||||
|
||||
return Pair<tmp<volScalarField>>
|
||||
(
|
||||
coeffC_*mixture_.rho2()*limitedAlpha2*pos(TSat - T),
|
||||
coeffE_*mixture_.rho1()*limitedAlpha1*pos(T - TSat)
|
||||
(
|
||||
coeffC_*mixture_.rho2()*clamp(mixture_.alpha2(), zero_one{})
|
||||
* pos(TSat - T)
|
||||
),
|
||||
(
|
||||
coeffE_*mixture_.rho1()*clamp(mixture_.alpha1(), zero_one{})
|
||||
* pos(T - TSat)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -201,25 +190,17 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::TSource() const
|
||||
|
||||
const dimensionedScalar& TSat = thermo.TSat();
|
||||
|
||||
dimensionedScalar L = mixture_.Hf2() - mixture_.Hf1();
|
||||
|
||||
volScalarField limitedAlpha1
|
||||
(
|
||||
min(max(mixture_.alpha1(), scalar(0)), scalar(1))
|
||||
);
|
||||
|
||||
volScalarField limitedAlpha2
|
||||
(
|
||||
min(max(mixture_.alpha2(), scalar(0)), scalar(1))
|
||||
);
|
||||
const dimensionedScalar L = mixture_.Hf2() - mixture_.Hf1();
|
||||
|
||||
const volScalarField Vcoeff
|
||||
(
|
||||
coeffE_*mixture_.rho1()*limitedAlpha1*L*pos(T - TSat)
|
||||
coeffE_*mixture_.rho1()*clamp(mixture_.alpha1(), zero_one{})
|
||||
* L*pos(T - TSat)
|
||||
);
|
||||
const volScalarField Ccoeff
|
||||
(
|
||||
coeffC_*mixture_.rho2()*limitedAlpha2*L*pos(TSat - T)
|
||||
coeffC_*mixture_.rho2()*clamp(mixture_.alpha2(), zero_one{})
|
||||
* L*pos(TSat - T)
|
||||
);
|
||||
|
||||
TSource =
|
||||
|
||||
@ -167,20 +167,10 @@ Foam::Pair<Foam::tmp<Foam::volScalarField>>
|
||||
Foam::temperaturePhaseChangeTwoPhaseMixtures::interfaceHeatResistance::
|
||||
mDotAlphal() const
|
||||
{
|
||||
volScalarField limitedAlpha1
|
||||
(
|
||||
min(max(mixture_.alpha1(), scalar(0)), scalar(1))
|
||||
);
|
||||
|
||||
volScalarField limitedAlpha2
|
||||
(
|
||||
min(max(mixture_.alpha2(), scalar(0)), scalar(1))
|
||||
);
|
||||
|
||||
return Pair<tmp<volScalarField>>
|
||||
(
|
||||
(mDotc_/(limitedAlpha2 + SMALL)),
|
||||
-(mDote_/(limitedAlpha1 + SMALL))
|
||||
(mDotc_/clamp(mixture_.alpha2(), scalarMinMax(SMALL, 1))),
|
||||
-(mDote_/clamp(mixture_.alpha1(), scalarMinMax(SMALL, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -155,7 +155,7 @@ Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::Cp() const
|
||||
{
|
||||
const volScalarField limitedAlpha1
|
||||
(
|
||||
min(max(alpha1_, scalar(0)), scalar(1))
|
||||
clamp(alpha1_, zero_one{})
|
||||
);
|
||||
|
||||
return tmp<volScalarField>
|
||||
@ -176,13 +176,11 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::Cp
|
||||
const label patchi
|
||||
) const
|
||||
{
|
||||
const volScalarField limitedAlpha1
|
||||
const scalarField alpha1p
|
||||
(
|
||||
min(max(alpha1_, scalar(0)), scalar(1))
|
||||
clamp(alpha1_.boundaryField()[patchi], zero_one{})
|
||||
);
|
||||
|
||||
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
|
||||
|
||||
return
|
||||
(
|
||||
alpha1p*Cp1().value() + (scalar(1) - alpha1p)*Cp2().value()
|
||||
@ -194,7 +192,7 @@ Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::rho() const
|
||||
{
|
||||
const volScalarField limitedAlpha1
|
||||
(
|
||||
min(max(alpha1_, scalar(0)), scalar(1))
|
||||
clamp(alpha1_, zero_one{})
|
||||
);
|
||||
|
||||
return tmp<volScalarField>
|
||||
@ -214,13 +212,11 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::rho
|
||||
const label patchi
|
||||
) const
|
||||
{
|
||||
const volScalarField limitedAlpha1
|
||||
const scalarField alpha1p
|
||||
(
|
||||
min(max(alpha1_, scalar(0)), scalar(1))
|
||||
clamp(alpha1_.boundaryField()[patchi], zero_one{})
|
||||
);
|
||||
|
||||
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
|
||||
|
||||
return
|
||||
(
|
||||
alpha1p*rho1().value() + (scalar(1) - alpha1p)*rho2().value()
|
||||
@ -232,7 +228,7 @@ Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::Cv() const
|
||||
{
|
||||
const volScalarField limitedAlpha1
|
||||
(
|
||||
min(max(alpha1_, scalar(0)), scalar(1))
|
||||
clamp(alpha1_, zero_one{})
|
||||
);
|
||||
|
||||
return tmp<volScalarField>
|
||||
@ -253,13 +249,11 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::Cv
|
||||
const label patchi
|
||||
) const
|
||||
{
|
||||
const volScalarField limitedAlpha1
|
||||
const scalarField alpha1p
|
||||
(
|
||||
min(max(alpha1_, scalar(0)), scalar(1))
|
||||
clamp(alpha1_.boundaryField()[patchi], zero_one{})
|
||||
);
|
||||
|
||||
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
|
||||
|
||||
return
|
||||
(
|
||||
alpha1p*Cv1().value() + (scalar(1) - alpha1p)*Cv2().value()
|
||||
@ -339,7 +333,7 @@ Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::kappa() const
|
||||
{
|
||||
const volScalarField limitedAlpha1
|
||||
(
|
||||
min(max(alpha1_, scalar(0)), scalar(1))
|
||||
clamp(alpha1_, zero_one{})
|
||||
);
|
||||
|
||||
return tmp<volScalarField>
|
||||
@ -358,13 +352,11 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::kappa
|
||||
const label patchi
|
||||
) const
|
||||
{
|
||||
const volScalarField limitedAlpha1
|
||||
const scalarField alpha1p
|
||||
(
|
||||
min(max(alpha1_, scalar(0)), scalar(1))
|
||||
clamp(alpha1_.boundaryField()[patchi], zero_one{})
|
||||
);
|
||||
|
||||
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
|
||||
|
||||
return (alpha1p*kappa1().value() + (1 - alpha1p)*kappa2().value());
|
||||
}
|
||||
|
||||
@ -402,13 +394,11 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::kappaEff
|
||||
const label patchi
|
||||
) const
|
||||
{
|
||||
const volScalarField limitedAlpha1
|
||||
const scalarField alpha1p
|
||||
(
|
||||
min(max(alpha1_, scalar(0)), scalar(1))
|
||||
clamp(alpha1_.boundaryField()[patchi], zero_one{})
|
||||
);
|
||||
|
||||
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
|
||||
|
||||
return
|
||||
(alpha1p*kappa1().value() + (1 - alpha1p)*kappa2().value()) + kappat;
|
||||
|
||||
@ -435,13 +425,11 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::alphaEff
|
||||
const label patchi
|
||||
) const
|
||||
{
|
||||
const volScalarField limitedAlpha1
|
||||
const scalarField alpha1p
|
||||
(
|
||||
min(max(alpha1_, scalar(0)), scalar(1))
|
||||
clamp(alpha1_.boundaryField()[patchi], zero_one{})
|
||||
);
|
||||
|
||||
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
|
||||
|
||||
const scalarField rho
|
||||
(
|
||||
alpha1p*rho1().value() + (1.0 - alpha1p)*rho2().value()
|
||||
|
||||
@ -70,7 +70,7 @@ Foam::Pair<Foam::tmp<Foam::volScalarField>>
|
||||
Foam::phaseChangeTwoPhaseMixtures::Kunz::mDotAlphal() const
|
||||
{
|
||||
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
||||
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
|
||||
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
|
||||
|
||||
return Pair<tmp<volScalarField>>
|
||||
(
|
||||
@ -85,7 +85,7 @@ Foam::Pair<Foam::tmp<Foam::volScalarField>>
|
||||
Foam::phaseChangeTwoPhaseMixtures::Kunz::mDotP() const
|
||||
{
|
||||
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
||||
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
|
||||
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
|
||||
|
||||
return Pair<tmp<volScalarField>>
|
||||
(
|
||||
|
||||
@ -82,7 +82,7 @@ Foam::Pair<Foam::tmp<Foam::volScalarField>>
|
||||
Foam::phaseChangeTwoPhaseMixtures::Merkle::mDotP() const
|
||||
{
|
||||
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
||||
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
|
||||
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
|
||||
|
||||
return Pair<tmp<volScalarField>>
|
||||
(
|
||||
|
||||
@ -99,7 +99,7 @@ Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::pCoeff
|
||||
const volScalarField& p
|
||||
) const
|
||||
{
|
||||
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
|
||||
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
|
||||
volScalarField rho
|
||||
(
|
||||
limitedAlpha1*rho1() + (scalar(1) - limitedAlpha1)*rho2()
|
||||
@ -117,7 +117,7 @@ Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::mDotAlphal() const
|
||||
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
||||
volScalarField pCoeff(this->pCoeff(p));
|
||||
|
||||
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
|
||||
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
|
||||
|
||||
return Pair<tmp<volScalarField>>
|
||||
(
|
||||
@ -134,7 +134,7 @@ Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::mDotP() const
|
||||
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
||||
volScalarField pCoeff(this->pCoeff(p));
|
||||
|
||||
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
|
||||
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
|
||||
volScalarField apCoeff(limitedAlpha1*pCoeff);
|
||||
|
||||
return Pair<tmp<volScalarField>>
|
||||
|
||||
@ -152,19 +152,26 @@ int main(int argc, char *argv[])
|
||||
Info<< nl
|
||||
<< "field: " << flatOutput(someField) << nl;
|
||||
Info<< "clamp01: "
|
||||
<< flatOutput(clamp(someField, scalarMinMax(zero_one{}))()) << nl;
|
||||
<< flatOutput(clamp(someField, zero_one{})()) << nl;
|
||||
|
||||
Info<< "clamp01: "
|
||||
<< clamp(tmp<scalarField>(someField), scalarMinMax(zero_one{}))<< nl;
|
||||
<< clamp(tmp<scalarField>(someField), zero_one{})<< nl;
|
||||
|
||||
scalarField result(10);
|
||||
clamp(result, someField, scalarMinMax(zero_one{}));
|
||||
clamp(result, someField, zero_one{});
|
||||
|
||||
Info<< "result: " << result << nl;
|
||||
|
||||
someField.clamp(zero_one{});
|
||||
|
||||
someField.clamp_range(zero_one{});
|
||||
Info<< "inplace: " << someField << nl;
|
||||
|
||||
scalar val(1.414);
|
||||
|
||||
Info<< "clamp " << val
|
||||
// nope << " : " << clamp(val, zero_one{})
|
||||
// nope << " : " << clamp(val, scalarMinMax(zero_one{}))
|
||||
<< " : " << clamp(val, 0, 1)
|
||||
<< nl;
|
||||
}
|
||||
|
||||
Info<< nl << "\nDone\n" << endl;
|
||||
|
||||
@ -1,3 +1,38 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
Test-vectorSpeed
|
||||
|
||||
Description
|
||||
Test speeds, usability of some field operations
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "primitiveFields.H"
|
||||
#include "cpuTime.H"
|
||||
#include "IOstreams.H"
|
||||
@ -5,12 +40,22 @@
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
int main()
|
||||
{
|
||||
const label nIter = 100;
|
||||
const label size = 1000000;
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Info<< "Initialising fields" << endl;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::addBoolOption("lerp");
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
const label nIter = 1000;
|
||||
const label size = (1000000);
|
||||
|
||||
Info<< "Initialising fields. size:" << size
|
||||
<< " max:" << labelMax << endl;
|
||||
|
||||
scalarField onet(size);
|
||||
|
||||
vectorField
|
||||
vf1(size, vector::one),
|
||||
@ -18,11 +63,14 @@ int main()
|
||||
vf3(size, vector::one),
|
||||
vf4(size);
|
||||
|
||||
Info<< "Done\n" << endl;
|
||||
Info<< "Start loop: " << nIter << endl;
|
||||
|
||||
cpuTime timing;
|
||||
|
||||
// Timing is mostly malloc anyhow...
|
||||
|
||||
if (!args.found("lerp"))
|
||||
{
|
||||
cpuTime executionTime;
|
||||
|
||||
Info<< "vectorField algebra" << endl;
|
||||
|
||||
for (int j=0; j<nIter; j++)
|
||||
@ -30,12 +78,142 @@ int main()
|
||||
vf4 = vf1 + vf2 - vf3;
|
||||
}
|
||||
|
||||
Info<< "ExecutionTime = "
|
||||
<< executionTime.elapsedCpuTime()
|
||||
<< " s\n" << endl;
|
||||
Info<< "Timing = " << timing.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
Snull<< vf4[1] << endl << endl;
|
||||
}
|
||||
|
||||
if (args.found("lerp"))
|
||||
{
|
||||
Info<< nl
|
||||
<< "testing timings with lerp 0.75" << nl
|
||||
<< "Main bottlenecks: malloc and looping" << nl;
|
||||
|
||||
scalar t = 0.75;
|
||||
scalarField fract(size, t);
|
||||
|
||||
// Basic compilation tests:
|
||||
lerp(vf1, vf2, fract)().size(); // list list list
|
||||
lerp(0.5*vf1, vf2, fract)().size(); // tmp list list
|
||||
lerp(vf1, 0.5*vf2, fract)().size(); // list tmp list
|
||||
lerp(vf1, vf2, 0.5*fract)().size(); // list list tmp
|
||||
lerp(0.5*vf1, 0.5*vf2, fract)().size(); // tmp tmp list
|
||||
lerp(0.5*vf1, vf2, 0.5*fract)().size(); // tmp list tmp
|
||||
lerp(vf1, 1.0*vf2, 0.5*fract)().size(); // list tmp tmp
|
||||
lerp(0.5*vf1, 0.5*vf2, 0.5*fract)().size(); // tmp tmp tmp
|
||||
|
||||
// Basic compilation tests:
|
||||
lerp(vf1, vf2, t)().size(); // list list scalar
|
||||
lerp(0.5*vf1, vf2, t)().size(); // tmp list scalar
|
||||
lerp(vf1, 0.5*vf2, t)().size(); // list tmp scalar
|
||||
lerp(0.5*vf1, 0.5*vf2, t)().size(); // tmp tmp scalar
|
||||
lerp(vf1, 1.0*vf2, 0.5*t)().size(); // list tmp scalar
|
||||
|
||||
// Other combinations (not yet included)
|
||||
// list scalar list...
|
||||
// scalar list list...
|
||||
|
||||
|
||||
// Probable base line of single instruction multiple data
|
||||
for (int j=0; j<nIter; j++)
|
||||
{
|
||||
const label loopLen = (vf1).size();
|
||||
|
||||
for (label i = 0; i < loopLen; ++i)
|
||||
{
|
||||
vf4[i] = (1-fract[i])*vf1[i] + fract[i]*vf2[i];
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "(1-t)*a + t*b : Timing (no malloc) = "
|
||||
<< timing.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
Snull<< vf4[1] << endl << endl;
|
||||
|
||||
// With all loops written out
|
||||
// - corresponds to what we would normally have
|
||||
for (int j=0; j<nIter; j++)
|
||||
{
|
||||
const label loopLen = (vf1).size();
|
||||
|
||||
for (label i = 0; i < loopLen; ++i)
|
||||
{
|
||||
onet[i] = (1-fract[i]);
|
||||
}
|
||||
|
||||
for (label i = 0; i < loopLen; ++i)
|
||||
{
|
||||
vf3[i] = (fract[i] * vf2[i]);
|
||||
}
|
||||
|
||||
for (label i = 0; i < loopLen; ++i)
|
||||
{
|
||||
vf4[i] = onet[i] * vf1[i];
|
||||
}
|
||||
|
||||
for (label i = 0; i < loopLen; ++i)
|
||||
{
|
||||
vf4[i] += vf3[i];
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "(1-t)*a + t*b : Looping (no malloc) = "
|
||||
<< timing.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
Snull<< vf4[1] << endl << endl;
|
||||
|
||||
for (int j=0; j<nIter; j++)
|
||||
{
|
||||
lerp(vf4, vf1, vf2, fract);
|
||||
}
|
||||
|
||||
Info<< "lerp(a, b, t) : Timing (no malloc) = "
|
||||
<< timing.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
Snull<< vf4[1] << endl << endl;
|
||||
|
||||
Info<< nl;
|
||||
|
||||
// Now with tmp fields
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
for (int j=0; j<nIter; j++)
|
||||
{
|
||||
vf4 = (1-fract)*vf1 + fract*vf2;
|
||||
}
|
||||
|
||||
Info<< "(1-t)*a + t*b : Timing (with malloc) = "
|
||||
<< timing.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
Snull<< vf4[1] << endl << endl;
|
||||
|
||||
for (int j=0; j<nIter; j++)
|
||||
{
|
||||
// With field 't'
|
||||
vf4 = lerp(vf1, vf2, fract);
|
||||
}
|
||||
|
||||
Info<< "lerp(a, b, t) : Timing (with malloc) = "
|
||||
<< timing.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
Snull<< vf4[1] << endl << endl;
|
||||
|
||||
for (int j=0; j<nIter; j++)
|
||||
{
|
||||
// With scalar 't'
|
||||
vf4 = lerp(vf1, vf2, t);
|
||||
}
|
||||
|
||||
Info<< "lerp(a, b, t) : Timing (with malloc) scalar = "
|
||||
<< timing.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
Snull<< vf4[1] << endl << endl;
|
||||
}
|
||||
|
||||
|
||||
Info<< nl << "Done" << nl << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -114,7 +114,7 @@ namespace vectorTools
|
||||
scalar cosPhi = (a & b)/(mag(a)*mag(b) + tolerance);
|
||||
|
||||
// Enforce bounding between -1 and 1
|
||||
return min(max(cosPhi, -1), 1);
|
||||
return clamp(cosPhi, -1, 1);
|
||||
}
|
||||
|
||||
//- Calculate angle between a and b in radians
|
||||
@ -129,7 +129,7 @@ namespace vectorTools
|
||||
scalar cosPhi = (a & b)/(mag(a)*mag(b) + tolerance);
|
||||
|
||||
// Enforce bounding between -1 and 1
|
||||
return acos( min(max(cosPhi, -1), 1) );
|
||||
return acos(clamp(cosPhi, -1, 1));
|
||||
}
|
||||
|
||||
//- Calculate angle between a and b in degrees
|
||||
|
||||
@ -92,7 +92,7 @@ void blendField
|
||||
volScalarField fld(fieldHeader, mesh);
|
||||
scalarField& pf = fld.primitiveFieldRef();
|
||||
pf = (1 - mask)*pf + mask*boundaryLayerField;
|
||||
fld.max(SMALL);
|
||||
fld.clamp_min(SMALL);
|
||||
|
||||
// Correct the processor patches only.
|
||||
// Do not correct BC
|
||||
@ -131,7 +131,7 @@ void calcOmegaField
|
||||
scalarField& pf = omega.primitiveFieldRef();
|
||||
|
||||
pf = (1 - mask)*pf + mask*epsilonBL/(Cmu*kBL + SMALL);
|
||||
omega.max(SMALL);
|
||||
omega.clamp_min(SMALL);
|
||||
|
||||
// Correct the processor patches only.
|
||||
// Do not correct BC
|
||||
|
||||
@ -108,7 +108,7 @@ void setAlpha
|
||||
{
|
||||
cutCell.calcSubCell(cellI, 0.0);
|
||||
|
||||
alpha1[cellI] = max(min(cutCell.VolumeOfFluid(), 1), 0);
|
||||
alpha1[cellI] = clamp(cutCell.VolumeOfFluid(), 0, 1);
|
||||
|
||||
if (writeOBJ && (mag(cutCell.faceArea()) >= 1e-14))
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -241,13 +241,7 @@ void calcF
|
||||
solve(fEqn);
|
||||
|
||||
// (M:p. 2)
|
||||
const dimensioned<scalarMinMax> fMinMax
|
||||
(
|
||||
dimless,
|
||||
scalarMinMax(Zero, scalar(1) - Foam::exp(-scalar(400)/scalar(50)))
|
||||
);
|
||||
|
||||
f.clip(fMinMax);
|
||||
f.clamp_range(0, scalar(1) - Foam::exp(-scalar(400)/scalar(50)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -207,7 +207,7 @@ void Foam::CLASS::updateCoeffs()
|
||||
const scalarField& phip =
|
||||
this->patch().template lookupPatchField<surfaceScalarField>("phi");
|
||||
|
||||
this->valueFraction() = 1.0 - pos0(phip);
|
||||
this->valueFraction() = neg(phip);
|
||||
|
||||
PARENT::updateCoeffs();
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ void Foam::adaptiveSolver::solve
|
||||
if (err > pow(maxScale_/safeScale_, -1.0/alphaInc_))
|
||||
{
|
||||
dxTry =
|
||||
min(max(safeScale_*pow(err, -alphaInc_), minScale_), maxScale_)*dx;
|
||||
clamp(safeScale_*pow(err, -alphaInc_), minScale_, maxScale_)*dx;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,32 +36,27 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type, class GeoMesh, direction r>
|
||||
tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh>>
|
||||
pow
|
||||
(
|
||||
const DimensionedField<Type, GeoMesh>& df,
|
||||
const DimensionedField<Type, GeoMesh>& f1,
|
||||
typename powProduct<Type, r>::type
|
||||
)
|
||||
{
|
||||
typedef typename powProduct<Type, r>::type powProductType;
|
||||
typedef typename powProduct<Type, r>::type resultType;
|
||||
|
||||
auto tres =
|
||||
tmp<DimensionedField<powProductType, GeoMesh>>::New
|
||||
reuseTmpDimensionedField<resultType, Type, GeoMesh>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pow(" + df.name() + ',' + name(r) + ')',
|
||||
df.instance(),
|
||||
df.db()
|
||||
),
|
||||
df.mesh(),
|
||||
pow(df.dimensions(), r)
|
||||
f1,
|
||||
"pow(" + f1.name() + ',' + Foam::name(r) + ')',
|
||||
pow(f1.dimensions(), r)
|
||||
);
|
||||
|
||||
pow<Type, r, GeoMesh>(tres.ref().field(), df.field());
|
||||
pow<Type, r, GeoMesh>(tres.ref().field(), f1.field());
|
||||
|
||||
return tres;
|
||||
}
|
||||
@ -71,166 +66,151 @@ template<class Type, class GeoMesh, direction r>
|
||||
tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh>>
|
||||
pow
|
||||
(
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf,
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tf1,
|
||||
typename powProduct<Type, r>::type
|
||||
)
|
||||
{
|
||||
typedef typename powProduct<Type, r>::type powProductType;
|
||||
typedef typename powProduct<Type, r>::type resultType;
|
||||
|
||||
const DimensionedField<Type, GeoMesh>& df = tdf();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
auto tres =
|
||||
reuseTmpDimensionedField<powProductType, Type, GeoMesh>::New
|
||||
reuseTmpDimensionedField<resultType, Type, GeoMesh>::New
|
||||
(
|
||||
tdf,
|
||||
"pow(" + df.name() + ',' + name(r) + ')',
|
||||
pow(df.dimensions(), r)
|
||||
tf1,
|
||||
"pow(" + f1.name() + ',' + Foam::name(r) + ')',
|
||||
pow(f1.dimensions(), r)
|
||||
);
|
||||
|
||||
pow<Type, r, GeoMesh>(tres.ref().field(), df.field());
|
||||
pow<Type, r, GeoMesh>(tres.ref().field(), f1.field());
|
||||
|
||||
tdf.clear();
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh>>
|
||||
sqr(const DimensionedField<Type, GeoMesh>& df)
|
||||
sqr(const DimensionedField<Type, GeoMesh>& f1)
|
||||
{
|
||||
typedef typename outerProduct<Type, Type>::type outerProductType;
|
||||
typedef typename outerProduct<Type, Type>::type resultType;
|
||||
|
||||
auto tres =
|
||||
tmp<DimensionedField<outerProductType, GeoMesh>>::New
|
||||
reuseTmpDimensionedField<resultType, Type, GeoMesh>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"sqr(" + df.name() + ')',
|
||||
df.instance(),
|
||||
df.db()
|
||||
),
|
||||
df.mesh(),
|
||||
sqr(df.dimensions())
|
||||
f1,
|
||||
"sqr(" + f1.name() + ')',
|
||||
sqr(f1.dimensions())
|
||||
);
|
||||
|
||||
sqr(tres.ref().field(), df.field());
|
||||
sqr(tres.ref().field(), f1.field());
|
||||
|
||||
return tres;
|
||||
}
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh>>
|
||||
sqr(const tmp<DimensionedField<Type, GeoMesh>>& tdf)
|
||||
sqr(const tmp<DimensionedField<Type, GeoMesh>>& tf1)
|
||||
{
|
||||
typedef typename outerProduct<Type, Type>::type outerProductType;
|
||||
typedef typename outerProduct<Type, Type>::type resultType;
|
||||
|
||||
const DimensionedField<Type, GeoMesh>& df = tdf();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
auto tres =
|
||||
reuseTmpDimensionedField<outerProductType, Type, GeoMesh>::New
|
||||
reuseTmpDimensionedField<resultType, Type, GeoMesh>::New
|
||||
(
|
||||
tdf,
|
||||
"sqr(" + df.name() + ')',
|
||||
sqr(df.dimensions())
|
||||
tf1,
|
||||
"sqr(" + f1.name() + ')',
|
||||
sqr(f1.dimensions())
|
||||
);
|
||||
|
||||
sqr(tres.ref().field(), df.field());
|
||||
sqr(tres.ref().field(), f1.field());
|
||||
|
||||
tdf.clear();
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
|
||||
magSqr(const DimensionedField<Type, GeoMesh>& df)
|
||||
magSqr(const DimensionedField<Type, GeoMesh>& f1)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
auto tres =
|
||||
tmp<DimensionedField<magType, GeoMesh>>::New
|
||||
reuseTmpDimensionedField<resultType, Type, GeoMesh>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"magSqr(" + df.name() + ')',
|
||||
df.instance(),
|
||||
df.db()
|
||||
),
|
||||
df.mesh(),
|
||||
sqr(df.dimensions())
|
||||
f1,
|
||||
"magSqr(" + f1.name() + ')',
|
||||
sqr(f1.dimensions())
|
||||
);
|
||||
|
||||
magSqr(tres.ref().field(), df.field());
|
||||
magSqr(tres.ref().field(), f1.field());
|
||||
|
||||
return tres;
|
||||
}
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
|
||||
magSqr(const tmp<DimensionedField<Type, GeoMesh>>& tdf)
|
||||
magSqr(const tmp<DimensionedField<Type, GeoMesh>>& tf1)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
const DimensionedField<Type, GeoMesh>& df = tdf();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
auto tres =
|
||||
reuseTmpDimensionedField<magType, Type, GeoMesh>::New
|
||||
reuseTmpDimensionedField<resultType, Type, GeoMesh>::New
|
||||
(
|
||||
tdf,
|
||||
"magSqr(" + df.name() + ')',
|
||||
sqr(df.dimensions())
|
||||
tf1,
|
||||
"magSqr(" + f1.name() + ')',
|
||||
sqr(f1.dimensions())
|
||||
);
|
||||
|
||||
magSqr(tres.ref().field(), df.field());
|
||||
magSqr(tres.ref().field(), f1.field());
|
||||
|
||||
tdf.clear();
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
|
||||
mag(const DimensionedField<Type, GeoMesh>& df)
|
||||
mag(const DimensionedField<Type, GeoMesh>& f1)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
auto tres =
|
||||
tmp<DimensionedField<magType, GeoMesh>>::New
|
||||
reuseTmpDimensionedField<resultType, Type, GeoMesh>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"mag(" + df.name() + ')',
|
||||
df.instance(),
|
||||
df.db()
|
||||
),
|
||||
df.mesh(),
|
||||
df.dimensions()
|
||||
f1,
|
||||
"mag(" + f1.name() + ')',
|
||||
f1.dimensions()
|
||||
);
|
||||
|
||||
mag(tres.ref().field(), df.field());
|
||||
mag(tres.ref().field(), f1.field());
|
||||
|
||||
return tres;
|
||||
}
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
|
||||
mag(const tmp<DimensionedField<Type, GeoMesh>>& tdf)
|
||||
mag(const tmp<DimensionedField<Type, GeoMesh>>& tf1)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
const DimensionedField<Type, GeoMesh>& df = tdf();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
auto tres =
|
||||
reuseTmpDimensionedField<magType, Type, GeoMesh>::New
|
||||
reuseTmpDimensionedField<resultType, Type, GeoMesh>::New
|
||||
(
|
||||
tdf,
|
||||
"mag(" + df.name() + ')',
|
||||
df.dimensions()
|
||||
tf1,
|
||||
"mag(" + f1.name() + ')',
|
||||
f1.dimensions()
|
||||
);
|
||||
|
||||
mag(tres.ref().field(), df.field());
|
||||
mag(tres.ref().field(), f1.field());
|
||||
|
||||
tdf.clear();
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
@ -243,24 +223,19 @@ tmp
|
||||
typename DimensionedField<Type, GeoMesh>::cmptType, GeoMesh
|
||||
>
|
||||
>
|
||||
cmptAv(const DimensionedField<Type, GeoMesh>& df)
|
||||
cmptAv(const DimensionedField<Type, GeoMesh>& f1)
|
||||
{
|
||||
typedef typename DimensionedField<Type, GeoMesh>::cmptType cmptType;
|
||||
typedef typename DimensionedField<Type, GeoMesh>::cmptType resultType;
|
||||
|
||||
auto tres =
|
||||
tmp<DimensionedField<cmptType, GeoMesh>>::New
|
||||
reuseTmpDimensionedField<resultType, Type, GeoMesh>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"cmptAv(" + df.name() + ')',
|
||||
df.instance(),
|
||||
df.db()
|
||||
),
|
||||
df.mesh(),
|
||||
df.dimensions()
|
||||
f1,
|
||||
"cmptAv(" + f1.name() + ')',
|
||||
f1.dimensions()
|
||||
);
|
||||
|
||||
cmptAv(tres.ref().field(), df.field());
|
||||
cmptAv(tres.ref().field(), f1.field());
|
||||
|
||||
return tres;
|
||||
}
|
||||
@ -274,51 +249,51 @@ tmp
|
||||
typename DimensionedField<Type, GeoMesh>::cmptType, GeoMesh
|
||||
>
|
||||
>
|
||||
cmptAv(const tmp<DimensionedField<Type, GeoMesh>>& tdf)
|
||||
cmptAv(const tmp<DimensionedField<Type, GeoMesh>>& tf1)
|
||||
{
|
||||
typedef typename DimensionedField<Type, GeoMesh>::cmptType cmptType;
|
||||
typedef typename DimensionedField<Type, GeoMesh>::cmptType resultType;
|
||||
|
||||
const DimensionedField<Type, GeoMesh>& df = tdf();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
auto tres =
|
||||
reuseTmpDimensionedField<cmptType, Type, GeoMesh>::New
|
||||
reuseTmpDimensionedField<resultType, Type, GeoMesh>::New
|
||||
(
|
||||
tdf,
|
||||
"cmptAv(" + df.name() + ')',
|
||||
df.dimensions()
|
||||
tf1,
|
||||
"cmptAv(" + f1.name() + ')',
|
||||
f1.dimensions()
|
||||
);
|
||||
|
||||
cmptAv(tres.ref().field(), df.field());
|
||||
cmptAv(tres.ref().field(), f1.field());
|
||||
|
||||
tdf.clear();
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
|
||||
#define UNARY_REDUCTION_FUNCTION(returnType, func, dfunc) \
|
||||
#define UNARY_REDUCTION_FUNCTION(ReturnType, Func, gFunc) \
|
||||
\
|
||||
template<class Type, class GeoMesh> \
|
||||
dimensioned<returnType> func \
|
||||
dimensioned<ReturnType> Func \
|
||||
( \
|
||||
const DimensionedField<Type, GeoMesh>& df \
|
||||
const DimensionedField<Type, GeoMesh>& f1 \
|
||||
) \
|
||||
{ \
|
||||
return dimensioned<returnType> \
|
||||
return dimensioned<ReturnType> \
|
||||
( \
|
||||
#func "(" + df.name() + ')', \
|
||||
df.dimensions(), \
|
||||
dfunc(df.field()) \
|
||||
#Func "(" + f1.name() + ')', \
|
||||
f1.dimensions(), \
|
||||
gFunc(f1.field()) \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
template<class Type, class GeoMesh> \
|
||||
dimensioned<returnType> func \
|
||||
dimensioned<ReturnType> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tf1 \
|
||||
) \
|
||||
{ \
|
||||
dimensioned<returnType> res = func(tdf1()); \
|
||||
tdf1.clear(); \
|
||||
dimensioned<ReturnType> res = Func(tf1()); \
|
||||
tf1.clear(); \
|
||||
return res; \
|
||||
}
|
||||
|
||||
@ -344,10 +319,81 @@ BINARY_TYPE_FUNCTION(Type, Type, Type, min)
|
||||
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
|
||||
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
|
||||
|
||||
BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax<Type>, clip)
|
||||
|
||||
// ------------------------------------------------------------------------- //
|
||||
|
||||
// Clamp Methods
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
void clamp
|
||||
(
|
||||
DimensionedField<Type, GeoMesh>& result,
|
||||
const DimensionedField<Type, GeoMesh>& f1,
|
||||
const Foam::zero_one
|
||||
)
|
||||
{
|
||||
const MinMax<Type> range(Foam::zero_one{});
|
||||
|
||||
clamp(result.field(), f1.field(), range);
|
||||
result.oriented() = f1.oriented();
|
||||
}
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<Type, GeoMesh>>
|
||||
clamp
|
||||
(
|
||||
const DimensionedField<Type, GeoMesh>& f1,
|
||||
const Foam::zero_one
|
||||
)
|
||||
{
|
||||
auto tres =
|
||||
reuseTmpDimensionedField<Type, Type, GeoMesh>::New
|
||||
(
|
||||
f1,
|
||||
"clamp01(" + f1.name() + ')',
|
||||
f1.dimensions()
|
||||
);
|
||||
|
||||
clamp(tres.ref(), f1, Foam::zero_one{});
|
||||
|
||||
return tres;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<Type, GeoMesh>>
|
||||
clamp
|
||||
(
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tf1,
|
||||
const Foam::zero_one
|
||||
)
|
||||
{
|
||||
const auto& f1 = tf1();
|
||||
|
||||
auto tres =
|
||||
reuseTmpDimensionedField<Type, Type, GeoMesh>::New
|
||||
(
|
||||
tf1,
|
||||
"clamp01(" + f1.name() + ')',
|
||||
f1.dimensions()
|
||||
);
|
||||
|
||||
clamp(tres.field(), f1, Foam::zero_one{});
|
||||
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax<Type>, clamp)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
TERNARY_FUNCTION(Type, Type, Type, scalar, lerp)
|
||||
TERNARY_TYPE_FUNCTION_FFS(Type, Type, Type, scalar, lerp)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
UNARY_OPERATOR(Type, Type, -, negate, transform)
|
||||
|
||||
@ -363,32 +409,27 @@ BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define PRODUCT_OPERATOR(product, op, opFunc) \
|
||||
#define PRODUCT_OPERATOR(product, Op, OpFunc) \
|
||||
\
|
||||
template<class Type1, class Type2, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& df1, \
|
||||
const DimensionedField<Type2, GeoMesh>& df2 \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
typedef typename product<Type1, Type2>::type resultType; \
|
||||
\
|
||||
auto tres = \
|
||||
tmp<DimensionedField<productType, GeoMesh>>::New \
|
||||
reuseTmpDimensionedField<resultType, Type1, GeoMesh>::New \
|
||||
( \
|
||||
IOobject \
|
||||
( \
|
||||
'(' + df1.name() + #op + df2.name() + ')', \
|
||||
df1.instance(), \
|
||||
df1.db() \
|
||||
), \
|
||||
df1.mesh(), \
|
||||
df1.dimensions() op df2.dimensions() \
|
||||
f1, \
|
||||
'(' + f1.name() + #Op + f2.name() + ')', \
|
||||
(f1.dimensions() Op f2.dimensions()) \
|
||||
); \
|
||||
\
|
||||
Foam::opFunc(tres.ref().field(), df1.field(), df2.field()); \
|
||||
Foam::OpFunc(tres.ref().field(), f1.field(), f2.field()); \
|
||||
\
|
||||
return tres; \
|
||||
} \
|
||||
@ -396,113 +437,108 @@ operator op \
|
||||
\
|
||||
template<class Type1, class Type2, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& df1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
typedef typename product<Type1, Type2>::type resultType; \
|
||||
\
|
||||
const DimensionedField<Type2, GeoMesh>& df2 = tdf2(); \
|
||||
const auto& f2 = tf2(); \
|
||||
\
|
||||
auto tres = \
|
||||
reuseTmpDimensionedField<productType, Type2, GeoMesh>::New \
|
||||
reuseTmpDimensionedField<resultType, Type2, GeoMesh>::New \
|
||||
( \
|
||||
tdf2, \
|
||||
'(' + df1.name() + #op + df2.name() + ')', \
|
||||
df1.dimensions() op df2.dimensions() \
|
||||
tf2, \
|
||||
'(' + f1.name() + #Op + f2.name() + ')', \
|
||||
(f1.dimensions() Op f2.dimensions()) \
|
||||
); \
|
||||
\
|
||||
Foam::opFunc(tres.ref().field(), df1.field(), df2.field()); \
|
||||
Foam::OpFunc(tres.ref().field(), f1.field(), f2.field()); \
|
||||
\
|
||||
tdf2.clear(); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
\
|
||||
template<class Type1, class Type2, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
|
||||
const DimensionedField<Type2, GeoMesh>& df2 \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
typedef typename product<Type1, Type2>::type resultType; \
|
||||
\
|
||||
const DimensionedField<Type1, GeoMesh>& df1 = tdf1(); \
|
||||
const auto& f1 = tf1(); \
|
||||
\
|
||||
auto tres = \
|
||||
reuseTmpDimensionedField<productType, Type1, GeoMesh>::New \
|
||||
reuseTmpDimensionedField<resultType, Type1, GeoMesh>::New \
|
||||
( \
|
||||
tdf1, \
|
||||
'(' + df1.name() + #op + df2.name() + ')', \
|
||||
df1.dimensions() op df2.dimensions() \
|
||||
tf1, \
|
||||
'(' + f1.name() + #Op + f2.name() + ')', \
|
||||
(f1.dimensions() Op f2.dimensions()) \
|
||||
); \
|
||||
\
|
||||
Foam::opFunc(tres.ref().field(), df1.field(), df2.field()); \
|
||||
Foam::OpFunc(tres.ref().field(), f1.field(), f2.field()); \
|
||||
\
|
||||
tdf1.clear(); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
\
|
||||
template<class Type1, class Type2, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
typedef typename product<Type1, Type2>::type resultType; \
|
||||
\
|
||||
const DimensionedField<Type1, GeoMesh>& df1 = tdf1(); \
|
||||
const DimensionedField<Type2, GeoMesh>& df2 = tdf2(); \
|
||||
const auto& f1 = tf1(); \
|
||||
const auto& f2 = tf2(); \
|
||||
\
|
||||
auto tres = \
|
||||
reuseTmpTmpDimensionedField \
|
||||
<productType, Type1, Type1, Type2, GeoMesh>::New \
|
||||
<resultType, Type1, Type1, Type2, GeoMesh>::New \
|
||||
( \
|
||||
tdf1, \
|
||||
tdf2, \
|
||||
'(' + df1.name() + #op + df2.name() + ')', \
|
||||
df1.dimensions() op df2.dimensions() \
|
||||
tf1, \
|
||||
tf2, \
|
||||
'(' + f1.name() + #Op + f2.name() + ')', \
|
||||
(f1.dimensions() Op f2.dimensions()) \
|
||||
); \
|
||||
\
|
||||
Foam::opFunc(tres.ref().field(), df1.field(), df2.field()); \
|
||||
Foam::OpFunc(tres.ref().field(), f1.field(), f2.field()); \
|
||||
\
|
||||
tdf1.clear(); \
|
||||
tdf2.clear(); \
|
||||
tf1.clear(); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
\
|
||||
template<class Form, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const DimensionedField<Type, GeoMesh>& df1, \
|
||||
const DimensionedField<Type, GeoMesh>& f1, \
|
||||
const dimensioned<Form>& dvs \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type, Form>::type productType; \
|
||||
typedef typename product<Type, Form>::type resultType; \
|
||||
\
|
||||
auto tres = \
|
||||
tmp<DimensionedField<productType, GeoMesh>>::New \
|
||||
reuseTmpDimensionedField<resultType, Type, GeoMesh>::New \
|
||||
( \
|
||||
IOobject \
|
||||
( \
|
||||
'(' + df1.name() + #op + dvs.name() + ')', \
|
||||
df1.instance(), \
|
||||
df1.db() \
|
||||
), \
|
||||
df1.mesh(), \
|
||||
df1.dimensions() op dvs.dimensions() \
|
||||
f1, \
|
||||
'(' + f1.name() + #Op + dvs.name() + ')', \
|
||||
(f1.dimensions() Op dvs.dimensions()) \
|
||||
); \
|
||||
\
|
||||
Foam::opFunc(tres.ref().field(), df1.field(), dvs.value()); \
|
||||
Foam::OpFunc(tres.ref().field(), f1.field(), dvs.value()); \
|
||||
\
|
||||
return tres; \
|
||||
} \
|
||||
@ -510,79 +546,74 @@ operator op \
|
||||
\
|
||||
template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const DimensionedField<Type, GeoMesh>& df1, \
|
||||
const DimensionedField<Type, GeoMesh>& f1, \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs \
|
||||
) \
|
||||
{ \
|
||||
return df1 op dimensioned<Form>(static_cast<const Form&>(vs)); \
|
||||
return f1 Op dimensioned<Form>(static_cast<const Form&>(vs)); \
|
||||
} \
|
||||
\
|
||||
\
|
||||
template<class Form, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf1, \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tf1, \
|
||||
const dimensioned<Form>& dvs \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type, Form>::type productType; \
|
||||
typedef typename product<Type, Form>::type resultType; \
|
||||
\
|
||||
const DimensionedField<Type, GeoMesh>& df1 = tdf1(); \
|
||||
const auto& f1 = tf1(); \
|
||||
\
|
||||
auto tres = \
|
||||
reuseTmpDimensionedField<productType, Type, GeoMesh>::New \
|
||||
reuseTmpDimensionedField<resultType, Type, GeoMesh>::New \
|
||||
( \
|
||||
tdf1, \
|
||||
'(' + df1.name() + #op + dvs.name() + ')', \
|
||||
df1.dimensions() op dvs.dimensions() \
|
||||
tf1, \
|
||||
'(' + f1.name() + #Op + dvs.name() + ')', \
|
||||
(f1.dimensions() Op dvs.dimensions()) \
|
||||
); \
|
||||
\
|
||||
Foam::opFunc(tres.ref().field(), df1.field(), dvs.value()); \
|
||||
Foam::OpFunc(tres.ref().field(), f1.field(), dvs.value()); \
|
||||
\
|
||||
tdf1.clear(); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
\
|
||||
template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf1, \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tf1, \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs \
|
||||
) \
|
||||
{ \
|
||||
return tdf1 op dimensioned<Form>(static_cast<const Form&>(vs)); \
|
||||
return tf1 Op dimensioned<Form>(static_cast<const Form&>(vs)); \
|
||||
} \
|
||||
\
|
||||
\
|
||||
template<class Form, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const dimensioned<Form>& dvs, \
|
||||
const DimensionedField<Type, GeoMesh>& df1 \
|
||||
const DimensionedField<Type, GeoMesh>& f2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Form, Type>::type productType; \
|
||||
typedef typename product<Form, Type>::type resultType; \
|
||||
\
|
||||
auto tres = \
|
||||
tmp<DimensionedField<productType, GeoMesh>>::New \
|
||||
reuseTmpDimensionedField<resultType, Type, GeoMesh>::New \
|
||||
( \
|
||||
IOobject \
|
||||
( \
|
||||
'(' + dvs.name() + #op + df1.name() + ')', \
|
||||
df1.instance(), \
|
||||
df1.db() \
|
||||
), \
|
||||
df1.mesh(), \
|
||||
dvs.dimensions() op df1.dimensions() \
|
||||
f2, \
|
||||
'(' + dvs.name() + #Op + f2.name() + ')', \
|
||||
(dvs.dimensions() Op f2.dimensions()) \
|
||||
); \
|
||||
\
|
||||
Foam::opFunc(tres.ref().field(), dvs.value(), df1.field()); \
|
||||
Foam::OpFunc(tres.ref().field(), dvs.value(), f2.field()); \
|
||||
\
|
||||
return tres; \
|
||||
} \
|
||||
@ -590,52 +621,52 @@ operator op \
|
||||
\
|
||||
template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs, \
|
||||
const DimensionedField<Type, GeoMesh>& df1 \
|
||||
const DimensionedField<Type, GeoMesh>& f2 \
|
||||
) \
|
||||
{ \
|
||||
return dimensioned<Form>(static_cast<const Form&>(vs)) op df1; \
|
||||
return dimensioned<Form>(static_cast<const Form&>(vs)) Op f2; \
|
||||
} \
|
||||
\
|
||||
\
|
||||
template<class Form, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const dimensioned<Form>& dvs, \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tf2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Form, Type>::type productType; \
|
||||
typedef typename product<Form, Type>::type resultType; \
|
||||
\
|
||||
const DimensionedField<Type, GeoMesh>& df1 = tdf1(); \
|
||||
const auto& f2 = tf2(); \
|
||||
\
|
||||
auto tres = \
|
||||
reuseTmpDimensionedField<productType, Type, GeoMesh>::New \
|
||||
reuseTmpDimensionedField<resultType, Type, GeoMesh>::New \
|
||||
( \
|
||||
tdf1, \
|
||||
'(' + dvs.name() + #op + df1.name() + ')', \
|
||||
dvs.dimensions() op df1.dimensions() \
|
||||
tf2, \
|
||||
'(' + dvs.name() + #Op + f2.name() + ')', \
|
||||
(dvs.dimensions() Op f2.dimensions()) \
|
||||
); \
|
||||
\
|
||||
Foam::opFunc(tres.ref().field(), dvs.value(), df1.field()); \
|
||||
Foam::OpFunc(tres.ref().field(), dvs.value(), f2.field()); \
|
||||
\
|
||||
tdf1.clear(); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
\
|
||||
template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs, \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tf2 \
|
||||
) \
|
||||
{ \
|
||||
return dimensioned<Form>(static_cast<const Form&>(vs)) op tdf1; \
|
||||
return dimensioned<Form>(static_cast<const Form&>(vs)) Op tf2; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,13 +36,13 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type, class GeoMesh, direction r>
|
||||
tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh>>
|
||||
pow
|
||||
(
|
||||
const DimensionedField<Type, GeoMesh>& df,
|
||||
const DimensionedField<Type, GeoMesh>& f1,
|
||||
typename powProduct<Type, r>::type
|
||||
);
|
||||
|
||||
@ -50,33 +50,33 @@ template<class Type, class GeoMesh, direction r>
|
||||
tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh>>
|
||||
pow
|
||||
(
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf,
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tf1,
|
||||
typename powProduct<Type, r>::type
|
||||
);
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh>>
|
||||
sqr(const DimensionedField<Type, GeoMesh>& df);
|
||||
sqr(const DimensionedField<Type, GeoMesh>& f1);
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh>>
|
||||
sqr(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
|
||||
sqr(const tmp<DimensionedField<Type, GeoMesh>>& tf1);
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
|
||||
magSqr(const DimensionedField<Type, GeoMesh>& df);
|
||||
magSqr(const DimensionedField<Type, GeoMesh>& f1);
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
|
||||
magSqr(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
|
||||
magSqr(const tmp<DimensionedField<Type, GeoMesh>>& tf1);
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
|
||||
mag(const DimensionedField<Type, GeoMesh>& df);
|
||||
mag(const DimensionedField<Type, GeoMesh>& f1);
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
|
||||
mag(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
|
||||
mag(const tmp<DimensionedField<Type, GeoMesh>>& tf1);
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp
|
||||
@ -87,7 +87,7 @@ tmp
|
||||
GeoMesh
|
||||
>
|
||||
>
|
||||
cmptAv(const DimensionedField<Type, GeoMesh>& df);
|
||||
cmptAv(const DimensionedField<Type, GeoMesh>& f1);
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp
|
||||
@ -98,21 +98,21 @@ tmp
|
||||
GeoMesh
|
||||
>
|
||||
>
|
||||
cmptAv(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
|
||||
cmptAv(const tmp<DimensionedField<Type, GeoMesh>>& tf1);
|
||||
|
||||
|
||||
// Forward to FieldFunction via dfunc()
|
||||
#define UNARY_REDUCTION_FUNCTION(returnType, func, dfunc) \
|
||||
// Forward to FieldFunction via gFunc()
|
||||
#define UNARY_REDUCTION_FUNCTION(ReturnType, Func, gFunc) \
|
||||
\
|
||||
template<class Type, class GeoMesh> \
|
||||
dimensioned<returnType> func \
|
||||
dimensioned<ReturnType> Func \
|
||||
( \
|
||||
const DimensionedField<Type, GeoMesh>& df \
|
||||
const DimensionedField<Type, GeoMesh>& f1 \
|
||||
); \
|
||||
template<class Type, class GeoMesh> \
|
||||
dimensioned<returnType> func \
|
||||
dimensioned<ReturnType> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tf1 \
|
||||
);
|
||||
|
||||
UNARY_REDUCTION_FUNCTION(Type, max, gMax)
|
||||
@ -137,10 +137,45 @@ BINARY_TYPE_FUNCTION(Type, Type, Type, min)
|
||||
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
|
||||
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
|
||||
|
||||
BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax<Type>, clip)
|
||||
|
||||
// ------------------------------------------------------------------------- //
|
||||
|
||||
// Clamp Methods
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
void clamp
|
||||
(
|
||||
DimensionedField<Type, GeoMesh>& result,
|
||||
const DimensionedField<Type, GeoMesh>& f1,
|
||||
const Foam::zero_one
|
||||
);
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<Type, GeoMesh>>
|
||||
clamp
|
||||
(
|
||||
const DimensionedField<Type, GeoMesh>& f1,
|
||||
const Foam::zero_one
|
||||
);
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp<DimensionedField<Type, GeoMesh>>
|
||||
clamp
|
||||
(
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tf1,
|
||||
const Foam::zero_one
|
||||
);
|
||||
|
||||
BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax<Type>, clamp)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
TERNARY_FUNCTION(Type, Type, Type, scalar, lerp)
|
||||
TERNARY_TYPE_FUNCTION_FFS(Type, Type, Type, scalar, lerp)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
UNARY_OPERATOR(Type, Type, -, negate, transform)
|
||||
|
||||
@ -156,102 +191,102 @@ BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define PRODUCT_OPERATOR(product, op, opFunc) \
|
||||
#define PRODUCT_OPERATOR(product, Op, OpFunc) \
|
||||
\
|
||||
template<class Type1, class Type2, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& df1, \
|
||||
const DimensionedField<Type2, GeoMesh>& df2 \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
template<class Type1, class Type2, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& df1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
|
||||
); \
|
||||
\
|
||||
template<class Type1, class Type2, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
|
||||
const DimensionedField<Type2, GeoMesh>& df2 \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
template<class Type1, class Type2, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
|
||||
); \
|
||||
\
|
||||
template<class Form, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const DimensionedField<Type, GeoMesh>& df1, \
|
||||
const DimensionedField<Type, GeoMesh>& f1, \
|
||||
const dimensioned<Form>& dvs \
|
||||
); \
|
||||
\
|
||||
template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const DimensionedField<Type, GeoMesh>& df1, \
|
||||
const DimensionedField<Type, GeoMesh>& f1, \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs \
|
||||
); \
|
||||
\
|
||||
template<class Form, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf1, \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tf1, \
|
||||
const dimensioned<Form>& dvs \
|
||||
); \
|
||||
\
|
||||
template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf1, \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tf1, \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs \
|
||||
); \
|
||||
\
|
||||
template<class Form, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const dimensioned<Form>& dvs, \
|
||||
const DimensionedField<Type, GeoMesh>& df1 \
|
||||
const DimensionedField<Type, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs, \
|
||||
const DimensionedField<Type, GeoMesh>& df1 \
|
||||
const DimensionedField<Type, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
template<class Form, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const dimensioned<Form>& dvs, \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tf2 \
|
||||
); \
|
||||
\
|
||||
template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
|
||||
tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs, \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tf2 \
|
||||
);
|
||||
|
||||
PRODUCT_OPERATOR(typeOfSum, +, add)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,32 +31,46 @@ License
|
||||
#define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
void Func \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& df \
|
||||
DimensionedField<ReturnType, GeoMesh>& result, \
|
||||
const DimensionedField<Type1, GeoMesh>& f1 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1 \
|
||||
const DimensionedField<Type1, GeoMesh>& f1 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1 \
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define UNARY_OPERATOR(ReturnType, Type1, Op, opFunc, Dfunc) \
|
||||
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
void OpFunc \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& df1 \
|
||||
DimensionedField<ReturnType, GeoMesh>& result, \
|
||||
const DimensionedField<Type1, GeoMesh>& f1 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1 \
|
||||
const DimensionedField<Type1, GeoMesh>& f1 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1 \
|
||||
);
|
||||
|
||||
|
||||
@ -64,31 +79,39 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
void Func \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& df1, \
|
||||
const DimensionedField<Type2, GeoMesh>& df2 \
|
||||
DimensionedField<ReturnType, GeoMesh>& result, \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& df1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
|
||||
const DimensionedField<Type2, GeoMesh>& df2 \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
|
||||
);
|
||||
|
||||
|
||||
@ -97,62 +120,78 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
#define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
void Func \
|
||||
( \
|
||||
DimensionedField<ReturnType, GeoMesh>& result, \
|
||||
const dimensioned<Type1>& dt1, \
|
||||
const DimensionedField<Type2, GeoMesh>& df2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const Type1& t1, \
|
||||
const DimensionedField<Type2, GeoMesh>& df2 \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const dimensioned<Type1>& dt1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const Type1& t1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
|
||||
const Type1& s1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const dimensioned<Type1>& dt1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const Type1& s1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
|
||||
);
|
||||
|
||||
|
||||
#define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
void Func \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& df1, \
|
||||
DimensionedField<ReturnType, GeoMesh>& result, \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const dimensioned<Type2>& dt2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& df1, \
|
||||
const Type2& t2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const dimensioned<Type2>& dt2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf2, \
|
||||
const Type2& t2 \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const Type2& s2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const dimensioned<Type2>& dt2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const Type2& s2 \
|
||||
);
|
||||
|
||||
|
||||
@ -166,31 +205,39 @@ tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
void OpFunc \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& df1, \
|
||||
const DimensionedField<Type2, GeoMesh>& df2 \
|
||||
DimensionedField<ReturnType, GeoMesh>& result, \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& df1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
|
||||
const DimensionedField<Type2, GeoMesh>& df2 \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
|
||||
);
|
||||
|
||||
|
||||
@ -199,62 +246,78 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
void OpFunc \
|
||||
( \
|
||||
DimensionedField<ReturnType, GeoMesh>& result, \
|
||||
const dimensioned<Type1>& dt1, \
|
||||
const DimensionedField<Type2, GeoMesh>& df2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const Type1& t1, \
|
||||
const DimensionedField<Type2, GeoMesh>& df2 \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const dimensioned<Type1>& dt1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const Type1& t1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
|
||||
const Type1& s1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const dimensioned<Type1>& dt1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const Type1& s1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
|
||||
);
|
||||
|
||||
|
||||
#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
void OpFunc \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& df1, \
|
||||
DimensionedField<ReturnType, GeoMesh>& result, \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const dimensioned<Type2>& dt2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& df1, \
|
||||
const Type2& t2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const dimensioned<Type2>& dt2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
|
||||
const Type2& t2 \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const Type2& s2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const dimensioned<Type2>& dt2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const Type2& s2 \
|
||||
);
|
||||
|
||||
|
||||
@ -263,4 +326,158 @@ tmp<DimensionedField<ReturnType, GeoMesh>> operator Op \
|
||||
BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define TERNARY_FUNCTION(ReturnType, Type1, Type2, Type3, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
DimensionedField<ReturnType, GeoMesh>& result, \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2, \
|
||||
const DimensionedField<Type3, GeoMesh>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2, \
|
||||
const DimensionedField<Type3, GeoMesh>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2, \
|
||||
const DimensionedField<Type3, GeoMesh>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2, \
|
||||
const DimensionedField<Type3, GeoMesh>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2, \
|
||||
const tmp<DimensionedField<Type3, GeoMesh>>& tf3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2, \
|
||||
const DimensionedField<Type3, GeoMesh>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2, \
|
||||
const tmp<DimensionedField<Type3, GeoMesh>>& tf3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2, \
|
||||
const tmp<DimensionedField<Type3, GeoMesh>>& tf3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2, \
|
||||
const tmp<DimensionedField<Type3, GeoMesh>>& tf3 \
|
||||
);
|
||||
|
||||
|
||||
#define TERNARY_TYPE_FUNCTION_FFS(ReturnType, Type1, Type2, Type3, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
DimensionedField<ReturnType, GeoMesh>& result, \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2, \
|
||||
const dimensioned<Type3>& dt3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2, \
|
||||
const dimensioned<Type3>& dt3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2, \
|
||||
const Type3& s3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2, \
|
||||
const dimensioned<Type3>& dt3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const DimensionedField<Type2, GeoMesh>& f2, \
|
||||
const Type3& s3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2, \
|
||||
const dimensioned<Type3>& dt3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const DimensionedField<Type1, GeoMesh>& f1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2, \
|
||||
const Type3& s3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2, \
|
||||
const dimensioned<Type3>& dt3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<DimensionedField<ReturnType, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2, \
|
||||
const Type3& s3 \
|
||||
);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,28 +35,51 @@ namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// One-parameter versions
|
||||
|
||||
template<class TypeR, class Type1, class GeoMesh>
|
||||
struct reuseTmpDimensionedField
|
||||
{
|
||||
//- Pass-through to New DimensionedField
|
||||
static tmp<DimensionedField<TypeR, GeoMesh>> New
|
||||
(
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1,
|
||||
const DimensionedField<Type1, GeoMesh>& f1,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions
|
||||
)
|
||||
{
|
||||
const auto& df1 = tdf1();
|
||||
return tmp<DimensionedField<TypeR, GeoMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
f1.instance(),
|
||||
f1.db()
|
||||
),
|
||||
f1.mesh(),
|
||||
dimensions
|
||||
);
|
||||
}
|
||||
|
||||
//- Dissimilar types: return new field
|
||||
static tmp<DimensionedField<TypeR, GeoMesh>> New
|
||||
(
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions
|
||||
)
|
||||
{
|
||||
const auto& f1 = tf1();
|
||||
|
||||
return tmp<DimensionedField<TypeR, GeoMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
df1.instance(),
|
||||
df1.db()
|
||||
f1.instance(),
|
||||
f1.db()
|
||||
),
|
||||
df1.mesh(),
|
||||
f1.mesh(),
|
||||
dimensions
|
||||
);
|
||||
}
|
||||
@ -70,38 +93,38 @@ struct reuseTmpDimensionedField<TypeR, TypeR, GeoMesh>
|
||||
//- for identical input and output types
|
||||
static tmp<DimensionedField<TypeR, GeoMesh>> New
|
||||
(
|
||||
const tmp<DimensionedField<TypeR, GeoMesh>>& tdf1,
|
||||
const tmp<DimensionedField<TypeR, GeoMesh>>& tf1,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions,
|
||||
const bool initCopy = false
|
||||
)
|
||||
{
|
||||
if (tdf1.movable())
|
||||
if (tf1.movable())
|
||||
{
|
||||
auto& df1 = tdf1.constCast();
|
||||
auto& f1 = tf1.constCast();
|
||||
|
||||
df1.rename(name);
|
||||
df1.dimensions().reset(dimensions);
|
||||
return tdf1;
|
||||
f1.rename(name);
|
||||
f1.dimensions().reset(dimensions);
|
||||
return tf1;
|
||||
}
|
||||
|
||||
const auto& df1 = tdf1();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
auto tresult = tmp<DimensionedField<TypeR, GeoMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
df1.instance(),
|
||||
df1.db()
|
||||
f1.instance(),
|
||||
f1.db()
|
||||
),
|
||||
df1.mesh(),
|
||||
f1.mesh(),
|
||||
dimensions
|
||||
);
|
||||
|
||||
if (initCopy)
|
||||
{
|
||||
tresult.ref().field() = tdf1().field();
|
||||
tresult.ref().field() = tf1().field();
|
||||
}
|
||||
|
||||
return tresult;
|
||||
@ -113,7 +136,7 @@ struct reuseTmpDimensionedField<TypeR, TypeR, GeoMesh>
|
||||
template<class TypeR, class GeoMesh>
|
||||
tmp<DimensionedField<TypeR, GeoMesh>> New
|
||||
(
|
||||
const tmp<DimensionedField<TypeR, GeoMesh>>& tdf1,
|
||||
const tmp<DimensionedField<TypeR, GeoMesh>>& tf1,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions,
|
||||
const bool initCopy = false
|
||||
@ -121,7 +144,7 @@ tmp<DimensionedField<TypeR, GeoMesh>> New
|
||||
{
|
||||
return reuseTmpDimensionedField<TypeR, TypeR, GeoMesh>::New
|
||||
(
|
||||
tdf1,
|
||||
tf1,
|
||||
name,
|
||||
dimensions,
|
||||
initCopy
|
||||
@ -134,23 +157,23 @@ struct reuseTmpTmpDimensionedField
|
||||
{
|
||||
static tmp<DimensionedField<TypeR, GeoMesh>> New
|
||||
(
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1,
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tdf2,
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1,
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions
|
||||
)
|
||||
{
|
||||
const auto& df1 = tdf1();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
return tmp<DimensionedField<TypeR, GeoMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
df1.instance(),
|
||||
df1.db()
|
||||
f1.instance(),
|
||||
f1.db()
|
||||
),
|
||||
df1.mesh(),
|
||||
f1.mesh(),
|
||||
dimensions
|
||||
);
|
||||
}
|
||||
@ -162,32 +185,32 @@ struct reuseTmpTmpDimensionedField<TypeR, Type1, Type12, TypeR, GeoMesh>
|
||||
{
|
||||
static tmp<DimensionedField<TypeR, GeoMesh>> New
|
||||
(
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tdf1,
|
||||
const tmp<DimensionedField<TypeR, GeoMesh>>& tdf2,
|
||||
const tmp<DimensionedField<Type1, GeoMesh>>& tf1,
|
||||
const tmp<DimensionedField<TypeR, GeoMesh>>& tf2,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions
|
||||
)
|
||||
{
|
||||
if (tdf2.movable())
|
||||
if (tf2.movable())
|
||||
{
|
||||
auto& df2 = tdf2.constCast();
|
||||
auto& f2 = tf2.constCast();
|
||||
|
||||
df2.rename(name);
|
||||
df2.dimensions().reset(dimensions);
|
||||
return tdf2;
|
||||
f2.rename(name);
|
||||
f2.dimensions().reset(dimensions);
|
||||
return tf2;
|
||||
}
|
||||
|
||||
const auto& df1 = tdf1();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
return tmp<DimensionedField<TypeR, GeoMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
df1.instance(),
|
||||
df1.db()
|
||||
f1.instance(),
|
||||
f1.db()
|
||||
),
|
||||
df1.mesh(),
|
||||
f1.mesh(),
|
||||
dimensions
|
||||
);
|
||||
}
|
||||
@ -199,32 +222,32 @@ struct reuseTmpTmpDimensionedField<TypeR, TypeR, TypeR, Type2, GeoMesh>
|
||||
{
|
||||
static tmp<DimensionedField<TypeR, GeoMesh>> New
|
||||
(
|
||||
const tmp<DimensionedField<TypeR, GeoMesh>>& tdf1,
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tdf2,
|
||||
const tmp<DimensionedField<TypeR, GeoMesh>>& tf1,
|
||||
const tmp<DimensionedField<Type2, GeoMesh>>& tf2,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions
|
||||
)
|
||||
{
|
||||
if (tdf1.movable())
|
||||
if (tf1.movable())
|
||||
{
|
||||
auto& df1 = tdf1.constCast();
|
||||
auto& f1 = tf1.constCast();
|
||||
|
||||
df1.rename(name);
|
||||
df1.dimensions().reset(dimensions);
|
||||
return tdf1;
|
||||
f1.rename(name);
|
||||
f1.dimensions().reset(dimensions);
|
||||
return tf1;
|
||||
}
|
||||
|
||||
const auto& df1 = tdf1();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
return tmp<DimensionedField<TypeR, GeoMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
df1.instance(),
|
||||
df1.db()
|
||||
f1.instance(),
|
||||
f1.db()
|
||||
),
|
||||
df1.mesh(),
|
||||
f1.mesh(),
|
||||
dimensions
|
||||
);
|
||||
}
|
||||
@ -236,40 +259,40 @@ struct reuseTmpTmpDimensionedField<TypeR, TypeR, TypeR, TypeR, GeoMesh>
|
||||
{
|
||||
static tmp<DimensionedField<TypeR, GeoMesh>> New
|
||||
(
|
||||
const tmp<DimensionedField<TypeR, GeoMesh>>& tdf1,
|
||||
const tmp<DimensionedField<TypeR, GeoMesh>>& tdf2,
|
||||
const tmp<DimensionedField<TypeR, GeoMesh>>& tf1,
|
||||
const tmp<DimensionedField<TypeR, GeoMesh>>& tf2,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions
|
||||
)
|
||||
{
|
||||
if (tdf1.movable())
|
||||
if (tf1.movable())
|
||||
{
|
||||
auto& df1 = tdf1.constCast();
|
||||
auto& f1 = tf1.constCast();
|
||||
|
||||
df1.rename(name);
|
||||
df1.dimensions().reset(dimensions);
|
||||
return tdf1;
|
||||
f1.rename(name);
|
||||
f1.dimensions().reset(dimensions);
|
||||
return tf1;
|
||||
}
|
||||
if (tdf2.movable())
|
||||
if (tf2.movable())
|
||||
{
|
||||
auto& df2 = tdf2.constCast();
|
||||
auto& f2 = tf2.constCast();
|
||||
|
||||
df2.rename(name);
|
||||
df2.dimensions().reset(dimensions);
|
||||
return tdf2;
|
||||
f2.rename(name);
|
||||
f2.dimensions().reset(dimensions);
|
||||
return tf2;
|
||||
}
|
||||
|
||||
const auto& df1 = tdf1();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
return tmp<DimensionedField<TypeR, GeoMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
df1.instance(),
|
||||
df1.db()
|
||||
f1.instance(),
|
||||
f1.db()
|
||||
),
|
||||
df1.mesh(),
|
||||
f1.mesh(),
|
||||
dimensions
|
||||
);
|
||||
}
|
||||
|
||||
@ -282,39 +282,6 @@ void FieldField<Field, Type>::replace
|
||||
}
|
||||
|
||||
|
||||
template<template<class> class Field, class Type>
|
||||
void FieldField<Field, Type>::clamp
|
||||
(
|
||||
const Type& lower,
|
||||
const Type& upper
|
||||
)
|
||||
{
|
||||
if (lower < upper)
|
||||
{
|
||||
for (auto& ff : *this)
|
||||
{
|
||||
ff.clamp(lower, upper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<template<class> class Field, class Type>
|
||||
void FieldField<Field, Type>::clamp
|
||||
(
|
||||
const MinMax<Type>& range
|
||||
)
|
||||
{
|
||||
if (range.min() < range.max())
|
||||
{
|
||||
for (auto& ff : *this)
|
||||
{
|
||||
ff.clamp(range.min(), range.max());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<template<class> class Field, class Type>
|
||||
void FieldField<Field, Type>::clamp_min
|
||||
(
|
||||
@ -341,6 +308,37 @@ void FieldField<Field, Type>::clamp_max
|
||||
}
|
||||
|
||||
|
||||
template<template<class> class Field, class Type>
|
||||
void FieldField<Field, Type>::clamp_range
|
||||
(
|
||||
const Type& lower,
|
||||
const Type& upper
|
||||
)
|
||||
{
|
||||
// Note: no checks for bad/invalid clamping ranges
|
||||
|
||||
for (auto& ff : *this)
|
||||
{
|
||||
ff.clamp_range(lower, upper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<template<class> class Field, class Type>
|
||||
void FieldField<Field, Type>::clamp_range
|
||||
(
|
||||
const MinMax<Type>& range
|
||||
)
|
||||
{
|
||||
// Note: no checks for bad/invalid clamping ranges
|
||||
|
||||
for (auto& ff : *this)
|
||||
{
|
||||
ff.clamp_range(range.min(), range.max());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<template<class> class Field, class Type>
|
||||
tmp<FieldField<Field, Type>> FieldField<Field, Type>::T() const
|
||||
{
|
||||
|
||||
@ -149,20 +149,20 @@ public:
|
||||
//- Replace a component field of the field
|
||||
void replace(const direction, const cmptType&);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// A no-op for an invalid range.
|
||||
void clamp(const Type& lower, const Type& upper);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// A no-op for an invalid range.
|
||||
void clamp(const MinMax<Type>& range);
|
||||
|
||||
//- Impose lower (floor) clamp on the field values (in-place)
|
||||
void clamp_min(const Type& lower);
|
||||
|
||||
//- Impose upper (ceiling) clamp on the field values (in-place)
|
||||
void clamp_max(const Type& upper);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// Does not check if range is valid or not.
|
||||
void clamp_range(const Type& lower, const Type& upper);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// Does not check if range is valid or not.
|
||||
void clamp_range(const MinMax<Type>& range);
|
||||
|
||||
//- Return the field transpose (only defined for second rank tensors)
|
||||
tmp<FieldField<Field, Type>> T() const;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -90,12 +90,9 @@ pow
|
||||
const FieldField<Field, Type>& f, typename powProduct<Type, r>::type
|
||||
)
|
||||
{
|
||||
typedef typename powProduct<Type, r>::type powProductType;
|
||||
typedef typename powProduct<Type, r>::type resultType;
|
||||
|
||||
auto tres
|
||||
(
|
||||
FieldField<Field, powProductType>::NewCalculatedType(f)
|
||||
);
|
||||
auto tres = FieldField<Field, resultType>::NewCalculatedType(f);
|
||||
|
||||
pow<Type, r>(tres.ref(), f);
|
||||
return tres;
|
||||
@ -108,12 +105,9 @@ pow
|
||||
const tmp<FieldField<Field, Type>>& tf, typename powProduct<Type, r>::type
|
||||
)
|
||||
{
|
||||
typedef typename powProduct<Type, r>::type powProductType;
|
||||
typedef typename powProduct<Type, r>::type resultType;
|
||||
|
||||
auto tres
|
||||
(
|
||||
reuseTmpFieldField<Field, powProductType, Type>::New(tf)
|
||||
);
|
||||
auto tres = reuseTmpFieldField<Field, resultType, Type>::New(tf);
|
||||
|
||||
pow<Type, r>(tres.ref(), tf());
|
||||
tf.clear();
|
||||
@ -140,11 +134,10 @@ template<template<class> class Field, class Type>
|
||||
tmp<FieldField<Field, typename outerProduct<Type, Type>::type>>
|
||||
sqr(const FieldField<Field, Type>& f)
|
||||
{
|
||||
typedef typename outerProduct<Type, Type>::type outerProductType;
|
||||
tmp<FieldField<Field, outerProductType>> tres
|
||||
(
|
||||
FieldField<Field, outerProductType>::NewCalculatedType(f)
|
||||
);
|
||||
typedef typename outerProduct<Type, Type>::type resultType;
|
||||
|
||||
auto tres = FieldField<Field, resultType>::NewCalculatedType(f);
|
||||
|
||||
sqr(tres.ref(), f);
|
||||
return tres;
|
||||
}
|
||||
@ -153,12 +146,9 @@ template<template<class> class Field, class Type>
|
||||
tmp<FieldField<Field, typename outerProduct<Type, Type>::type>>
|
||||
sqr(const tmp<FieldField<Field, Type>>& tf)
|
||||
{
|
||||
typedef typename outerProduct<Type, Type>::type outerProductType;
|
||||
typedef typename outerProduct<Type, Type>::type resultType;
|
||||
|
||||
auto tres
|
||||
(
|
||||
reuseTmpFieldField<Field, outerProductType, Type>::New(tf)
|
||||
);
|
||||
auto tres = reuseTmpFieldField<Field, resultType, Type>::New(tf);
|
||||
|
||||
sqr(tres.ref(), tf());
|
||||
tf.clear();
|
||||
@ -185,12 +175,9 @@ template<template<class> class Field, class Type>
|
||||
tmp<FieldField<Field, typename typeOfMag<Type>::type>>
|
||||
magSqr(const FieldField<Field, Type>& f)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
auto tres
|
||||
(
|
||||
FieldField<Field, magType>::NewCalculatedType(f)
|
||||
);
|
||||
auto tres = FieldField<Field, resultType>::NewCalculatedType(f);
|
||||
|
||||
magSqr(tres.ref(), f);
|
||||
return tres;
|
||||
@ -200,12 +187,9 @@ template<template<class> class Field, class Type>
|
||||
tmp<FieldField<Field, typename typeOfMag<Type>::type>>
|
||||
magSqr(const tmp<FieldField<Field, Type>>& tf)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
auto tres
|
||||
(
|
||||
reuseTmpFieldField<Field, magType, Type>::New(tf)
|
||||
);
|
||||
auto tres = reuseTmpFieldField<Field, resultType, Type>::New(tf);
|
||||
|
||||
magSqr(tres.ref(), tf());
|
||||
tf.clear();
|
||||
@ -232,12 +216,9 @@ template<template<class> class Field, class Type>
|
||||
tmp<FieldField<Field, typename typeOfMag<Type>::type>>
|
||||
mag(const FieldField<Field, Type>& f)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
auto tres
|
||||
(
|
||||
FieldField<Field, magType>::NewCalculatedType(f)
|
||||
);
|
||||
auto tres = FieldField<Field, resultType>::NewCalculatedType(f);
|
||||
|
||||
mag(tres.ref(), f);
|
||||
return tres;
|
||||
@ -247,12 +228,9 @@ template<template<class> class Field, class Type>
|
||||
tmp<FieldField<Field, typename typeOfMag<Type>::type>>
|
||||
mag(const tmp<FieldField<Field, Type>>& tf)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
auto tres
|
||||
(
|
||||
reuseTmpFieldField<Field, magType, Type>::New(tf)
|
||||
);
|
||||
auto tres = reuseTmpFieldField<Field, resultType, Type>::New(tf);
|
||||
|
||||
mag(tres.ref(), tf());
|
||||
tf.clear();
|
||||
@ -281,12 +259,9 @@ tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>> cmptMax
|
||||
const FieldField<Field, Type>& f
|
||||
)
|
||||
{
|
||||
typedef typename FieldField<Field, Type>::cmptType cmptType;
|
||||
typedef typename FieldField<Field, Type>::cmptType resultType;
|
||||
|
||||
auto tres
|
||||
(
|
||||
FieldField<Field, cmptType>::NewCalculatedType(f)
|
||||
);
|
||||
auto tres = FieldField<Field, resultType>::NewCalculatedType(f);
|
||||
|
||||
cmptMax(tres.ref(), f);
|
||||
return tres;
|
||||
@ -298,12 +273,9 @@ tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>> cmptMax
|
||||
const tmp<FieldField<Field, Type>>& tf
|
||||
)
|
||||
{
|
||||
typedef typename FieldField<Field, Type>::cmptType cmptType;
|
||||
typedef typename FieldField<Field, Type>::cmptType resultType;
|
||||
|
||||
auto tres
|
||||
(
|
||||
reuseTmpFieldField<Field, cmptType, Type>::New(tf)
|
||||
);
|
||||
auto tres = reuseTmpFieldField<Field, resultType, Type>::New(tf);
|
||||
|
||||
cmptMax(tres.ref(), tf());
|
||||
tf.clear();
|
||||
@ -332,12 +304,9 @@ tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>> cmptMin
|
||||
const FieldField<Field, Type>& f
|
||||
)
|
||||
{
|
||||
typedef typename FieldField<Field, Type>::cmptType cmptType;
|
||||
typedef typename FieldField<Field, Type>::cmptType resultType;
|
||||
|
||||
auto tres
|
||||
(
|
||||
FieldField<Field, cmptType>::NewCalculatedType(f)
|
||||
);
|
||||
auto tres = FieldField<Field, resultType>::NewCalculatedType(f);
|
||||
|
||||
cmptMin(tres.ref(), f);
|
||||
return tres;
|
||||
@ -349,12 +318,9 @@ tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>> cmptMin
|
||||
const tmp<FieldField<Field, Type>>& tf
|
||||
)
|
||||
{
|
||||
typedef typename FieldField<Field, Type>::cmptType cmptType;
|
||||
typedef typename FieldField<Field, Type>::cmptType resultType;
|
||||
|
||||
auto tres
|
||||
(
|
||||
reuseTmpFieldField<Field, cmptType, Type>::New(tf)
|
||||
);
|
||||
auto tres = reuseTmpFieldField<Field, resultType, Type>::New(tf);
|
||||
|
||||
cmptMin(tres.ref(), tf());
|
||||
tf.clear();
|
||||
@ -383,12 +349,9 @@ tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>> cmptAv
|
||||
const FieldField<Field, Type>& f
|
||||
)
|
||||
{
|
||||
typedef typename FieldField<Field, Type>::cmptType cmptType;
|
||||
typedef typename FieldField<Field, Type>::cmptType resultType;
|
||||
|
||||
auto tres
|
||||
(
|
||||
FieldField<Field, cmptType>::NewCalculatedType(f)
|
||||
);
|
||||
auto tres = FieldField<Field, resultType>::NewCalculatedType(f);
|
||||
|
||||
cmptAv(tres.ref(), f);
|
||||
return tres;
|
||||
@ -400,12 +363,9 @@ tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>> cmptAv
|
||||
const tmp<FieldField<Field, Type>>& tf
|
||||
)
|
||||
{
|
||||
typedef typename FieldField<Field, Type>::cmptType cmptType;
|
||||
typedef typename FieldField<Field, Type>::cmptType resultType;
|
||||
|
||||
auto tres
|
||||
(
|
||||
reuseTmpFieldField<Field, cmptType, Type>::New(tf)
|
||||
);
|
||||
auto tres = reuseTmpFieldField<Field, resultType, Type>::New(tf);
|
||||
|
||||
cmptAv(tres.ref(), tf());
|
||||
tf.clear();
|
||||
@ -434,10 +394,7 @@ tmp<FieldField<Field, Type>> cmptMag
|
||||
const FieldField<Field, Type>& f
|
||||
)
|
||||
{
|
||||
auto tres
|
||||
(
|
||||
FieldField<Field, Type>::NewCalculatedType(f)
|
||||
);
|
||||
auto tres = FieldField<Field, Type>::NewCalculatedType(f);
|
||||
|
||||
cmptMag(tres.ref(), f);
|
||||
return tres;
|
||||
@ -456,12 +413,12 @@ tmp<FieldField<Field, Type>> cmptMag
|
||||
}
|
||||
|
||||
|
||||
#define TMP_UNARY_FUNCTION(returnType, func) \
|
||||
#define TMP_UNARY_FUNCTION(ReturnType, Func) \
|
||||
\
|
||||
template<template<class> class Field, class Type> \
|
||||
returnType func(const tmp<FieldField<Field, Type>>& tf1) \
|
||||
ReturnType Func(const tmp<FieldField<Field, Type>>& tf1) \
|
||||
{ \
|
||||
returnType res = func(tf1()); \
|
||||
ReturnType res = Func(tf1()); \
|
||||
tf1.clear(); \
|
||||
return res; \
|
||||
}
|
||||
@ -529,9 +486,9 @@ TMP_UNARY_FUNCTION(Type, sum)
|
||||
template<template<class> class Field, class Type>
|
||||
typename typeOfMag<Type>::type sumMag(const FieldField<Field, Type>& f)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
magType result = Zero;
|
||||
resultType result = Zero;
|
||||
|
||||
const label loopLen = (f).size();
|
||||
|
||||
@ -609,12 +566,12 @@ TMP_UNARY_FUNCTION(scalarMinMax, minMaxMag)
|
||||
|
||||
|
||||
// With reduction on ReturnType
|
||||
#define G_UNARY_FUNCTION(ReturnType, gFunc, func, rFunc) \
|
||||
#define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc) \
|
||||
\
|
||||
template<template<class> class Field, class Type> \
|
||||
ReturnType gFunc(const FieldField<Field, Type>& f) \
|
||||
{ \
|
||||
ReturnType res = func(f); \
|
||||
ReturnType res = Func(f); \
|
||||
reduce(res, rFunc##Op<ReturnType>()); \
|
||||
return res; \
|
||||
} \
|
||||
@ -653,7 +610,7 @@ Type gAverage(const FieldField<Field, Type>& f)
|
||||
}
|
||||
|
||||
WarningInFunction
|
||||
<< "empty fieldField, returning zero" << endl;
|
||||
<< "Empty FieldField, returning zero" << endl;
|
||||
|
||||
return Zero;
|
||||
}
|
||||
@ -673,10 +630,17 @@ BINARY_TYPE_FUNCTION(Type, Type, Type, min)
|
||||
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
|
||||
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
|
||||
|
||||
// Note: works with zero_one through implicit conversion to MinMax
|
||||
BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax<Type>, clamp)
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
TERNARY_FUNCTION(Type, Type, Type, scalar, lerp)
|
||||
TERNARY_TYPE_FUNCTION_FFS(Type, Type, Type, scalar, lerp)
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * */
|
||||
|
||||
UNARY_OPERATOR(Type, Type, -, negate)
|
||||
|
||||
@ -692,7 +656,7 @@ BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define PRODUCT_OPERATOR(product, op, opFunc) \
|
||||
#define PRODUCT_OPERATOR(product, Op, OpFunc) \
|
||||
\
|
||||
template \
|
||||
< \
|
||||
@ -701,7 +665,7 @@ template \
|
||||
class Type1, \
|
||||
class Type2 \
|
||||
> \
|
||||
void opFunc \
|
||||
void OpFunc \
|
||||
( \
|
||||
FieldField<Field1, typename product<Type1, Type2>::type>& f, \
|
||||
const FieldField<Field1, Type1>& f1, \
|
||||
@ -712,7 +676,7 @@ void opFunc \
|
||||
\
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
opFunc(f[i], f1[i], f2[i]); \
|
||||
OpFunc(f[i], f1[i], f2[i]); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
@ -724,35 +688,29 @@ template \
|
||||
class Type2 \
|
||||
> \
|
||||
tmp<FieldField<Field1, typename product<Type1, Type2>::type>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const FieldField<Field1, Type1>& f1, \
|
||||
const FieldField<Field2, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
tmp<FieldField<Field1, productType>> tres \
|
||||
( \
|
||||
FieldField<Field1, productType>::NewCalculatedType(f1) \
|
||||
); \
|
||||
opFunc(tres.ref(), f1, f2); \
|
||||
typedef typename product<Type1, Type2>::type resultType; \
|
||||
auto tres = FieldField<Field1, resultType>::NewCalculatedType(f1); \
|
||||
OpFunc(tres.ref(), f1, f2); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
template<template<class> class Field, class Type1, class Type2> \
|
||||
tmp<FieldField<Field, typename product<Type1, Type2>::type>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
tmp<FieldField<Field, productType>> tres \
|
||||
( \
|
||||
reuseTmpFieldField<Field, productType, Type2>::New(tf2) \
|
||||
); \
|
||||
opFunc(tres.ref(), f1, tf2()); \
|
||||
typedef typename product<Type1, Type2>::type resultType; \
|
||||
auto tres = reuseTmpFieldField<Field, resultType, Type2>::New(tf2); \
|
||||
OpFunc(tres.ref(), f1, tf2()); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
@ -765,18 +723,15 @@ template \
|
||||
class Type2 \
|
||||
> \
|
||||
tmp<FieldField<Field, typename product<Type1, Type2>::type>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const FieldField<Field1, Type1>& f1, \
|
||||
const tmp<FieldField<Field2, Type2>>& tf2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
tmp<FieldField<Field1, productType>> tres \
|
||||
( \
|
||||
FieldField<Field1, productType>::NewCalculatedType(f1) \
|
||||
); \
|
||||
opFunc(tres.ref(), f1, tf2()); \
|
||||
typedef typename product<Type1, Type2>::type resultType; \
|
||||
auto tres = FieldField<Field1, resultType>::NewCalculatedType(f1); \
|
||||
OpFunc(tres.ref(), f1, tf2()); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
@ -789,18 +744,15 @@ template \
|
||||
class Type2 \
|
||||
> \
|
||||
tmp<FieldField<Field1, typename product<Type1, Type2>::type>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<FieldField<Field1, Type1>>& tf1, \
|
||||
const FieldField<Field2, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
tmp<FieldField<Field1, productType>> tres \
|
||||
( \
|
||||
reuseTmpFieldField<Field1, productType, Type1>::New(tf1) \
|
||||
); \
|
||||
opFunc(tres.ref(), tf1(), f2); \
|
||||
typedef typename product<Type1, Type2>::type resultType; \
|
||||
auto tres = reuseTmpFieldField<Field1, resultType, Type1>::New(tf1); \
|
||||
OpFunc(tres.ref(), tf1(), f2); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
@ -813,19 +765,19 @@ template \
|
||||
class Type2 \
|
||||
> \
|
||||
tmp<FieldField<Field1, typename product<Type1, Type2>::type>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<FieldField<Field1, Type1>>& tf1, \
|
||||
const tmp<FieldField<Field2, Type2>>& tf2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
tmp<FieldField<Field1, productType>> tres \
|
||||
typedef typename product<Type1, Type2>::type resultType; \
|
||||
auto tres \
|
||||
( \
|
||||
reuseTmpTmpFieldField<Field1, productType, Type1, Type1, Type2>::New \
|
||||
reuseTmpTmpFieldField<Field1, resultType, Type1, Type1, Type2>::New \
|
||||
(tf1, tf2) \
|
||||
); \
|
||||
opFunc(tres.ref(), tf1(), tf2()); \
|
||||
OpFunc(tres.ref(), tf1(), tf2()); \
|
||||
tf1.clear(); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
@ -839,18 +791,18 @@ template \
|
||||
class Cmpt, \
|
||||
direction nCmpt \
|
||||
> \
|
||||
void opFunc \
|
||||
void OpFunc \
|
||||
( \
|
||||
FieldField<Field, typename product<Type, Form>::type>& f, \
|
||||
FieldField<Field, typename product<Type, Form>::type>& result, \
|
||||
const FieldField<Field, Type>& f1, \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs \
|
||||
) \
|
||||
{ \
|
||||
const label loopLen = (f).size(); \
|
||||
const label loopLen = (result).size(); \
|
||||
\
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
opFunc(f[i], f1[i], vs); \
|
||||
OpFunc(result[i], f1[i], vs); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
@ -863,18 +815,15 @@ template \
|
||||
direction nCmpt \
|
||||
> \
|
||||
tmp<FieldField<Field, typename product<Type, Form>::type>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const FieldField<Field, Type>& f1, \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type, Form>::type productType; \
|
||||
tmp<FieldField<Field, productType>> tres \
|
||||
( \
|
||||
FieldField<Field, productType>::NewCalculatedType(f1) \
|
||||
); \
|
||||
opFunc(tres.ref(), f1, static_cast<const Form&>(vs)); \
|
||||
typedef typename product<Type, Form>::type resultType; \
|
||||
auto tres = FieldField<Field, resultType>::NewCalculatedType(f1); \
|
||||
OpFunc(tres.ref(), f1, static_cast<const Form&>(vs)); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
@ -887,18 +836,15 @@ template \
|
||||
direction nCmpt \
|
||||
> \
|
||||
tmp<FieldField<Field, typename product<Type, Form>::type>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type>>& tf1, \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type, Form>::type productType; \
|
||||
tmp<FieldField<Field, productType>> tres \
|
||||
( \
|
||||
reuseTmpFieldField<Field, productType, Type>::New(tf1) \
|
||||
); \
|
||||
opFunc(tres.ref(), tf1(), static_cast<const Form&>(vs)); \
|
||||
typedef typename product<Type, Form>::type resultType; \
|
||||
auto tres = reuseTmpFieldField<Field, resultType, Type>::New(tf1); \
|
||||
OpFunc(tres.ref(), tf1(), static_cast<const Form&>(vs)); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
@ -911,18 +857,18 @@ template \
|
||||
class Cmpt, \
|
||||
direction nCmpt \
|
||||
> \
|
||||
void opFunc \
|
||||
void OpFunc \
|
||||
( \
|
||||
FieldField<Field, typename product<Form, Type>::type>& f, \
|
||||
FieldField<Field, typename product<Form, Type>::type>& result, \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs, \
|
||||
const FieldField<Field, Type>& f1 \
|
||||
) \
|
||||
{ \
|
||||
const label loopLen = (f).size(); \
|
||||
const label loopLen = (result).size(); \
|
||||
\
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
opFunc(f[i], vs, f1[i]); \
|
||||
OpFunc(result[i], vs, f1[i]); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
@ -935,18 +881,15 @@ template \
|
||||
direction nCmpt \
|
||||
> \
|
||||
tmp<FieldField<Field, typename product<Form, Type>::type>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs, \
|
||||
const FieldField<Field, Type>& f1 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Form, Type>::type productType; \
|
||||
tmp<FieldField<Field, productType>> tres \
|
||||
( \
|
||||
FieldField<Field, productType>::NewCalculatedType(f1) \
|
||||
); \
|
||||
opFunc(tres.ref(), static_cast<const Form&>(vs), f1); \
|
||||
typedef typename product<Form, Type>::type resultType; \
|
||||
auto tres = FieldField<Field, resultType>::NewCalculatedType(f1); \
|
||||
OpFunc(tres.ref(), static_cast<const Form&>(vs), f1); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
@ -959,18 +902,15 @@ template \
|
||||
direction nCmpt \
|
||||
> \
|
||||
tmp<FieldField<Field, typename product<Form, Type>::type>> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs, \
|
||||
const tmp<FieldField<Field, Type>>& tf1 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Form, Type>::type productType; \
|
||||
tmp<FieldField<Field, productType>> tres \
|
||||
( \
|
||||
reuseTmpFieldField<Field, productType, Type>::New(tf1) \
|
||||
); \
|
||||
opFunc(tres.ref(), static_cast<const Form&>(vs), tf1()); \
|
||||
typedef typename product<Form, Type>::type resultType; \
|
||||
auto tres = reuseTmpFieldField<Field, resultType, Type>::New(tf1); \
|
||||
OpFunc(tres.ref(), static_cast<const Form&>(vs), tf1()); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
|
||||
@ -287,10 +287,16 @@ BINARY_TYPE_FUNCTION(Type, Type, Type, min)
|
||||
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
|
||||
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
|
||||
|
||||
// Note: works with zero_one through implicit conversion to MinMax
|
||||
BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax<Type>, clamp)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
/* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */
|
||||
TERNARY_FUNCTION(Type, Type, Type, scalar, lerp)
|
||||
TERNARY_TYPE_FUNCTION_FFS(Type, Type, Type, scalar, lerp)
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * */
|
||||
|
||||
UNARY_OPERATOR(Type, Type, -, negate)
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,92 +31,86 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define UNARY_FUNCTION(ReturnType, Type, Func) \
|
||||
#define UNARY_FUNCTION(ReturnType, Type1, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& res, \
|
||||
const FieldField<Field, Type>& f \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1 \
|
||||
) \
|
||||
{ \
|
||||
const label loopLen = (res).size(); \
|
||||
const label loopLen = (result).size(); \
|
||||
\
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
Func(res[i], f[i]); \
|
||||
Func(result[i], f1[i]); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type>& f \
|
||||
const FieldField<Field, Type1>& f1 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
FieldField<Field, ReturnType>::NewCalculatedType(f) \
|
||||
); \
|
||||
Func(tres.ref(), f); \
|
||||
auto tres = FieldField<Field, ReturnType>::NewCalculatedType(f1); \
|
||||
Func(tres.ref(), f1); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type>>& tf \
|
||||
const tmp<FieldField<Field, Type1>>& tf1 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres(New(tf)); \
|
||||
Func(tres.ref(), tf()); \
|
||||
tf.clear(); \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1); \
|
||||
Func(tres.ref(), tf1()); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define UNARY_OPERATOR(ReturnType, Type, Op, OpFunc) \
|
||||
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& res, \
|
||||
const FieldField<Field, Type>& f \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1 \
|
||||
) \
|
||||
{ \
|
||||
const label loopLen = (res).size(); \
|
||||
const label loopLen = (result).size(); \
|
||||
\
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
OpFunc(res[i], f[i]); \
|
||||
OpFunc(result[i], f1[i]); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
( \
|
||||
const FieldField<Field, Type>& f \
|
||||
const FieldField<Field, Type1>& f1 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
FieldField<Field, Type>::NewCalculatedType(f) \
|
||||
); \
|
||||
OpFunc(tres.ref(), f); \
|
||||
auto tres = FieldField<Field, ReturnType>::NewCalculatedType(f1); \
|
||||
OpFunc(tres.ref(), f1); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type>>& tf \
|
||||
const tmp<FieldField<Field, Type1>>& tf1 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres(New(tf)); \
|
||||
OpFunc(tres.ref(), tf()); \
|
||||
tf.clear(); \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1); \
|
||||
OpFunc(tres.ref(), tf1()); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
|
||||
@ -128,16 +122,16 @@ tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& f, \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
const label loopLen = (f).size(); \
|
||||
const label loopLen = (result).size(); \
|
||||
\
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
Func(f[i], f1[i], f2[i]); \
|
||||
Func(result[i], f1[i], f2[i]); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
@ -148,10 +142,7 @@ tmp<FieldField<Field, ReturnType>> Func \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
FieldField<Field, Type1>::NewCalculatedType(f1) \
|
||||
); \
|
||||
auto tres = FieldField<Field, ReturnType>::NewCalculatedType(f1); \
|
||||
Func(tres.ref(), f1, f2); \
|
||||
return tres; \
|
||||
} \
|
||||
@ -163,10 +154,7 @@ tmp<FieldField<Field, ReturnType>> Func \
|
||||
const tmp<FieldField<Field, Type2>>& tf2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
|
||||
); \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2); \
|
||||
Func(tres.ref(), f1, tf2()); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
@ -179,10 +167,7 @@ tmp<FieldField<Field, ReturnType>> Func \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
|
||||
); \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1); \
|
||||
Func(tres.ref(), tf1(), f2); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
@ -195,7 +180,7 @@ tmp<FieldField<Field, ReturnType>> Func \
|
||||
const tmp<FieldField<Field, Type2>>& tf2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
auto tres \
|
||||
( \
|
||||
reuseTmpTmpFieldField<Field, ReturnType, Type1, Type1, Type2>:: \
|
||||
New(tf1, tf2) \
|
||||
@ -214,46 +199,40 @@ tmp<FieldField<Field, ReturnType>> Func \
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& f, \
|
||||
const Type1& s, \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const Type1& s1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
const label loopLen = (f).size(); \
|
||||
const label loopLen = (result).size(); \
|
||||
\
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
Func(f[i], s, f2[i]); \
|
||||
Func(result[i], s1, f2[i]); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const Type1& s, \
|
||||
const Type1& s1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
FieldField<Field, Type2>::NewCalculatedType(f2) \
|
||||
); \
|
||||
Func(tres.ref(), s, f2); \
|
||||
auto tres = FieldField<Field, ReturnType>::NewCalculatedType(f2); \
|
||||
Func(tres.ref(), s1, f2); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const Type1& s, \
|
||||
const Type1& s1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
|
||||
); \
|
||||
Func(tres.ref(), s, tf2()); \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2); \
|
||||
Func(tres.ref(), s1, tf2()); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
@ -264,16 +243,16 @@ tmp<FieldField<Field, ReturnType>> Func \
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& f, \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const Type2& s \
|
||||
const Type2& s2 \
|
||||
) \
|
||||
{ \
|
||||
const label loopLen = (f).size(); \
|
||||
const label loopLen = (result).size(); \
|
||||
\
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
Func(f[i], f1[i], s); \
|
||||
Func(result[i], f1[i], s2); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
@ -281,14 +260,11 @@ TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const Type2& s \
|
||||
const Type2& s2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
FieldField<Field, Type1>::NewCalculatedType(f1) \
|
||||
); \
|
||||
Func(tres.ref(), f1, s); \
|
||||
auto tres = FieldField<Field, ReturnType>::NewCalculatedType(f1); \
|
||||
Func(tres.ref(), f1, s2); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
@ -296,14 +272,11 @@ TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const Type2& s \
|
||||
const Type2& s2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
|
||||
); \
|
||||
Func(tres.ref(), tf1(), s); \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1); \
|
||||
Func(tres.ref(), tf1(), s2); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
@ -321,16 +294,16 @@ tmp<FieldField<Field, ReturnType>> Func \
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& f, \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
const label loopLen = (f).size(); \
|
||||
const label loopLen = (result).size(); \
|
||||
\
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
OpFunc(f[i], f1[i], f2[i]); \
|
||||
OpFunc(result[i], f1[i], f2[i]); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
@ -341,10 +314,7 @@ tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
FieldField<Field, ReturnType>::NewCalculatedType(f1) \
|
||||
); \
|
||||
auto tres = FieldField<Field, ReturnType>::NewCalculatedType(f1); \
|
||||
OpFunc(tres.ref(), f1, f2); \
|
||||
return tres; \
|
||||
} \
|
||||
@ -356,10 +326,7 @@ tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
const tmp<FieldField<Field, Type2>>& tf2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
|
||||
); \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2); \
|
||||
OpFunc(tres.ref(), f1, tf2()); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
@ -372,10 +339,7 @@ tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
|
||||
); \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1); \
|
||||
OpFunc(tres.ref(), tf1(), f2); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
@ -388,7 +352,7 @@ tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
const tmp<FieldField<Field, Type2>>& tf2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
auto tres \
|
||||
( \
|
||||
reuseTmpTmpFieldField<Field, ReturnType, Type1, Type1, Type2>:: \
|
||||
New(tf1, tf2) \
|
||||
@ -407,46 +371,40 @@ tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& f, \
|
||||
const Type1& s, \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const Type1& s1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
const label loopLen = (f).size(); \
|
||||
const label loopLen = (result).size(); \
|
||||
\
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
OpFunc(f[i], s, f2[i]); \
|
||||
OpFunc(result[i], s1, f2[i]); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
( \
|
||||
const Type1& s, \
|
||||
const Type1& s1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
FieldField<Field, Type2>::NewCalculatedType(f2) \
|
||||
); \
|
||||
OpFunc(tres.ref(), s, f2); \
|
||||
auto tres = FieldField<Field, ReturnType>::NewCalculatedType(f2); \
|
||||
OpFunc(tres.ref(), s1, f2); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
( \
|
||||
const Type1& s, \
|
||||
const Type1& s1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
|
||||
); \
|
||||
OpFunc(tres.ref(), s, tf2()); \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2); \
|
||||
OpFunc(tres.ref(), s1, tf2()); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
@ -457,16 +415,16 @@ tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& f, \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const Type2& s \
|
||||
const Type2& s2 \
|
||||
) \
|
||||
{ \
|
||||
const label loopLen = (f).size(); \
|
||||
const label loopLen = (result).size(); \
|
||||
\
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
OpFunc(f[i], f1[i], s); \
|
||||
OpFunc(result[i], f1[i], s2); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
@ -474,14 +432,11 @@ TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const Type2& s \
|
||||
const Type2& s2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
FieldField<Field, Type1>::NewCalculatedType(f1) \
|
||||
); \
|
||||
OpFunc(tres.ref(), f1, s); \
|
||||
auto tres = FieldField<Field, ReturnType>::NewCalculatedType(f1); \
|
||||
OpFunc(tres.ref(), f1, s2); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
@ -489,14 +444,11 @@ TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const Type2& s \
|
||||
const Type2& s2 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
|
||||
); \
|
||||
OpFunc(tres.ref(), tf1(), s); \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1); \
|
||||
OpFunc(tres.ref(), tf1(), s2); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
@ -506,4 +458,240 @@ tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
|
||||
BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define TERNARY_FUNCTION(ReturnType, Type1, Type2, Type3, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const FieldField<Field, Type3>& f3 \
|
||||
) \
|
||||
{ \
|
||||
const label loopLen = (result).size(); \
|
||||
\
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
Func(result[i], f1[i], f2[i], f3[i]); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const FieldField<Field, Type3>& f3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = FieldField<Field, ReturnType>::NewCalculatedType(f1); \
|
||||
Func(tres.ref(), f1, f2, f3); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const FieldField<Field, Type3>& f3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1); \
|
||||
Func(tres.ref(), tf1(), f2, f3); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2, \
|
||||
const FieldField<Field, Type3>& f3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2); \
|
||||
Func(tres.ref(), f1, tf2(), f3); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const tmp<FieldField<Field, Type3>>& tf3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type3>::New(tf3); \
|
||||
Func(tres.ref(), f1, f2, tf3()); \
|
||||
tf3.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2, \
|
||||
const FieldField<Field, Type3>& f3 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
reuseTmpTmpFieldField<Field, ReturnType, Type1, Type1, Type2>:: \
|
||||
New(tf1, tf2) \
|
||||
); \
|
||||
Func(tres.ref(), tf1(), tf2(), f3); \
|
||||
tf1.clear(); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const tmp<FieldField<Field, Type3>>& tf3 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
reuseTmpTmpFieldField<Field, ReturnType, Type1, Type1, Type3>:: \
|
||||
New(tf1, tf3) \
|
||||
); \
|
||||
Func(tres.ref(), tf1(), f2, tf3()); \
|
||||
tf1.clear(); \
|
||||
tf3.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2, \
|
||||
const tmp<FieldField<Field, Type3>>& tf3 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
reuseTmpTmpFieldField<Field, ReturnType, Type2, Type2, Type3>:: \
|
||||
New(tf2, tf3) \
|
||||
); \
|
||||
Func(tres.ref(), f1, tf2(), tf3()); \
|
||||
tf2.clear(); \
|
||||
tf3.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2, \
|
||||
const tmp<FieldField<Field, Type3>>& tf3 \
|
||||
) \
|
||||
{ \
|
||||
/* TBD: check all three types? */ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
reuseTmpTmpFieldField<Field, ReturnType, Type1, Type1, Type2>:: \
|
||||
New(tf1, tf2) \
|
||||
); \
|
||||
Func(tres.ref(), tf1(), tf2(), tf3()); \
|
||||
tf1.clear(); \
|
||||
tf2.clear(); \
|
||||
tf3.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
|
||||
|
||||
#define TERNARY_TYPE_FUNCTION_FFS(ReturnType, Type1, Type2, Type3, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const Type3& s3 \
|
||||
) \
|
||||
{ \
|
||||
const label loopLen = (result).size(); \
|
||||
\
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
Func(result[i], f1[i], f2[i], s3); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const Type3& s3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = FieldField<Field, ReturnType>::NewCalculatedType(f1); \
|
||||
Func(tres.ref(), f1, f2, s3); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const Type3& s3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1); \
|
||||
Func(tres.ref(), tf1(), f2, s3); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2, \
|
||||
const Type3& s3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2); \
|
||||
Func(tres.ref(), f1, tf2(), s3); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2, \
|
||||
const Type3& s3 \
|
||||
) \
|
||||
{ \
|
||||
tmp<FieldField<Field, ReturnType>> tres \
|
||||
( \
|
||||
reuseTmpTmpFieldField<Field, ReturnType, Type1, Type1, Type2>:: \
|
||||
New(tf1, tf2) \
|
||||
); \
|
||||
Func(tres.ref(), tf1(), tf2(), s3); \
|
||||
tf1.clear(); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,9 +25,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
High performance macro functions for Field\<Type\> algebra.
|
||||
These expand using either array element access (for vector machines)
|
||||
or pointer dereferencing for scalar machines as appropriate.
|
||||
Macro functions for FieldField\<Type\> algebra.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -37,20 +36,20 @@ Description
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& res, \
|
||||
const FieldField<Field, Type1>& f \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f \
|
||||
const FieldField<Field, Type1>& f1 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf \
|
||||
const tmp<FieldField<Field, Type1>>& tf1 \
|
||||
);
|
||||
|
||||
|
||||
@ -61,20 +60,20 @@ tmp<FieldField<Field, ReturnType>> Func \
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& res, \
|
||||
const FieldField<Field, Type1>& f \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f \
|
||||
const FieldField<Field, Type1>& f1 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf \
|
||||
const tmp<FieldField<Field, Type1>>& tf1 \
|
||||
);
|
||||
|
||||
|
||||
@ -83,36 +82,36 @@ tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void func \
|
||||
void Func \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& f, \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> func \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> func \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> func \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> func \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2 \
|
||||
@ -124,22 +123,22 @@ tmp<FieldField<Field, ReturnType>> func \
|
||||
#define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void func \
|
||||
void Func \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& f, \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const Type1& s1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> func \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const Type1& s1, \
|
||||
const FieldField<Field, Type1>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> func \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const Type1& s1, \
|
||||
const tmp<FieldField<Field, Type1>>& tf2 \
|
||||
@ -149,25 +148,25 @@ tmp<FieldField<Field, ReturnType>> func \
|
||||
#define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void func \
|
||||
void Func \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& f, \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const Type2& s \
|
||||
const Type2& s2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> func \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const Type2& s \
|
||||
const Type2& s2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> func \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const Type2& s \
|
||||
const Type2& s2 \
|
||||
);
|
||||
|
||||
|
||||
@ -183,7 +182,7 @@ tmp<FieldField<Field, ReturnType>> func \
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& f, \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
); \
|
||||
@ -224,7 +223,7 @@ tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& f, \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const Type1& s1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
); \
|
||||
@ -249,7 +248,7 @@ tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& f, \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const Type2& s2 \
|
||||
); \
|
||||
@ -274,4 +273,126 @@ tmp<FieldField<Field, ReturnType>> operator Op \
|
||||
BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define TERNARY_FUNCTION(ReturnType, Type1, Type2, Type3, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const FieldField<Field, Type3>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const FieldField<Field, Type3>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const FieldField<Field, Type3>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2, \
|
||||
const FieldField<Field, Type3>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const tmp<FieldField<Field, Type3>>& tf3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2, \
|
||||
const FieldField<Field, Type3>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const tmp<FieldField<Field, Type3>>& tf3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2, \
|
||||
const tmp<FieldField<Field, Type3>>& tf3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2, \
|
||||
const tmp<FieldField<Field, Type3>>& tf3 \
|
||||
);
|
||||
|
||||
|
||||
#define TERNARY_TYPE_FUNCTION_FFS(ReturnType, Type1, Type2, Type3, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
FieldField<Field, ReturnType>& result, \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const Type3& s3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const Type3& s3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const FieldField<Field, Type2>& f2, \
|
||||
const Type3& s3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2, \
|
||||
const Type3& s3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<FieldField<Field, ReturnType>> Func \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1>>& tf1, \
|
||||
const tmp<FieldField<Field, Type2>>& tf2, \
|
||||
const Type3& s3 \
|
||||
);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,10 +35,21 @@ namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// One-parameter versions
|
||||
|
||||
template<template<class> class Field, class TypeR, class Type1>
|
||||
struct reuseTmpFieldField
|
||||
{
|
||||
//- Pass-through to NewCalculatedType
|
||||
static tmp<FieldField<Field, TypeR>> New
|
||||
(
|
||||
const FieldField<Field, Type1>& f1
|
||||
)
|
||||
{
|
||||
return FieldField<Field, TypeR>::NewCalculatedType(f1);
|
||||
}
|
||||
|
||||
//- Dissimilar types: just use size
|
||||
static tmp<FieldField<Field, TypeR>> New
|
||||
(
|
||||
const tmp<FieldField<Field, Type1>>& tf1
|
||||
@ -52,6 +63,8 @@ struct reuseTmpFieldField
|
||||
template<template<class> class Field, class TypeR>
|
||||
struct reuseTmpFieldField<Field, TypeR, TypeR>
|
||||
{
|
||||
//- Identical input and return types:
|
||||
//- allow optional copy assignment of the initial content
|
||||
static tmp<FieldField<Field, TypeR>> New
|
||||
(
|
||||
const tmp<FieldField<Field, TypeR>>& tf1,
|
||||
@ -63,19 +76,19 @@ struct reuseTmpFieldField<Field, TypeR, TypeR>
|
||||
return tf1;
|
||||
}
|
||||
|
||||
auto rtf = FieldField<Field, TypeR>::NewCalculatedType(tf1());
|
||||
auto tresult = FieldField<Field, TypeR>::NewCalculatedType(tf1());
|
||||
|
||||
if (initCopy)
|
||||
{
|
||||
rtf.ref() = tf1();
|
||||
tresult.ref() = tf1();
|
||||
}
|
||||
|
||||
return rtf;
|
||||
return tresult;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//- Global function forwards to reuseTmpFieldField::New
|
||||
//- This global function forwards to reuseTmpFieldField::New
|
||||
template<template<class> class Field, class TypeR>
|
||||
tmp<FieldField<Field, TypeR>> New
|
||||
(
|
||||
@ -87,6 +100,9 @@ tmp<FieldField<Field, TypeR>> New
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Two-parameter versions
|
||||
|
||||
template
|
||||
<
|
||||
template<class> class Field,
|
||||
@ -97,6 +113,7 @@ template
|
||||
>
|
||||
struct reuseTmpTmpFieldField
|
||||
{
|
||||
//- Dissimilar types: just use size
|
||||
static tmp<FieldField<Field, TypeR>> New
|
||||
(
|
||||
const tmp<FieldField<Field, Type1>>& tf1,
|
||||
@ -111,6 +128,7 @@ struct reuseTmpTmpFieldField
|
||||
template<template<class> class Field, class TypeR, class Type1, class Type12>
|
||||
struct reuseTmpTmpFieldField<Field, TypeR, Type1, Type12, TypeR>
|
||||
{
|
||||
//- Second input has return type
|
||||
static tmp<FieldField<Field, TypeR>> New
|
||||
(
|
||||
const tmp<FieldField<Field, Type1>>& tf1,
|
||||
@ -130,6 +148,7 @@ struct reuseTmpTmpFieldField<Field, TypeR, Type1, Type12, TypeR>
|
||||
template<template<class> class Field, class TypeR, class Type2>
|
||||
struct reuseTmpTmpFieldField<Field, TypeR, TypeR, TypeR, Type2>
|
||||
{
|
||||
//- First input has return type
|
||||
static tmp<FieldField<Field, TypeR>> New
|
||||
(
|
||||
const tmp<FieldField<Field, TypeR>>& tf1,
|
||||
@ -149,6 +168,7 @@ struct reuseTmpTmpFieldField<Field, TypeR, TypeR, TypeR, Type2>
|
||||
template<template<class> class Field, class TypeR>
|
||||
struct reuseTmpTmpFieldField<Field, TypeR, TypeR, TypeR, TypeR>
|
||||
{
|
||||
//- Both inputs have return type
|
||||
static tmp<FieldField<Field, TypeR>> New
|
||||
(
|
||||
const tmp<FieldField<Field, TypeR>>& tf1,
|
||||
|
||||
@ -658,27 +658,6 @@ void Foam::Field<Type>::replace
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Field<Type>::clamp(const Type& lower, const Type& upper)
|
||||
{
|
||||
// Use free functions min(), max() to impose component-wise clamping
|
||||
if (lower < upper)
|
||||
{
|
||||
// std::for_each
|
||||
for (auto& val : *this)
|
||||
{
|
||||
val = min(max(val, lower), upper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void Foam::Field<Type>::clamp(const MinMax<Type>& range)
|
||||
{
|
||||
clamp(range.min(), range.max());
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Field<Type>::clamp_min(const Type& lower)
|
||||
{
|
||||
@ -702,6 +681,26 @@ void Foam::Field<Type>::clamp_max(const Type& upper)
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Field<Type>::clamp_range(const Type& lower, const Type& upper)
|
||||
{
|
||||
// Note: no checks for bad/invalid clamping ranges
|
||||
|
||||
// Use free functions min(), max() to impose component-wise clamping
|
||||
// std::for_each
|
||||
for (auto& val : *this)
|
||||
{
|
||||
val = min(max(val, lower), upper);
|
||||
}
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void Foam::Field<Type>::clamp_range(const MinMax<Type>& range)
|
||||
{
|
||||
Field<Type>::clamp_range(range.min(), range.max());
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
template<class VSForm>
|
||||
VSForm Foam::Field<Type>::block(const label start) const
|
||||
|
||||
@ -434,20 +434,20 @@ public:
|
||||
//- Replace a component field of the field
|
||||
void replace(const direction, const cmptType&);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// A no-op for an invalid range.
|
||||
void clamp(const Type& lower, const Type& upper);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// A no-op for an invalid range.
|
||||
void clamp(const MinMax<Type>& range);
|
||||
|
||||
//- Impose lower (floor) clamp on the field values (in-place)
|
||||
void clamp_min(const Type& lower);
|
||||
|
||||
//- Impose upper (ceiling) clamp on the field values (in-place)
|
||||
void clamp_max(const Type& upper);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// Does not check if range is valid or not.
|
||||
void clamp_range(const Type& lower, const Type& upper);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// Does not check if range is valid or not.
|
||||
void clamp_range(const MinMax<Type>& range);
|
||||
|
||||
template<class VSForm>
|
||||
VSForm block(const label start) const;
|
||||
|
||||
|
||||
@ -42,38 +42,40 @@ namespace Foam
|
||||
template<class Type>
|
||||
void component
|
||||
(
|
||||
Field<typename Field<Type>::cmptType>& res,
|
||||
const UList<Type>& f,
|
||||
Field<typename Field<Type>::cmptType>& result,
|
||||
const UList<Type>& f1,
|
||||
const direction d
|
||||
)
|
||||
{
|
||||
typedef typename Field<Type>::cmptType cmptType;
|
||||
typedef typename Field<Type>::cmptType resultType;
|
||||
|
||||
TFOR_ALL_F_OP_F_FUNC_S
|
||||
(
|
||||
cmptType, res, =, Type, f, .component, const direction, d
|
||||
resultType, result, =, Type, f1, .component, const direction, d
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void T(Field<Type>& res, const UList<Type>& f)
|
||||
void T(Field<Type>& result, const UList<Type>& f1)
|
||||
{
|
||||
TFOR_ALL_F_OP_F_FUNC(Type, res, =, Type, f, T)
|
||||
TFOR_ALL_F_OP_F_FUNC(Type, result, =, Type, f1, T)
|
||||
}
|
||||
|
||||
|
||||
template<class Type, direction r>
|
||||
void pow
|
||||
(
|
||||
Field<typename powProduct<Type, r>::type>& res,
|
||||
const UList<Type>& vf
|
||||
Field<typename powProduct<Type, r>::type>& result,
|
||||
const UList<Type>& f1
|
||||
)
|
||||
{
|
||||
typedef typename powProduct<Type, r>::type powProductType;
|
||||
typedef typename powProduct<Type, r>::type resultType;
|
||||
|
||||
TFOR_ALL_F_OP_FUNC_F_S
|
||||
(
|
||||
powProductType, res, =, pow, Type, vf, powProductType,
|
||||
pTraits<powProductType>::zero
|
||||
resultType, result, =, pow, Type, f1, resultType,
|
||||
pTraits<resultType>::zero
|
||||
)
|
||||
}
|
||||
|
||||
@ -81,16 +83,13 @@ template<class Type, direction r>
|
||||
tmp<Field<typename powProduct<Type, r>::type>>
|
||||
pow
|
||||
(
|
||||
const UList<Type>& f,
|
||||
const UList<Type>& f1,
|
||||
typename powProduct<Type, r>::type
|
||||
)
|
||||
{
|
||||
typedef typename powProduct<Type, r>::type powProductType;
|
||||
auto tres
|
||||
(
|
||||
tmp<Field<powProductType>>::New(f.size())
|
||||
);
|
||||
pow<Type, r>(tres.ref(), f);
|
||||
typedef typename powProduct<Type, r>::type resultType;
|
||||
auto tres = tmp<Field<resultType>>::New(f1.size());
|
||||
pow<Type, r>(tres.ref(), f1);
|
||||
return tres;
|
||||
}
|
||||
|
||||
@ -98,14 +97,14 @@ template<class Type, direction r>
|
||||
tmp<Field<typename powProduct<Type, r>::type>>
|
||||
pow
|
||||
(
|
||||
const tmp<Field<Type>>& tf,
|
||||
const tmp<Field<Type>>& tf1,
|
||||
typename powProduct<Type, r>::type
|
||||
)
|
||||
{
|
||||
typedef typename powProduct<Type, r>::type powProductType;
|
||||
auto tres = reuseTmp<powProductType, Type>::New(tf);
|
||||
pow<Type, r>(tres.ref(), tf());
|
||||
tf.clear();
|
||||
typedef typename powProduct<Type, r>::type resultType;
|
||||
auto tres = reuseTmp<resultType, Type>::New(tf1);
|
||||
pow<Type, r>(tres.ref(), tf1());
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
@ -113,35 +112,33 @@ pow
|
||||
template<class Type>
|
||||
void sqr
|
||||
(
|
||||
Field<typename outerProduct<Type, Type>::type>& res,
|
||||
const UList<Type>& vf
|
||||
Field<typename outerProduct<Type, Type>::type>& result,
|
||||
const UList<Type>& f1
|
||||
)
|
||||
{
|
||||
typedef typename outerProduct<Type, Type>::type outerProductType;
|
||||
TFOR_ALL_F_OP_FUNC_F(outerProductType, res, =, sqr, Type, vf)
|
||||
typedef typename outerProduct<Type, Type>::type resultType;
|
||||
|
||||
TFOR_ALL_F_OP_FUNC_F(resultType, result, =, sqr, Type, f1)
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<typename outerProduct<Type, Type>::type>>
|
||||
sqr(const UList<Type>& f)
|
||||
sqr(const UList<Type>& f1)
|
||||
{
|
||||
typedef typename outerProduct<Type, Type>::type outerProductType;
|
||||
auto tres
|
||||
(
|
||||
tmp<Field<outerProductType>>::New(f.size())
|
||||
);
|
||||
sqr(tres.ref(), f);
|
||||
typedef typename outerProduct<Type, Type>::type resultType;
|
||||
auto tres = tmp<Field<resultType>>::New(f1.size());
|
||||
sqr(tres.ref(), f1);
|
||||
return tres;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<typename outerProduct<Type, Type>::type>>
|
||||
sqr(const tmp<Field<Type>>& tf)
|
||||
sqr(const tmp<Field<Type>>& tf1)
|
||||
{
|
||||
typedef typename outerProduct<Type, Type>::type outerProductType;
|
||||
auto tres = reuseTmp<outerProductType, Type>::New(tf);
|
||||
sqr(tres.ref(), tf());
|
||||
tf.clear();
|
||||
typedef typename outerProduct<Type, Type>::type resultType;
|
||||
auto tres = reuseTmp<resultType, Type>::New(tf1);
|
||||
sqr(tres.ref(), tf1());
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
@ -149,35 +146,35 @@ sqr(const tmp<Field<Type>>& tf)
|
||||
template<class Type>
|
||||
void magSqr
|
||||
(
|
||||
Field<typename typeOfMag<Type>::type>& res,
|
||||
const UList<Type>& f
|
||||
Field<typename typeOfMag<Type>::type>& result,
|
||||
const UList<Type>& f1
|
||||
)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
TFOR_ALL_F_OP_FUNC_F(magType, res, =, magSqr, Type, f)
|
||||
TFOR_ALL_F_OP_FUNC_F(resultType, result, =, magSqr, Type, f1)
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<typename typeOfMag<Type>::type>>
|
||||
magSqr(const UList<Type>& f)
|
||||
magSqr(const UList<Type>& f1)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
auto tres = tmp<Field<magType>>::New(f.size());
|
||||
magSqr(tres.ref(), f);
|
||||
auto tres = tmp<Field<resultType>>::New(f1.size());
|
||||
magSqr(tres.ref(), f1);
|
||||
return tres;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<typename typeOfMag<Type>::type>>
|
||||
magSqr(const tmp<Field<Type>>& tf)
|
||||
magSqr(const tmp<Field<Type>>& tf1)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
auto tres = reuseTmp<magType, Type>::New(tf);
|
||||
magSqr(tres.ref(), tf());
|
||||
tf.clear();
|
||||
auto tres = reuseTmp<resultType, Type>::New(tf1);
|
||||
magSqr(tres.ref(), tf1());
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
@ -185,164 +182,179 @@ magSqr(const tmp<Field<Type>>& tf)
|
||||
template<class Type>
|
||||
void mag
|
||||
(
|
||||
Field<typename typeOfMag<Type>::type>& res,
|
||||
const UList<Type>& f
|
||||
Field<typename typeOfMag<Type>::type>& result,
|
||||
const UList<Type>& f1
|
||||
)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
TFOR_ALL_F_OP_FUNC_F(magType, res, =, mag, Type, f)
|
||||
TFOR_ALL_F_OP_FUNC_F(resultType, result, =, mag, Type, f1)
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<typename typeOfMag<Type>::type>>
|
||||
mag(const UList<Type>& f)
|
||||
mag(const UList<Type>& f1)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
auto tres = tmp<Field<magType>>::New(f.size());
|
||||
mag(tres.ref(), f);
|
||||
auto tres = tmp<Field<resultType>>::New(f1.size());
|
||||
mag(tres.ref(), f1);
|
||||
return tres;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<typename typeOfMag<Type>::type>>
|
||||
mag(const tmp<Field<Type>>& tf)
|
||||
mag(const tmp<Field<Type>>& tf1)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
auto tres = reuseTmp<magType, Type>::New(tf);
|
||||
mag(tres.ref(), tf());
|
||||
tf.clear();
|
||||
auto tres = reuseTmp<resultType, Type>::New(tf1);
|
||||
mag(tres.ref(), tf1());
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void cmptMax(Field<typename Field<Type>::cmptType>& res, const UList<Type>& f)
|
||||
void cmptMax
|
||||
(
|
||||
Field<typename Field<Type>::cmptType>& result,
|
||||
const UList<Type>& f1
|
||||
)
|
||||
{
|
||||
typedef typename Field<Type>::cmptType cmptType;
|
||||
TFOR_ALL_F_OP_FUNC_F(cmptType, res, =, cmptMax, Type, f)
|
||||
typedef typename Field<Type>::cmptType resultType;
|
||||
|
||||
TFOR_ALL_F_OP_FUNC_F(resultType, result, =, cmptMax, Type, f1)
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<typename Field<Type>::cmptType>> cmptMax(const UList<Type>& f)
|
||||
tmp<Field<typename Field<Type>::cmptType>> cmptMax(const UList<Type>& f1)
|
||||
{
|
||||
typedef typename Field<Type>::cmptType cmptType;
|
||||
auto tres = tmp<Field<cmptType>>::New(f.size());
|
||||
cmptMax(tres.ref(), f);
|
||||
typedef typename Field<Type>::cmptType resultType;
|
||||
auto tres = tmp<Field<resultType>>::New(f1.size());
|
||||
cmptMax(tres.ref(), f1);
|
||||
return tres;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<typename Field<Type>::cmptType>> cmptMax(const tmp<Field<Type>>& tf)
|
||||
tmp<Field<typename Field<Type>::cmptType>> cmptMax(const tmp<Field<Type>>& tf1)
|
||||
{
|
||||
typedef typename Field<Type>::cmptType cmptType;
|
||||
auto tres = reuseTmp<cmptType, Type>::New(tf);
|
||||
cmptMax(tres.ref(), tf());
|
||||
tf.clear();
|
||||
typedef typename Field<Type>::cmptType resultType;
|
||||
auto tres = reuseTmp<resultType, Type>::New(tf1);
|
||||
cmptMax(tres.ref(), tf1());
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void cmptMin(Field<typename Field<Type>::cmptType>& res, const UList<Type>& f)
|
||||
void cmptMin
|
||||
(
|
||||
Field<typename Field<Type>::cmptType>& result,
|
||||
const UList<Type>& f1
|
||||
)
|
||||
{
|
||||
typedef typename Field<Type>::cmptType cmptType;
|
||||
TFOR_ALL_F_OP_FUNC_F(cmptType, res, =, cmptMin, Type, f)
|
||||
typedef typename Field<Type>::cmptType resultType;
|
||||
|
||||
TFOR_ALL_F_OP_FUNC_F(resultType, result, =, cmptMin, Type, f1)
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<typename Field<Type>::cmptType>> cmptMin(const UList<Type>& f)
|
||||
tmp<Field<typename Field<Type>::cmptType>> cmptMin(const UList<Type>& f1)
|
||||
{
|
||||
typedef typename Field<Type>::cmptType cmptType;
|
||||
auto tres = tmp<Field<cmptType>>::New(f.size());
|
||||
cmptMin(tres.ref(), f);
|
||||
typedef typename Field<Type>::cmptType resultType;
|
||||
auto tres = tmp<Field<resultType>>::New(f1.size());
|
||||
cmptMin(tres.ref(), f1);
|
||||
return tres;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<typename Field<Type>::cmptType>> cmptMin(const tmp<Field<Type>>& tf)
|
||||
tmp<Field<typename Field<Type>::cmptType>> cmptMin(const tmp<Field<Type>>& tf1)
|
||||
{
|
||||
typedef typename Field<Type>::cmptType cmptType;
|
||||
auto tres = reuseTmp<cmptType, Type>::New(tf);
|
||||
cmptMin(tres.ref(), tf());
|
||||
tf.clear();
|
||||
typedef typename Field<Type>::cmptType resultType;
|
||||
auto tres = reuseTmp<resultType, Type>::New(tf1);
|
||||
cmptMin(tres.ref(), tf1());
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void cmptAv(Field<typename Field<Type>::cmptType>& res, const UList<Type>& f)
|
||||
void cmptAv
|
||||
(
|
||||
Field<typename Field<Type>::cmptType>& result,
|
||||
const UList<Type>& f1
|
||||
)
|
||||
{
|
||||
typedef typename Field<Type>::cmptType cmptType;
|
||||
TFOR_ALL_F_OP_FUNC_F(cmptType, res, =, cmptAv, Type, f)
|
||||
typedef typename Field<Type>::cmptType resultType;
|
||||
|
||||
TFOR_ALL_F_OP_FUNC_F(resultType, result, =, cmptAv, Type, f1)
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<typename Field<Type>::cmptType>> cmptAv(const UList<Type>& f)
|
||||
tmp<Field<typename Field<Type>::cmptType>> cmptAv(const UList<Type>& f1)
|
||||
{
|
||||
typedef typename Field<Type>::cmptType cmptType;
|
||||
auto tres = tmp<Field<cmptType>>::New(f.size());
|
||||
cmptAv(tres.ref(), f);
|
||||
typedef typename Field<Type>::cmptType resultType;
|
||||
auto tres = tmp<Field<resultType>>::New(f1.size());
|
||||
cmptAv(tres.ref(), f1);
|
||||
return tres;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<typename Field<Type>::cmptType>> cmptAv(const tmp<Field<Type>>& tf)
|
||||
tmp<Field<typename Field<Type>::cmptType>> cmptAv(const tmp<Field<Type>>& tf1)
|
||||
{
|
||||
typedef typename Field<Type>::cmptType cmptType;
|
||||
auto tres = reuseTmp<cmptType, Type>::New(tf);
|
||||
cmptAv(tres.ref(), tf());
|
||||
tf.clear();
|
||||
typedef typename Field<Type>::cmptType resultType;
|
||||
auto tres = reuseTmp<resultType, Type>::New(tf1);
|
||||
cmptAv(tres.ref(), tf1());
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void cmptMag(Field<Type>& res, const UList<Type>& f)
|
||||
void cmptMag(Field<Type>& result, const UList<Type>& f1)
|
||||
{
|
||||
TFOR_ALL_F_OP_FUNC_F(Type, res, =, cmptMag, Type, f)
|
||||
TFOR_ALL_F_OP_FUNC_F(Type, result, =, cmptMag, Type, f1)
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<Type>> cmptMag(const UList<Type>& f)
|
||||
tmp<Field<Type>> cmptMag(const UList<Type>& f1)
|
||||
{
|
||||
auto tres = tmp<Field<Type>>::New(f.size());
|
||||
cmptMag(tres.ref(), f);
|
||||
auto tres = tmp<Field<Type>>::New(f1.size());
|
||||
cmptMag(tres.ref(), f1);
|
||||
return tres;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<Type>> cmptMag(const tmp<Field<Type>>& tf)
|
||||
tmp<Field<Type>> cmptMag(const tmp<Field<Type>>& tf1)
|
||||
{
|
||||
auto tres = New(tf);
|
||||
cmptMag(tres.ref(), tf());
|
||||
tf.clear();
|
||||
auto tres = New(tf1);
|
||||
cmptMag(tres.ref(), tf1());
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void cmptMagSqr(Field<Type>& res, const UList<Type>& f)
|
||||
void cmptMagSqr(Field<Type>& result, const UList<Type>& f1)
|
||||
{
|
||||
TFOR_ALL_F_OP_FUNC_F(Type, res, =, cmptMagSqr, Type, f)
|
||||
TFOR_ALL_F_OP_FUNC_F(Type, result, =, cmptMagSqr, Type, f1)
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<Type>> cmptMagSqr(const UList<Type>& f)
|
||||
tmp<Field<Type>> cmptMagSqr(const UList<Type>& f1)
|
||||
{
|
||||
auto tres = tmp<Field<Type>>::New(f.size());
|
||||
cmptMagSqr(tres.ref(), f);
|
||||
auto tres = tmp<Field<Type>>::New(f1.size());
|
||||
cmptMagSqr(tres.ref(), f1);
|
||||
return tres;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<Type>> cmptMagSqr(const tmp<Field<Type>>& tf)
|
||||
tmp<Field<Type>> cmptMagSqr(const tmp<Field<Type>>& tf1)
|
||||
{
|
||||
auto tres = New(tf);
|
||||
cmptMagSqr(tres.ref(), tf());
|
||||
tf.clear();
|
||||
auto tres = New(tf1);
|
||||
cmptMagSqr(tres.ref(), tf1());
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
|
||||
@ -358,13 +370,13 @@ ReturnType Func(const tmp<Field<Type>>& tf1) \
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
Type max(const UList<Type>& f)
|
||||
Type max(const UList<Type>& f1)
|
||||
{
|
||||
if (f.size())
|
||||
if (f1.size())
|
||||
{
|
||||
Type Max(f[0]);
|
||||
TFOR_ALL_S_OP_FUNC_F_S(Type, Max, =, max, Type, f, Type, Max)
|
||||
return Max;
|
||||
Type result(f1[0]);
|
||||
TFOR_ALL_S_OP_FUNC_F_S(Type, result, =, max, Type, f1, Type, result)
|
||||
return result;
|
||||
}
|
||||
|
||||
return pTraits<Type>::min;
|
||||
@ -373,13 +385,13 @@ Type max(const UList<Type>& f)
|
||||
TMP_UNARY_FUNCTION(Type, max)
|
||||
|
||||
template<class Type>
|
||||
Type min(const UList<Type>& f)
|
||||
Type min(const UList<Type>& f1)
|
||||
{
|
||||
if (f.size())
|
||||
if (f1.size())
|
||||
{
|
||||
Type Min(f[0]);
|
||||
TFOR_ALL_S_OP_FUNC_F_S(Type, Min, =, min, Type, f, Type, Min)
|
||||
return Min;
|
||||
Type result(f1[0]);
|
||||
TFOR_ALL_S_OP_FUNC_F_S(Type, result, =, min, Type, f1, Type, result)
|
||||
return result;
|
||||
}
|
||||
|
||||
return pTraits<Type>::max;
|
||||
@ -388,18 +400,19 @@ Type min(const UList<Type>& f)
|
||||
TMP_UNARY_FUNCTION(Type, min)
|
||||
|
||||
template<class Type>
|
||||
Type sum(const UList<Type>& f)
|
||||
Type sum(const UList<Type>& f1)
|
||||
{
|
||||
typedef typename Foam::typeOfSolve<Type>::type solveType;
|
||||
typedef typename Foam::typeOfSolve<Type>::type resultType;
|
||||
|
||||
solveType Sum = Zero;
|
||||
resultType result = Zero;
|
||||
|
||||
if (f.size())
|
||||
if (f1.size())
|
||||
{
|
||||
TFOR_ALL_S_OP_FUNC_F(solveType, Sum, +=, solveType, Type, f)
|
||||
// Use resultType() as functional cast
|
||||
TFOR_ALL_S_OP_FUNC_F(resultType, result, +=, resultType, Type, f1)
|
||||
}
|
||||
|
||||
return Type(Sum);
|
||||
return Type(result);
|
||||
}
|
||||
|
||||
TMP_UNARY_FUNCTION(Type, sum)
|
||||
@ -414,23 +427,23 @@ TMP_UNARY_FUNCTION(scalarMinMax, minMaxMag)
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type maxMagSqr(const UList<Type>& f)
|
||||
Type maxMagSqr(const UList<Type>& f1)
|
||||
{
|
||||
if (f.size())
|
||||
if (f1.size())
|
||||
{
|
||||
Type Max(f[0]);
|
||||
Type result(f1[0]);
|
||||
TFOR_ALL_S_OP_FUNC_F_S
|
||||
(
|
||||
Type,
|
||||
Max,
|
||||
result,
|
||||
=,
|
||||
maxMagSqrOp<Type>(),
|
||||
Type,
|
||||
f,
|
||||
f1,
|
||||
Type,
|
||||
Max
|
||||
result
|
||||
)
|
||||
return Max;
|
||||
return result;
|
||||
}
|
||||
|
||||
return Zero;
|
||||
@ -439,23 +452,23 @@ Type maxMagSqr(const UList<Type>& f)
|
||||
TMP_UNARY_FUNCTION(Type, maxMagSqr)
|
||||
|
||||
template<class Type>
|
||||
Type minMagSqr(const UList<Type>& f)
|
||||
Type minMagSqr(const UList<Type>& f1)
|
||||
{
|
||||
if (f.size())
|
||||
if (f1.size())
|
||||
{
|
||||
Type Min(f[0]);
|
||||
Type result(f1[0]);
|
||||
TFOR_ALL_S_OP_FUNC_F_S
|
||||
(
|
||||
Type,
|
||||
Min,
|
||||
result,
|
||||
=,
|
||||
minMagSqrOp<Type>(),
|
||||
Type,
|
||||
f,
|
||||
f1,
|
||||
Type,
|
||||
Min
|
||||
result
|
||||
)
|
||||
return Min;
|
||||
return result;
|
||||
}
|
||||
|
||||
return pTraits<Type>::rootMax;
|
||||
@ -467,12 +480,12 @@ template<class Type>
|
||||
typename scalarProduct<Type, Type>::type
|
||||
sumProd(const UList<Type>& f1, const UList<Type>& f2)
|
||||
{
|
||||
typedef typename scalarProduct<Type, Type>::type prodType;
|
||||
typedef typename scalarProduct<Type, Type>::type resultType;
|
||||
|
||||
prodType result = Zero;
|
||||
resultType result = Zero;
|
||||
if (f1.size() && (f1.size() == f2.size()))
|
||||
{
|
||||
TFOR_ALL_S_OP_F_OP_F(prodType, result, +=, Type, f1, &&, Type, f2)
|
||||
TFOR_ALL_S_OP_F_OP_F(resultType, result, +=, Type, f1, &&, Type, f2)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -502,37 +515,39 @@ Type sumCmptProd(const UList<Type>& f1, const UList<Type>& f2)
|
||||
|
||||
template<class Type>
|
||||
typename outerProduct1<Type>::type
|
||||
sumSqr(const UList<Type>& f)
|
||||
sumSqr(const UList<Type>& f1)
|
||||
{
|
||||
typedef typename outerProduct1<Type>::type prodType;
|
||||
prodType result = Zero;
|
||||
if (f.size())
|
||||
typedef typename outerProduct1<Type>::type resultType;
|
||||
|
||||
resultType result = Zero;
|
||||
if (f1.size())
|
||||
{
|
||||
TFOR_ALL_S_OP_FUNC_F(prodType, result, +=, sqr, Type, f)
|
||||
TFOR_ALL_S_OP_FUNC_F(resultType, result, +=, sqr, Type, f1)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename outerProduct1<Type>::type
|
||||
sumSqr(const tmp<Field<Type>>& tf)
|
||||
sumSqr(const tmp<Field<Type>>& tf1)
|
||||
{
|
||||
typedef typename outerProduct1<Type>::type prodType;
|
||||
prodType result = sumSqr(tf());
|
||||
tf.clear();
|
||||
typedef typename outerProduct1<Type>::type resultType;
|
||||
resultType result = sumSqr(tf1());
|
||||
tf1.clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename typeOfMag<Type>::type
|
||||
sumMag(const UList<Type>& f)
|
||||
sumMag(const UList<Type>& f1)
|
||||
{
|
||||
typedef typename typeOfMag<Type>::type magType;
|
||||
magType result = Zero;
|
||||
if (f.size())
|
||||
typedef typename typeOfMag<Type>::type resultType;
|
||||
|
||||
resultType result = Zero;
|
||||
if (f1.size())
|
||||
{
|
||||
TFOR_ALL_S_OP_FUNC_F(magType, result, +=, mag, Type, f)
|
||||
TFOR_ALL_S_OP_FUNC_F(resultType, result, +=, mag, Type, f1)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -541,12 +556,12 @@ TMP_UNARY_FUNCTION(typename typeOfMag<Type>::type, sumMag)
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type sumCmptMag(const UList<Type>& f)
|
||||
Type sumCmptMag(const UList<Type>& f1)
|
||||
{
|
||||
Type result = Zero;
|
||||
if (f.size())
|
||||
if (f1.size())
|
||||
{
|
||||
TFOR_ALL_S_OP_FUNC_F(Type, result, +=, cmptMag, Type, f)
|
||||
TFOR_ALL_S_OP_FUNC_F(Type, result, +=, cmptMag, Type, f1)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -554,13 +569,13 @@ Type sumCmptMag(const UList<Type>& f)
|
||||
TMP_UNARY_FUNCTION(Type, sumCmptMag)
|
||||
|
||||
template<class Type>
|
||||
Type average(const UList<Type>& f)
|
||||
Type average(const UList<Type>& f1)
|
||||
{
|
||||
if (f.size())
|
||||
if (f1.size())
|
||||
{
|
||||
Type avrg = sum(f)/f.size();
|
||||
Type result = sum(f1)/f1.size();
|
||||
|
||||
return avrg;
|
||||
return result;
|
||||
}
|
||||
|
||||
WarningInFunction
|
||||
@ -608,10 +623,10 @@ typename scalarProduct<Type, Type>::type gSumProd
|
||||
const label comm
|
||||
)
|
||||
{
|
||||
typedef typename scalarProduct<Type, Type>::type prodType;
|
||||
typedef typename scalarProduct<Type, Type>::type resultType;
|
||||
|
||||
prodType result = sumProd(f1, f2);
|
||||
reduce(result, sumOp<prodType>(), UPstream::msgType(), comm);
|
||||
resultType result = sumProd(f1, f2);
|
||||
reduce(result, sumOp<resultType>(), UPstream::msgType(), comm);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -623,27 +638,27 @@ Type gSumCmptProd
|
||||
const label comm
|
||||
)
|
||||
{
|
||||
Type SumProd = sumCmptProd(f1, f2);
|
||||
reduce(SumProd, sumOp<Type>(), UPstream::msgType(), comm);
|
||||
return SumProd;
|
||||
Type result = sumCmptProd(f1, f2);
|
||||
reduce(result, sumOp<Type>(), UPstream::msgType(), comm);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
Type gAverage
|
||||
(
|
||||
const UList<Type>& f,
|
||||
const UList<Type>& f1,
|
||||
const label comm
|
||||
)
|
||||
{
|
||||
label n = f.size();
|
||||
Type s = sum(f);
|
||||
label n = f1.size();
|
||||
Type s = sum(f1);
|
||||
sumReduce(s, n, UPstream::msgType(), comm);
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
Type avrg = s/n;
|
||||
Type result = s/n;
|
||||
|
||||
return avrg;
|
||||
return result;
|
||||
}
|
||||
|
||||
WarningInFunction
|
||||
@ -656,6 +671,8 @@ TMP_UNARY_FUNCTION(Type, gAverage)
|
||||
|
||||
#undef TMP_UNARY_FUNCTION
|
||||
|
||||
|
||||
// Implement BINARY_FUNCTION_TRANSFORM_FS for clamp
|
||||
template<class Type>
|
||||
void clamp
|
||||
(
|
||||
@ -664,55 +681,52 @@ void clamp
|
||||
const MinMax<Type>& range
|
||||
)
|
||||
{
|
||||
// Note: no checks for bad/invalid clamping ranges
|
||||
|
||||
if (result.cdata() == f1.cdata())
|
||||
{
|
||||
// Apply in-place
|
||||
result.clamp(range);
|
||||
result.clamp_range(range);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (range.good())
|
||||
{
|
||||
std::transform
|
||||
(
|
||||
f1.cbegin(),
|
||||
f1.cbegin(result.size()),
|
||||
result.begin(),
|
||||
clampOp<Type>(range)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No clamping
|
||||
std::copy(f1.cbegin(), f1.cbegin(result.size()), result.begin());
|
||||
}
|
||||
std::transform
|
||||
(
|
||||
f1.cbegin(),
|
||||
f1.cbegin(result.size()),
|
||||
result.begin(),
|
||||
clampOp<Type>(range)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<Type>> clamp
|
||||
void clamp
|
||||
(
|
||||
Field<Type>& result,
|
||||
const UList<Type>& f1,
|
||||
const MinMax<Type>& range
|
||||
const Foam::zero_one& // Note: macros generate a const reference
|
||||
)
|
||||
{
|
||||
auto tres = tmp<Field<Type>>::New(f1.size());
|
||||
clamp(tres.ref(), f1, range);
|
||||
return tres;
|
||||
if (result.cdata() == f1.cdata())
|
||||
{
|
||||
// Apply in-place
|
||||
result.clamp_range(Foam::zero_one{});
|
||||
}
|
||||
else
|
||||
{
|
||||
std::transform
|
||||
(
|
||||
f1.cbegin(),
|
||||
f1.cbegin(result.size()),
|
||||
result.begin(),
|
||||
clampOp<Type>(Foam::zero_one{})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<Type>> clamp
|
||||
(
|
||||
const tmp<Field<Type>>& tf1,
|
||||
const MinMax<Type>& range
|
||||
)
|
||||
{
|
||||
auto tres = reuseTmp<Type, Type>::New(tf1);
|
||||
clamp(tres.ref(), tf1(), range);
|
||||
tf1.clear();
|
||||
return tres;
|
||||
}
|
||||
BINARY_FUNCTION_INTERFACE_FS(Type, Type, MinMax<Type>, clamp)
|
||||
BINARY_FUNCTION_INTERFACE_FS(Type, Type, Foam::zero_one, clamp)
|
||||
|
||||
|
||||
BINARY_FUNCTION(Type, Type, Type, max)
|
||||
@ -727,6 +741,11 @@ BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
|
||||
|
||||
BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax<Type>, clip) // Same as clamp
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
TERNARY_FUNCTION(Type, Type, Type, scalar, lerp)
|
||||
TERNARY_TYPE_FUNCTION_FFS(Type, Type, Type, scalar, lerp)
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * */
|
||||
|
||||
@ -749,21 +768,21 @@ BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide)
|
||||
template<class Type1, class Type2> \
|
||||
void OpFunc \
|
||||
( \
|
||||
Field<typename product<Type1, Type2>::type>& res, \
|
||||
Field<typename product<Type1, Type2>::type>& result, \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
TFOR_ALL_F_OP_F_OP_F(productType, res, =, Type1, f1, Op, Type2, f2) \
|
||||
typedef typename product<Type1, Type2>::type resultType; \
|
||||
TFOR_ALL_F_OP_F_OP_F(resultType, result, =, Type1, f1, Op, Type2, f2) \
|
||||
} \
|
||||
\
|
||||
template<class Type1, class Type2> \
|
||||
tmp<Field<typename product<Type1, Type2>::type>> \
|
||||
operator Op(const UList<Type1>& f1, const UList<Type2>& f2) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
auto tres = tmp<Field<productType>>::New(f1.size()); \
|
||||
typedef typename product<Type1, Type2>::type resultType; \
|
||||
auto tres = tmp<Field<resultType>>::New(f1.size()); \
|
||||
OpFunc(tres.ref(), f1, f2); \
|
||||
return tres; \
|
||||
} \
|
||||
@ -772,8 +791,8 @@ template<class Type1, class Type2> \
|
||||
tmp<Field<typename product<Type1, Type2>::type>> \
|
||||
operator Op(const UList<Type1>& f1, const tmp<Field<Type2>>& tf2) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
auto tres = reuseTmp<productType, Type2>::New(tf2); \
|
||||
typedef typename product<Type1, Type2>::type resultType; \
|
||||
auto tres = reuseTmp<resultType, Type2>::New(tf2); \
|
||||
OpFunc(tres.ref(), f1, tf2()); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
@ -783,8 +802,8 @@ template<class Type1, class Type2> \
|
||||
tmp<Field<typename product<Type1, Type2>::type>> \
|
||||
operator Op(const tmp<Field<Type1>>& tf1, const UList<Type2>& f2) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
auto tres = reuseTmp<productType, Type1>::New(tf1); \
|
||||
typedef typename product<Type1, Type2>::type resultType; \
|
||||
auto tres = reuseTmp<resultType, Type1>::New(tf1); \
|
||||
OpFunc(tres.ref(), tf1(), f2); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
@ -794,8 +813,8 @@ template<class Type1, class Type2> \
|
||||
tmp<Field<typename product<Type1, Type2>::type>> \
|
||||
operator Op(const tmp<Field<Type1>>& tf1, const tmp<Field<Type2>>& tf2) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
auto tres = reuseTmpTmp<productType, Type1, Type1, Type2>::New(tf1, tf2); \
|
||||
typedef typename product<Type1, Type2>::type resultType; \
|
||||
auto tres = reuseTmpTmp<resultType, Type1, Type1, Type2>::New(tf1, tf2); \
|
||||
OpFunc(tres.ref(), tf1(), tf2()); \
|
||||
tf1.clear(); \
|
||||
tf2.clear(); \
|
||||
@ -805,22 +824,22 @@ operator Op(const tmp<Field<Type1>>& tf1, const tmp<Field<Type2>>& tf2) \
|
||||
template<class Type, class Form, class Cmpt, direction nCmpt> \
|
||||
void OpFunc \
|
||||
( \
|
||||
Field<typename product<Type, Form>::type>& res, \
|
||||
Field<typename product<Type, Form>::type>& result, \
|
||||
const UList<Type>& f1, \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type, Form>::type productType; \
|
||||
typedef typename product<Type, Form>::type resultType; \
|
||||
TFOR_ALL_F_OP_F_OP_S \
|
||||
(productType, res, =,Type, f1, Op, Form, static_cast<const Form&>(vs)) \
|
||||
(resultType, result, =,Type, f1, Op, Form, static_cast<const Form&>(vs))\
|
||||
} \
|
||||
\
|
||||
template<class Type, class Form, class Cmpt, direction nCmpt> \
|
||||
tmp<Field<typename product<Type, Form>::type>> \
|
||||
operator Op(const UList<Type>& f1, const VectorSpace<Form,Cmpt,nCmpt>& vs) \
|
||||
{ \
|
||||
typedef typename product<Type, Form>::type productType; \
|
||||
auto tres = tmp<Field<productType>>::New(f1.size()); \
|
||||
typedef typename product<Type, Form>::type resultType; \
|
||||
auto tres = tmp<Field<resultType>>::New(f1.size()); \
|
||||
OpFunc(tres.ref(), f1, static_cast<const Form&>(vs)); \
|
||||
return tres; \
|
||||
} \
|
||||
@ -833,8 +852,8 @@ operator Op \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type, Form>::type productType; \
|
||||
auto tres = reuseTmp<productType, Type>::New(tf1); \
|
||||
typedef typename product<Type, Form>::type resultType; \
|
||||
auto tres = reuseTmp<resultType, Type>::New(tf1); \
|
||||
OpFunc(tres.ref(), tf1(), static_cast<const Form&>(vs)); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
@ -843,22 +862,22 @@ operator Op \
|
||||
template<class Form, class Cmpt, direction nCmpt, class Type> \
|
||||
void OpFunc \
|
||||
( \
|
||||
Field<typename product<Form, Type>::type>& res, \
|
||||
Field<typename product<Form, Type>::type>& result, \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs, \
|
||||
const UList<Type>& f1 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Form, Type>::type productType; \
|
||||
typedef typename product<Form, Type>::type resultType; \
|
||||
TFOR_ALL_F_OP_S_OP_F \
|
||||
(productType, res, =,Form,static_cast<const Form&>(vs), Op, Type, f1) \
|
||||
(resultType, result, =,Form,static_cast<const Form&>(vs), Op, Type, f1)\
|
||||
} \
|
||||
\
|
||||
template<class Form, class Cmpt, direction nCmpt, class Type> \
|
||||
tmp<Field<typename product<Form, Type>::type>> \
|
||||
operator Op(const VectorSpace<Form,Cmpt,nCmpt>& vs, const UList<Type>& f1) \
|
||||
{ \
|
||||
typedef typename product<Form, Type>::type productType; \
|
||||
auto tres = tmp<Field<productType>>::New(f1.size()); \
|
||||
typedef typename product<Form, Type>::type resultType; \
|
||||
auto tres = tmp<Field<resultType>>::New(f1.size()); \
|
||||
OpFunc(tres.ref(), static_cast<const Form&>(vs), f1); \
|
||||
return tres; \
|
||||
} \
|
||||
@ -870,8 +889,8 @@ operator Op \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs, const tmp<Field<Type>>& tf1 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Form, Type>::type productType; \
|
||||
auto tres = reuseTmp<productType, Type>::New(tf1); \
|
||||
typedef typename product<Form, Type>::type resultType; \
|
||||
auto tres = reuseTmp<resultType, Type>::New(tf1); \
|
||||
OpFunc(tres.ref(), static_cast<const Form&>(vs), tf1()); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
|
||||
@ -314,8 +314,14 @@ BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
|
||||
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
|
||||
|
||||
BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax<Type>, clamp)
|
||||
BINARY_TYPE_FUNCTION_FS(Type, Type, Foam::zero_one, clamp)
|
||||
BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax<Type>, clip) // Same as clamp
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
TERNARY_FUNCTION(Type, Type, Type, scalar, lerp)
|
||||
TERNARY_TYPE_FUNCTION_FFS(Type, Type, Type, scalar, lerp)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,77 +31,99 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define UNARY_FUNCTION(ReturnType, Type, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func(Field<ReturnType>& res, const UList<Type>& f) \
|
||||
{ \
|
||||
TFOR_ALL_F_OP_FUNC_F(ReturnType, res, =, ::Foam::Func, Type, f) \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func(const UList<Type>& f) \
|
||||
{ \
|
||||
auto tres = tmp<Field<ReturnType>>::New(f.size()); \
|
||||
Func(tres.ref(), f); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func(const tmp<Field<Type>>& tf) \
|
||||
{ \
|
||||
auto tres = reuseTmp<ReturnType, Type>::New(tf); \
|
||||
Func(tres.ref(), tf()); \
|
||||
tf.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define UNARY_OPERATOR(ReturnType, Type, Op, OpFunc) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void OpFunc(Field<ReturnType>& res, const UList<Type>& f) \
|
||||
{ \
|
||||
TFOR_ALL_F_OP_OP_F(ReturnType, res, =, Op, Type, f) \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> operator Op(const UList<Type>& f) \
|
||||
{ \
|
||||
auto tres = tmp<Field<ReturnType>>::New(f.size()); \
|
||||
OpFunc(tres.ref(), f); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> operator Op(const tmp<Field<Type>>& tf) \
|
||||
{ \
|
||||
auto tres = reuseTmp<ReturnType, Type>::New(tf); \
|
||||
OpFunc(tres.ref(), tf()); \
|
||||
tf.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
|
||||
#define UNARY_FUNCTION(ReturnType, Type1, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
Field<ReturnType>& res, \
|
||||
Field<ReturnType>& result, \
|
||||
const UList<Type1>& f1 \
|
||||
) \
|
||||
{ \
|
||||
TFOR_ALL_F_OP_FUNC_F(ReturnType, result, =, ::Foam::Func, Type1, f1) \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = tmp<Field<ReturnType>>::New(f1.size()); \
|
||||
Func(tres.ref(), f1); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmp<ReturnType, Type1>::New(tf1); \
|
||||
Func(tres.ref(), tf1()); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
Field<ReturnType>& result, \
|
||||
const UList<Type1>& f1 \
|
||||
) \
|
||||
{ \
|
||||
TFOR_ALL_F_OP_OP_F(ReturnType, result, =, Op, Type1, f1) \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> operator Op \
|
||||
( \
|
||||
const UList<Type1>& f1 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = tmp<Field<ReturnType>>::New(f1.size()); \
|
||||
OpFunc(tres.ref(), f1); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> operator Op \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmp<ReturnType, Type1>::New(tf1); \
|
||||
OpFunc(tres.ref(), tf1()); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define BINARY_FUNCTION_TRANSFORM(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
Field<ReturnType>& result, \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
TFOR_ALL_F_OP_FUNC_F_F \
|
||||
( \
|
||||
ReturnType, res, =, ::Foam::Func, Type1, f1, Type2, f2 \
|
||||
ReturnType, result, =, ::Foam::Func, Type1, f1, Type2, f2 \
|
||||
) \
|
||||
} \
|
||||
}
|
||||
|
||||
#define BINARY_FUNCTION_INTERFACE(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
@ -155,24 +177,30 @@ tmp<Field<ReturnType>> Func \
|
||||
return tres; \
|
||||
}
|
||||
|
||||
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
|
||||
BINARY_FUNCTION_TRANSFORM(ReturnType, Type1, Type2, Func) \
|
||||
BINARY_FUNCTION_INTERFACE(ReturnType, Type1, Type2, Func)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
|
||||
#define BINARY_FUNCTION_TRANSFORM_SF(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
Field<ReturnType>& res, \
|
||||
Field<ReturnType>& result, \
|
||||
const Type1& s1, \
|
||||
const UList<Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
TFOR_ALL_F_OP_FUNC_S_F \
|
||||
( \
|
||||
ReturnType, res, =, ::Foam::Func, Type1, s1, Type2, f2 \
|
||||
ReturnType, result, =, ::Foam::Func, Type1, s1, Type2, f2 \
|
||||
) \
|
||||
} \
|
||||
}
|
||||
|
||||
#define BINARY_FUNCTION_INTERFACE_SF(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
@ -199,22 +227,28 @@ tmp<Field<ReturnType>> Func \
|
||||
return tres; \
|
||||
}
|
||||
|
||||
#define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
|
||||
BINARY_FUNCTION_TRANSFORM_SF(ReturnType, Type1, Type2, Func) \
|
||||
BINARY_FUNCTION_INTERFACE_SF(ReturnType, Type1, Type2, Func)
|
||||
|
||||
#define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
|
||||
|
||||
#define BINARY_FUNCTION_TRANSFORM_FS(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
Field<ReturnType>& res, \
|
||||
Field<ReturnType>& result, \
|
||||
const UList<Type1>& f1, \
|
||||
const Type2& s2 \
|
||||
) \
|
||||
{ \
|
||||
TFOR_ALL_F_OP_FUNC_F_S \
|
||||
( \
|
||||
ReturnType, res, =, ::Foam::Func, Type1, f1, Type2, s2 \
|
||||
ReturnType, result, =, ::Foam::Func, Type1, f1, Type2, s2 \
|
||||
) \
|
||||
} \
|
||||
}
|
||||
|
||||
#define BINARY_FUNCTION_INTERFACE_FS(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
@ -241,6 +275,10 @@ tmp<Field<ReturnType>> Func \
|
||||
return tres; \
|
||||
}
|
||||
|
||||
#define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
|
||||
BINARY_FUNCTION_TRANSFORM_FS(ReturnType, Type1, Type2, Func) \
|
||||
BINARY_FUNCTION_INTERFACE_FS(ReturnType, Type1, Type2, Func)
|
||||
|
||||
|
||||
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func) \
|
||||
BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
|
||||
@ -254,12 +292,12 @@ tmp<Field<ReturnType>> Func \
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
Field<ReturnType>& res, \
|
||||
Field<ReturnType>& result, \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
TFOR_ALL_F_OP_F_OP_F(ReturnType, res, =, Type1, f1, Op, Type2, f2) \
|
||||
TFOR_ALL_F_OP_F_OP_F(ReturnType, result, =, Type1, f1, Op, Type2, f2) \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
@ -322,12 +360,12 @@ tmp<Field<ReturnType>> operator Op \
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
Field<ReturnType>& res, \
|
||||
Field<ReturnType>& result, \
|
||||
const Type1& s1, \
|
||||
const UList<Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
TFOR_ALL_F_OP_S_OP_F(ReturnType, res, =, Type1, s1, Op, Type2, f2) \
|
||||
TFOR_ALL_F_OP_S_OP_F(ReturnType, result, =, Type1, s1, Op, Type2, f2) \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
@ -361,12 +399,12 @@ tmp<Field<ReturnType>> operator Op \
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
Field<ReturnType>& res, \
|
||||
Field<ReturnType>& result, \
|
||||
const UList<Type1>& f1, \
|
||||
const Type2& s2 \
|
||||
) \
|
||||
{ \
|
||||
TFOR_ALL_F_OP_F_OP_S(ReturnType, res, =, Type1, f1, Op, Type2, s2) \
|
||||
TFOR_ALL_F_OP_F_OP_S(ReturnType, result, =, Type1, f1, Op, Type2, s2) \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
@ -400,4 +438,215 @@ tmp<Field<ReturnType>> operator Op \
|
||||
BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define TERNARY_FUNCTION(ReturnType, Type1, Type2, Type3, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
Field<ReturnType>& result, \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2, \
|
||||
const UList<Type3>& f3 \
|
||||
) \
|
||||
{ \
|
||||
TFOR_ALL_F_OP_FUNC_F_F_F \
|
||||
( \
|
||||
ReturnType, result, =, ::Foam::Func, Type1, f1, Type2, f2, Type3, f3 \
|
||||
) \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2, \
|
||||
const UList<Type3>& f3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = tmp<Field<ReturnType>>::New(f1.size()); \
|
||||
Func(tres.ref(), f1, f2, f3); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const UList<Type2>& f2, \
|
||||
const UList<Type3>& f3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmp<ReturnType, Type1>::New(tf1); \
|
||||
Func(tres.ref(), tf1(), f2, f3); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const tmp<Field<Type2>>& tf2, \
|
||||
const UList<Type3>& f3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmp<ReturnType, Type2>::New(tf2); \
|
||||
Func(tres.ref(), f1, tf2(), f3); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2, \
|
||||
const tmp<Field<Type3>>& tf3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmp<ReturnType, Type3>::New(tf3); \
|
||||
Func(tres.ref(), f1, f2, tf3()); \
|
||||
tf3.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const tmp<Field<Type2>>& tf2, \
|
||||
const UList<Type3>& f3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmpTmp<ReturnType, Type1, Type1, Type2>::New(tf1, tf2); \
|
||||
Func(tres.ref(), tf1(), tf2(), f3); \
|
||||
tf1.clear(); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const UList<Type2>& f2, \
|
||||
const tmp<Field<Type3>>& tf3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmpTmp<ReturnType, Type1, Type1, Type3>::New(tf1, tf3); \
|
||||
Func(tres.ref(), tf1(), f2, tf3()); \
|
||||
tf1.clear(); \
|
||||
tf3.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const tmp<Field<Type2>>& tf2, \
|
||||
const tmp<Field<Type3>>& tf3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmpTmp<ReturnType, Type2, Type2, Type3>::New(tf2, tf3); \
|
||||
Func(tres.ref(), f1, tf2(), tf3()); \
|
||||
tf2.clear(); \
|
||||
tf3.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const tmp<Field<Type2>>& tf2, \
|
||||
const tmp<Field<Type3>>& tf3 \
|
||||
) \
|
||||
{ \
|
||||
/* TBD: check all three types? */ \
|
||||
auto tres = reuseTmpTmp<ReturnType, Type1, Type1, Type2>::New(tf1, tf2); \
|
||||
Func(tres.ref(), tf1(), tf2(), tf3()); \
|
||||
tf1.clear(); \
|
||||
tf2.clear(); \
|
||||
tf3.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
|
||||
|
||||
#define TERNARY_TYPE_FUNCTION_FFS(ReturnType, Type1, Type2, Type3, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
Field<ReturnType>& result, \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2, \
|
||||
const Type3& s3 \
|
||||
) \
|
||||
{ \
|
||||
TFOR_ALL_F_OP_FUNC_F_F_S \
|
||||
( \
|
||||
ReturnType, result, =, ::Foam::Func, Type1, f1, Type2, f2, Type3, s3 \
|
||||
) \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2, \
|
||||
const Type3& s3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = tmp<Field<ReturnType>>::New(f1.size()); \
|
||||
Func(tres.ref(), f1, f2, s3); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const UList<Type2>& f2, \
|
||||
const Type3& s3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmp<ReturnType, Type1>::New(tf1); \
|
||||
Func(tres.ref(), tf1(), f2, s3); \
|
||||
tf1.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const tmp<Field<Type2>>& tf2, \
|
||||
const Type3& s3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmp<ReturnType, Type2>::New(tf2); \
|
||||
Func(tres.ref(), f1, tf2(), s3); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
} \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const tmp<Field<Type2>>& tf2, \
|
||||
const Type3& s3 \
|
||||
) \
|
||||
{ \
|
||||
auto tres = reuseTmpTmp<ReturnType, Type1, Type1, Type2>::New(tf1, tf2); \
|
||||
Func(tres.ref(), tf1(), tf2(), s3); \
|
||||
tf1.clear(); \
|
||||
tf2.clear(); \
|
||||
return tres; \
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,9 +25,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
High performance macro functions for Field\<Type\> algebra. These expand
|
||||
using either array element access (for vector machines) or pointer
|
||||
dereferencing for scalar machines as appropriate.
|
||||
Macro functions for Field\<Type\> algebra.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -35,11 +34,13 @@ Description
|
||||
#define UNARY_FUNCTION(ReturnType, Type1, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func(Field<ReturnType>& res, const UList<Type1>& f); \
|
||||
void Func(Field<ReturnType>& result, const UList<Type1>& f1); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func(const UList<Type1>& f); \
|
||||
tmp<Field<ReturnType>> Func(const UList<Type1>& f1); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func(const tmp<Field<Type1>>& tf);
|
||||
tmp<Field<ReturnType>> Func(const tmp<Field<Type1>>& tf1);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -47,65 +48,74 @@ tmp<Field<ReturnType>> Func(const tmp<Field<Type1>>& tf);
|
||||
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void OpFunc(Field<ReturnType>& res, const UList<Type1>& f); \
|
||||
void OpFunc(Field<ReturnType>& res, const UList<Type1>& f1); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> operator Op(const UList<Type1>& f); \
|
||||
tmp<Field<ReturnType>> operator Op(const UList<Type1>& f1); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> operator Op(const tmp<Field<Type1>>& tf);
|
||||
tmp<Field<ReturnType>> operator Op(const tmp<Field<Type1>>& tf1);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define BINARY_FUNCTION_TRANSFORM(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
Field<ReturnType>& result, \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2 \
|
||||
);
|
||||
|
||||
#define BINARY_FUNCTION_INTERFACE(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const tmp<Field<Type2>>& tf2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const UList<Type2>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const tmp<Field<Type2>>& tf2 \
|
||||
);
|
||||
|
||||
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
Field<ReturnType>& f, \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const tmp<Field<Type2>>& tf2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const UList<Type2>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const tmp<Field<Type2>>& tf2 \
|
||||
);
|
||||
|
||||
BINARY_FUNCTION_TRANSFORM(ReturnType, Type1, Type2, Func) \
|
||||
BINARY_FUNCTION_INTERFACE(ReturnType, Type1, Type2, Func)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
|
||||
#define BINARY_FUNCTION_TRANSFORM_SF(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
Field<ReturnType>& f, \
|
||||
Field<ReturnType>& result, \
|
||||
const Type1& s1, \
|
||||
const UList<Type2>& f2 \
|
||||
); \
|
||||
);
|
||||
|
||||
#define BINARY_FUNCTION_INTERFACE_SF(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
@ -121,16 +131,22 @@ tmp<Field<ReturnType>> Func \
|
||||
const tmp<Field<Type2>>& tf2 \
|
||||
);
|
||||
|
||||
#define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
|
||||
BINARY_FUNCTION_TRANSFORM_SF(ReturnType, Type1, Type2, Func) \
|
||||
BINARY_FUNCTION_INTERFACE_SF(ReturnType, Type1, Type2, Func)
|
||||
|
||||
#define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
|
||||
|
||||
#define BINARY_FUNCTION_TRANSFORM_FS(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
Field<ReturnType>& f, \
|
||||
Field<ReturnType>& result, \
|
||||
const UList<Type1>& f1, \
|
||||
const Type2& s2 \
|
||||
); \
|
||||
);
|
||||
|
||||
#define BINARY_FUNCTION_INTERFACE_FS(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
@ -146,6 +162,10 @@ tmp<Field<ReturnType>> Func \
|
||||
const Type2& s2 \
|
||||
);
|
||||
|
||||
#define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
|
||||
BINARY_FUNCTION_TRANSFORM_FS(ReturnType, Type1, Type2, Func) \
|
||||
BINARY_FUNCTION_INTERFACE_FS(ReturnType, Type1, Type2, Func)
|
||||
|
||||
|
||||
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func) \
|
||||
BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
|
||||
@ -159,7 +179,7 @@ tmp<Field<ReturnType>> Func \
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
Field<ReturnType>& f, \
|
||||
Field<ReturnType>& result, \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2 \
|
||||
); \
|
||||
@ -200,7 +220,7 @@ tmp<Field<ReturnType>> operator Op \
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
Field<ReturnType>& f, \
|
||||
Field<ReturnType>& result, \
|
||||
const Type1& s1, \
|
||||
const UList<Type2>& f2 \
|
||||
); \
|
||||
@ -225,7 +245,7 @@ tmp<Field<ReturnType>> operator Op \
|
||||
TEMPLATE \
|
||||
void OpFunc \
|
||||
( \
|
||||
Field<ReturnType>& f, \
|
||||
Field<ReturnType>& result, \
|
||||
const UList<Type1>& f1, \
|
||||
const Type2& s2 \
|
||||
); \
|
||||
@ -250,4 +270,136 @@ tmp<Field<ReturnType>> operator Op \
|
||||
BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define TERNARY_FUNCTION(ReturnType, Type1, Type2, Type3, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
Field<ReturnType>& result, \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2, \
|
||||
const UList<Type3>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2, \
|
||||
const UList<Type3>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const UList<Type2>& f2, \
|
||||
const UList<Type3>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const tmp<Field<Type2>>& tf2, \
|
||||
const UList<Type3>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2, \
|
||||
const tmp<Field<Type3>>& tf3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const tmp<Field<Type2>>& tf2, \
|
||||
const UList<Type3>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const UList<Type2>& f2, \
|
||||
const tmp<Field<Type3>>& tf3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const tmp<Field<Type2>>& tf2, \
|
||||
const tmp<Field<Type3>>& tf3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const tmp<Field<Type2>>& tf2, \
|
||||
const tmp<Field<Type3>>& tf3 \
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Permutations of ternary functions taking non-field argument(s)
|
||||
//
|
||||
// FFS (defined)
|
||||
// FSF (not defined)
|
||||
// SFF (not defined)
|
||||
// SSF (not defined)
|
||||
// SFS (not defined)
|
||||
// FSS (not defined)
|
||||
|
||||
#define TERNARY_TYPE_FUNCTION_FFS(ReturnType, Type1, Type2, Type3, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
Field<ReturnType>& result, \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2, \
|
||||
const Type3& s3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const UList<Type2>& f2, \
|
||||
const Type3& s3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const UList<Type2>& f2, \
|
||||
const Type3& s3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const UList<Type1>& f1, \
|
||||
const tmp<Field<Type2>>& tf2, \
|
||||
const Type3& s3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<Field<ReturnType>> Func \
|
||||
( \
|
||||
const tmp<Field<Type1>>& tf1, \
|
||||
const tmp<Field<Type2>>& tf2, \
|
||||
const Type3& s3 \
|
||||
);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,9 +25,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
High performance macro functions for Field\<Type\> algebra. These expand
|
||||
using either array element access (for vector machines) or pointer
|
||||
dereferencing for scalar machines as appropriate.
|
||||
Declaration macros for Field\<Type\> algebra.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -86,6 +84,34 @@ void checkFields
|
||||
}
|
||||
}
|
||||
|
||||
template<class Type1, class Type2, class Type3, class Type4>
|
||||
void checkFields
|
||||
(
|
||||
const UList<Type1>& f1,
|
||||
const UList<Type2>& f2,
|
||||
const UList<Type3>& f3,
|
||||
const UList<Type4>& f4,
|
||||
const char* op
|
||||
)
|
||||
{
|
||||
if
|
||||
(
|
||||
f1.size() != f2.size()
|
||||
|| f1.size() != f3.size()
|
||||
|| f1.size() != f4.size()
|
||||
)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< " Field<"<<pTraits<Type1>::typeName<<"> f1("<<f1.size()<<')'
|
||||
<< ", Field<"<<pTraits<Type2>::typeName<<"> f2("<<f2.size()<<')'
|
||||
<< ", Field<"<<pTraits<Type3>::typeName<<"> f3("<<f3.size()<<')'
|
||||
<< " and Field<"<<pTraits<Type4>::typeName<<"> f4("<<f4.size()<<')'
|
||||
<< endl
|
||||
<< " for operation " << op
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<class Type1, class Type2>
|
||||
@ -107,12 +133,23 @@ void checkFields
|
||||
)
|
||||
{}
|
||||
|
||||
template<class Type1, class Type2, class Type3, class Type4>
|
||||
void checkFields
|
||||
(
|
||||
const UList<Type1>&,
|
||||
const UList<Type2>&,
|
||||
const UList<Type3>&,
|
||||
const UList<Type4>&,
|
||||
const char*
|
||||
)
|
||||
{}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Member function : f1 OP Func f2
|
||||
// Unary Free Function : f1 OP Func f2
|
||||
|
||||
#define TFOR_ALL_F_OP_FUNC_F(typeF1, f1, OP, FUNC, typeF2, f2) \
|
||||
\
|
||||
@ -133,7 +170,7 @@ void checkFields
|
||||
}
|
||||
|
||||
|
||||
// Member function : this f1 OP f2.FUNC()
|
||||
// Nullary Member Function : f1 OP f2.FUNC()
|
||||
|
||||
#define TFOR_ALL_F_OP_F_FUNC(typeF1, f1, OP, typeF2, f2, FUNC) \
|
||||
\
|
||||
@ -154,7 +191,7 @@ void checkFields
|
||||
}
|
||||
|
||||
|
||||
// Member function : this field f1 OP FUNC(f2, f3)
|
||||
// Binary Free Function : f1 OP FUNC(f2, f3)
|
||||
|
||||
#define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3) \
|
||||
\
|
||||
@ -176,7 +213,7 @@ void checkFields
|
||||
}
|
||||
|
||||
|
||||
// Member function : s OP FUNC(f1, f2)
|
||||
// [reduction] Binary Free Function : s OP FUNC(f1, f2)
|
||||
|
||||
#define TFOR_ALL_S_OP_FUNC_F_F(typeS, s, OP, FUNC, typeF1, f1, typeF2, f2) \
|
||||
\
|
||||
@ -197,7 +234,7 @@ void checkFields
|
||||
}
|
||||
|
||||
|
||||
// Member function : this f1 OP FUNC(f2, s)
|
||||
// Binary Free Function : f1 OP FUNC(f2, s)
|
||||
|
||||
#define TFOR_ALL_F_OP_FUNC_F_S(typeF1, f1, OP, FUNC, typeF2, f2, typeS, s) \
|
||||
\
|
||||
@ -218,7 +255,7 @@ void checkFields
|
||||
}
|
||||
|
||||
|
||||
// Member function : s1 OP FUNC(f, s2)
|
||||
// [reduction] Binary Free Function : s1 OP FUNC(f, s2)
|
||||
|
||||
#define TFOR_ALL_S_OP_FUNC_F_S(typeS1, s1, OP, FUNC, typeF, f, typeS2, s2) \
|
||||
\
|
||||
@ -235,7 +272,7 @@ void checkFields
|
||||
}
|
||||
|
||||
|
||||
// Member function : this f1 OP FUNC(s, f2)
|
||||
// Binary Free Function : f1 OP FUNC(s, f2)
|
||||
|
||||
#define TFOR_ALL_F_OP_FUNC_S_F(typeF1, f1, OP, FUNC, typeS, s, typeF2, f2) \
|
||||
\
|
||||
@ -256,7 +293,7 @@ void checkFields
|
||||
}
|
||||
|
||||
|
||||
// Member function : this f1 OP FUNC(s1, s2)
|
||||
// Binary Free Function : f1 OP FUNC(s1, s2)
|
||||
|
||||
#define TFOR_ALL_F_OP_FUNC_S_S(typeF1, f1, OP, FUNC, typeS1, s1, typeS2, s2) \
|
||||
\
|
||||
@ -273,7 +310,7 @@ void checkFields
|
||||
}
|
||||
|
||||
|
||||
// Member function : this f1 OP f2 FUNC(s)
|
||||
// Unary Member Function : f1 OP f2 FUNC(s)
|
||||
|
||||
#define TFOR_ALL_F_OP_F_FUNC_S(typeF1, f1, OP, typeF2, f2, FUNC, typeS, s) \
|
||||
\
|
||||
@ -294,6 +331,56 @@ void checkFields
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Ternary Free Function : f1 OP FUNC(f2, f3, f4)
|
||||
|
||||
#define TFOR_ALL_F_OP_FUNC_F_F_F\
|
||||
(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3, typeF4, f4) \
|
||||
\
|
||||
/* Check fields have same size */ \
|
||||
checkFields(f1, f2, f3, f4, "f1 " #OP " " #FUNC "(f2, f3, f4)"); \
|
||||
\
|
||||
/* Field access */ \
|
||||
List_ACCESS(typeF1, f1, f1P); \
|
||||
List_CONST_ACCESS(typeF2, f2, f2P); \
|
||||
List_CONST_ACCESS(typeF3, f3, f3P); \
|
||||
List_CONST_ACCESS(typeF4, f4, f4P); \
|
||||
\
|
||||
/* Loop: f1 OP FUNC(f2, f3, f4) */ \
|
||||
const label loopLen = (f1).size(); \
|
||||
\
|
||||
/* pragmas... */ \
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
(f1P[i]) OP FUNC((f2P[i]), (f3P[i]), (f4P[i])); \
|
||||
}
|
||||
|
||||
// Ternary Free Function : f1 OP FUNC(f2, f3, s4)
|
||||
|
||||
#define TFOR_ALL_F_OP_FUNC_F_F_S\
|
||||
(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3, typeF4, s4) \
|
||||
\
|
||||
/* Check fields have same size */ \
|
||||
checkFields(f1, f2, f3, "f1 " #OP " " #FUNC "(f2, f3, s)"); \
|
||||
\
|
||||
/* Field access */ \
|
||||
List_ACCESS(typeF1, f1, f1P); \
|
||||
List_CONST_ACCESS(typeF2, f2, f2P); \
|
||||
List_CONST_ACCESS(typeF3, f3, f3P); \
|
||||
\
|
||||
/* Loop: f1 OP FUNC(f2, f3, s4) */ \
|
||||
const label loopLen = (f1).size(); \
|
||||
\
|
||||
/* pragmas... */ \
|
||||
for (label i = 0; i < loopLen; ++i) \
|
||||
{ \
|
||||
(f1P[i]) OP FUNC((f2P[i]), (f3P[i]), (s4)); \
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Member operator : this field f1 OP1 f2 OP2 f3
|
||||
|
||||
#define TFOR_ALL_F_OP_F_OP_F(typeF1, f1, OP1, typeF2, f2, OP2, typeF3, f3) \
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,10 +35,18 @@ namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// One-parameter versions
|
||||
|
||||
template<class TypeR, class Type1>
|
||||
struct reuseTmp
|
||||
{
|
||||
//- Pass-through to tmp New
|
||||
static tmp<Field<TypeR>> New(const Field<Type1>& f1)
|
||||
{
|
||||
return tmp<Field<TypeR>>::New(f1.size());
|
||||
}
|
||||
|
||||
//- Dissimilar types: just use size
|
||||
static tmp<Field<TypeR>> New(const tmp<Field<Type1>>& tf1)
|
||||
{
|
||||
return tmp<Field<TypeR>>::New(tf1().size());
|
||||
@ -49,8 +57,8 @@ struct reuseTmp
|
||||
template<class TypeR>
|
||||
struct reuseTmp<TypeR, TypeR>
|
||||
{
|
||||
//- Allow optional copy assignment of the initial content
|
||||
//- for identical input and output types
|
||||
//- Identical input and return types:
|
||||
//- allow optional copy assignment of the initial content
|
||||
static tmp<Field<TypeR>> New
|
||||
(
|
||||
const tmp<Field<TypeR>>& tf1,
|
||||
@ -85,9 +93,13 @@ template<class TypeR> tmp<Field<TypeR>> New
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Two-parameter versions
|
||||
|
||||
template<class TypeR, class Type1, class Type12, class Type2>
|
||||
struct reuseTmpTmp
|
||||
{
|
||||
//- Dissimilar types: just use size
|
||||
static tmp<Field<TypeR>> New
|
||||
(
|
||||
const tmp<Field<Type1>>& tf1,
|
||||
@ -102,6 +114,7 @@ struct reuseTmpTmp
|
||||
template<class TypeR, class Type1, class Type12>
|
||||
struct reuseTmpTmp<TypeR, Type1, Type12, TypeR>
|
||||
{
|
||||
//- Second input has return type
|
||||
static tmp<Field<TypeR>> New
|
||||
(
|
||||
const tmp<Field<Type1>>& tf1,
|
||||
@ -121,6 +134,7 @@ struct reuseTmpTmp<TypeR, Type1, Type12, TypeR>
|
||||
template<class TypeR, class Type2>
|
||||
struct reuseTmpTmp<TypeR, TypeR, TypeR, Type2>
|
||||
{
|
||||
//- First input has return type
|
||||
static tmp<Field<TypeR>> New
|
||||
(
|
||||
const tmp<Field<TypeR>>& tf1,
|
||||
@ -140,6 +154,7 @@ struct reuseTmpTmp<TypeR, TypeR, TypeR, Type2>
|
||||
template<class TypeR>
|
||||
struct reuseTmpTmp<TypeR, TypeR, TypeR, TypeR>
|
||||
{
|
||||
//- Both inputs have return type
|
||||
static tmp<Field<TypeR>> New
|
||||
(
|
||||
const tmp<Field<TypeR>>& tf1,
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,20 +27,40 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#undef UNARY_FUNCTION
|
||||
#undef UNARY_FUNCTION_TRANSFORM
|
||||
#undef UNARY_FUNCTION_INTERFACE
|
||||
|
||||
#undef UNARY_OPERATOR
|
||||
#undef UNARY_OPERATOR_TRANSFORM
|
||||
#undef UNARY_OPERATOR_INTERFACE
|
||||
|
||||
#undef BINARY_FUNCTION
|
||||
#undef BINARY_FUNCTION_TRANSFORM
|
||||
#undef BINARY_FUNCTION_INTERFACE
|
||||
|
||||
#undef BINARY_TYPE_FUNCTION
|
||||
#undef BINARY_TYPE_FUNCTION_SF
|
||||
#undef BINARY_TYPE_FUNCTION_FS
|
||||
#undef BINARY_TYPE_FUNCTION
|
||||
#undef BINARY_FUNCTION_TRANSFORM_SF
|
||||
#undef BINARY_FUNCTION_INTERFACE_SF
|
||||
#undef BINARY_FUNCTION_TRANSFORM_FS
|
||||
#undef BINARY_FUNCTION_INTERFACE_FS
|
||||
|
||||
#undef BINARY_OPERATOR
|
||||
|
||||
#undef BINARY_TYPE_OPERATOR
|
||||
#undef BINARY_TYPE_OPERATOR_SF
|
||||
#undef BINARY_TYPE_OPERATOR_FS
|
||||
#undef BINARY_TYPE_OPERATOR
|
||||
|
||||
#undef TERNARY_FUNCTION
|
||||
#undef TERNARY_FUNCTION_TRANSFORM
|
||||
#undef TERNARY_FUNCTION_INTERFACE
|
||||
#undef TERNARY_TYPE_FUNCTION
|
||||
#undef TERNARY_TYPE_FUNCTION_FFS
|
||||
#undef TERNARY_TYPE_FUNCTION_FSF
|
||||
#undef TERNARY_TYPE_FUNCTION_SFF
|
||||
#undef TERNARY_TYPE_FUNCTION_SSF
|
||||
#undef TERNARY_TYPE_FUNCTION_SFS
|
||||
#undef TERNARY_TYPE_FUNCTION_FSS
|
||||
|
||||
#undef TEMPLATE
|
||||
|
||||
|
||||
@ -1249,50 +1249,6 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::replace
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::clamp
|
||||
(
|
||||
const Type& lower,
|
||||
const Type& upper
|
||||
)
|
||||
{
|
||||
primitiveFieldRef().clamp(lower, upper);
|
||||
boundaryFieldRef().clamp(lower, upper);
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::clamp
|
||||
(
|
||||
const MinMax<Type>& range
|
||||
)
|
||||
{
|
||||
primitiveFieldRef().clamp(range.min(), range.max());
|
||||
boundaryFieldRef().clamp(range.min(), range.max());
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::clamp
|
||||
(
|
||||
const dimensioned<Type>& lower,
|
||||
const dimensioned<Type>& upper
|
||||
)
|
||||
{
|
||||
this->clamp(lower.value(), upper.value());
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::clamp
|
||||
(
|
||||
const dimensioned<MinMax<Type>>& range
|
||||
)
|
||||
{
|
||||
this->clamp(range.value());
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::clamp_min
|
||||
(
|
||||
@ -1335,6 +1291,50 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::clamp_max
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::clamp_range
|
||||
(
|
||||
const Type& lower,
|
||||
const Type& upper
|
||||
)
|
||||
{
|
||||
primitiveFieldRef().clamp_range(lower, upper);
|
||||
boundaryFieldRef().clamp_range(lower, upper);
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::clamp_range
|
||||
(
|
||||
const MinMax<Type>& range
|
||||
)
|
||||
{
|
||||
primitiveFieldRef().clamp_range(range.min(), range.max());
|
||||
boundaryFieldRef().clamp_range(range.min(), range.max());
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::clamp_range
|
||||
(
|
||||
const dimensioned<Type>& lower,
|
||||
const dimensioned<Type>& upper
|
||||
)
|
||||
{
|
||||
this->clamp_range(lower.value(), upper.value());
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::clamp_range
|
||||
(
|
||||
const dimensioned<MinMax<Type>>& range
|
||||
)
|
||||
{
|
||||
this->clamp_range(range.value());
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::negate()
|
||||
{
|
||||
|
||||
@ -629,26 +629,6 @@ public:
|
||||
const dimensioned<cmptType>& ds
|
||||
);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// A no-op for an invalid range.
|
||||
void clamp(const Type& lower, const Type& upper);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// A no-op for an invalid range.
|
||||
void clamp(const MinMax<Type>& range);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// A no-op for an invalid range. No dimension checking.
|
||||
void clamp
|
||||
(
|
||||
const dimensioned<Type>& lower,
|
||||
const dimensioned<Type>& upper
|
||||
);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// A no-op for an invalid range. No dimension checking.
|
||||
void clamp(const dimensioned<MinMax<Type>>& range);
|
||||
|
||||
//- Impose lower (floor) clamp on the field values (in-place)
|
||||
void clamp_min(const Type& lower);
|
||||
|
||||
@ -663,6 +643,26 @@ public:
|
||||
// No dimension checking
|
||||
void clamp_max(const dimensioned<Type>& upper);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// Does not check if range is valid or not. No dimension checking.
|
||||
void clamp_range(const dimensioned<MinMax<Type>>& range);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// Does not check if range is valid or not.
|
||||
void clamp_range(const Type& lower, const Type& upper);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// Does not check if range is valid or not.
|
||||
void clamp_range(const MinMax<Type>& range);
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// Does not check if range is valid or not. No dimension checking.
|
||||
void clamp_range
|
||||
(
|
||||
const dimensioned<Type>& lower,
|
||||
const dimensioned<Type>& upper
|
||||
);
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
@ -715,17 +715,17 @@ public:
|
||||
// Housekeeping
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// \deprecated(2023-01) prefer clamp() naming
|
||||
// \deprecated(2023-01) prefer clamp_range() naming
|
||||
void clip(const dimensioned<MinMax<Type>>& range)
|
||||
{
|
||||
this->clamp(range);
|
||||
this->clamp_range(range);
|
||||
}
|
||||
|
||||
//- Clamp field values (in-place) to the specified range.
|
||||
// \deprecated(2023-01) prefer clamp() naming
|
||||
// \deprecated(2023-01) prefer clamp_range() naming
|
||||
void clip(const dimensioned<Type>& lo, const dimensioned<Type>& hi)
|
||||
{
|
||||
this->clamp(lo.value(), hi.value());
|
||||
this->clamp_range(lo.value(), hi.value());
|
||||
}
|
||||
|
||||
//- Use minimum of the field and specified value. ie, clamp_max().
|
||||
@ -738,12 +738,12 @@ public:
|
||||
// \deprecated(2023-01) prefer clamp_min()
|
||||
void max(const dimensioned<Type>& lower) { this->clamp_min(lower); }
|
||||
|
||||
//- Deprecated(2019-01) identical to clamp()
|
||||
// \deprecated(2019-01) identical to clamp()
|
||||
FOAM_DEPRECATED_FOR(2019-01, "clamp() method")
|
||||
//- Deprecated(2019-01) identical to clamp_range()
|
||||
// \deprecated(2019-01) identical to clamp_range()
|
||||
FOAM_DEPRECATED_FOR(2019-01, "clamp_range() method")
|
||||
void maxMin(const dimensioned<Type>& lo, const dimensioned<Type>& hi)
|
||||
{
|
||||
return this->clamp(lo.value(), hi.value());
|
||||
return this->clamp_range(lo.value(), hi.value());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,7 +37,7 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void component
|
||||
@ -47,16 +47,16 @@ void component
|
||||
typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
|
||||
PatchField,
|
||||
GeoMesh
|
||||
>& gcf,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf,
|
||||
>& result,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1,
|
||||
const direction d
|
||||
);
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void T
|
||||
(
|
||||
GeometricField<Type, PatchField, GeoMesh>& gf,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf1
|
||||
GeometricField<Type, PatchField, GeoMesh>& result,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1
|
||||
);
|
||||
|
||||
template
|
||||
@ -68,8 +68,9 @@ template
|
||||
>
|
||||
void pow
|
||||
(
|
||||
GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>& gf,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf1
|
||||
GeometricField
|
||||
<typename powProduct<Type, r>::type, PatchField, GeoMesh>& result,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1
|
||||
);
|
||||
|
||||
template
|
||||
@ -86,7 +87,7 @@ tmp
|
||||
>
|
||||
pow
|
||||
(
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1,
|
||||
typename powProduct<Type, r>::type
|
||||
);
|
||||
|
||||
@ -104,7 +105,7 @@ tmp
|
||||
>
|
||||
pow
|
||||
(
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf,
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1,
|
||||
typename powProduct<Type, r>::type
|
||||
);
|
||||
|
||||
@ -112,7 +113,7 @@ template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void sqr
|
||||
(
|
||||
GeometricField
|
||||
<typename outerProduct<Type, Type>::type, PatchField, GeoMesh>& gf,
|
||||
<typename outerProduct<Type, Type>::type, PatchField, GeoMesh>& f1,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf1
|
||||
);
|
||||
|
||||
@ -126,7 +127,7 @@ tmp
|
||||
GeoMesh
|
||||
>
|
||||
>
|
||||
sqr(const GeometricField<Type, PatchField, GeoMesh>& gf);
|
||||
sqr(const GeometricField<Type, PatchField, GeoMesh>& f1);
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
tmp
|
||||
@ -138,48 +139,48 @@ tmp
|
||||
GeoMesh
|
||||
>
|
||||
>
|
||||
sqr(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf);
|
||||
sqr(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1);
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void magSqr
|
||||
(
|
||||
GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>& gsf,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf
|
||||
GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>& result,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1
|
||||
);
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
tmp<GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>>
|
||||
magSqr
|
||||
(
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1
|
||||
);
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
tmp<GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>>
|
||||
magSqr
|
||||
(
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1
|
||||
);
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void mag
|
||||
(
|
||||
GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>& gsf,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf
|
||||
GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>& result,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& tf1
|
||||
);
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
tmp<GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>>
|
||||
mag
|
||||
(
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1
|
||||
);
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
tmp<GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>>
|
||||
mag
|
||||
(
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1
|
||||
);
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
@ -190,8 +191,8 @@ void cmptAv
|
||||
typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
|
||||
PatchField,
|
||||
GeoMesh
|
||||
>& gcf,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf
|
||||
>& result,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1
|
||||
);
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
@ -204,7 +205,7 @@ tmp
|
||||
GeoMesh
|
||||
>
|
||||
>
|
||||
cmptAv(const GeometricField<Type, PatchField, GeoMesh>& gf);
|
||||
cmptAv(const GeometricField<Type, PatchField, GeoMesh>& f1);
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
tmp
|
||||
@ -216,21 +217,21 @@ tmp
|
||||
GeoMesh
|
||||
>
|
||||
>
|
||||
cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf);
|
||||
cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1);
|
||||
|
||||
|
||||
#define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, binaryOp) \
|
||||
#define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(ReturnType, Func, BinaryOp) \
|
||||
\
|
||||
template<class Type, template<class> class PatchField, class GeoMesh> \
|
||||
dimensioned<returnType> func \
|
||||
dimensioned<ReturnType> Func \
|
||||
( \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1 \
|
||||
); \
|
||||
\
|
||||
template<class Type, template<class> class PatchField, class GeoMesh> \
|
||||
dimensioned<returnType> func \
|
||||
dimensioned<ReturnType> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1 \
|
||||
);
|
||||
|
||||
UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, max, maxOp)
|
||||
@ -241,18 +242,18 @@ UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(scalarMinMax, minMaxMag, minMaxMagOp)
|
||||
#undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
|
||||
|
||||
|
||||
#define UNARY_REDUCTION_FUNCTION(returnType, func, gFunc) \
|
||||
#define UNARY_REDUCTION_FUNCTION(ReturnType, Func, gFunc) \
|
||||
\
|
||||
template<class Type, template<class> class PatchField, class GeoMesh> \
|
||||
dimensioned<returnType> func \
|
||||
dimensioned<ReturnType> Func \
|
||||
( \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1 \
|
||||
); \
|
||||
\
|
||||
template<class Type, template<class> class PatchField, class GeoMesh> \
|
||||
dimensioned<returnType> func \
|
||||
dimensioned<ReturnType> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1 \
|
||||
);
|
||||
|
||||
UNARY_REDUCTION_FUNCTION(Type, sum, gSum)
|
||||
@ -272,8 +273,44 @@ BINARY_TYPE_FUNCTION(Type, Type, Type, min)
|
||||
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
|
||||
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
|
||||
|
||||
// ------------------------------------------------------------------------- //
|
||||
|
||||
// * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
|
||||
// Clamp Methods
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void clamp
|
||||
(
|
||||
GeometricField<Type, PatchField, GeoMesh>& result,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1,
|
||||
const Foam::zero_one
|
||||
);
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
tmp<GeometricField<Type, PatchField, GeoMesh>>
|
||||
clamp
|
||||
(
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1,
|
||||
const Foam::zero_one
|
||||
);
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
tmp<GeometricField<Type, PatchField, GeoMesh>>
|
||||
clamp
|
||||
(
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1,
|
||||
const Foam::zero_one
|
||||
);
|
||||
|
||||
BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax<Type>, clamp)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
TERNARY_FUNCTION(Type, Type, Type, scalar, lerp)
|
||||
TERNARY_TYPE_FUNCTION_FFS(Type, Type, Type, scalar, lerp)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
UNARY_OPERATOR(Type, Type, -, negate, transform)
|
||||
|
||||
@ -289,16 +326,16 @@ BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define PRODUCT_OPERATOR(product, op, opFunc) \
|
||||
#define PRODUCT_OPERATOR(product, Op, OpFunc) \
|
||||
\
|
||||
template \
|
||||
<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
|
||||
void opFunc \
|
||||
void OpFunc \
|
||||
( \
|
||||
GeometricField \
|
||||
<typename product<Type1, Type2>::type, PatchField, GeoMesh>& gf, \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
|
||||
<typename product<Type1, Type2>::type, PatchField, GeoMesh>& result, \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
template \
|
||||
@ -308,10 +345,10 @@ tmp \
|
||||
GeometricField \
|
||||
<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
|
||||
> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
template \
|
||||
@ -321,10 +358,10 @@ tmp \
|
||||
GeometricField \
|
||||
<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
|
||||
> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tgf2 \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
|
||||
); \
|
||||
\
|
||||
template \
|
||||
@ -334,10 +371,10 @@ tmp \
|
||||
GeometricField \
|
||||
<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
|
||||
> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tgf1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
template \
|
||||
@ -347,19 +384,19 @@ tmp \
|
||||
GeometricField \
|
||||
<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
|
||||
> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tgf1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tgf2 \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
|
||||
); \
|
||||
\
|
||||
template \
|
||||
<class Form, class Type, template<class> class PatchField, class GeoMesh> \
|
||||
void opFunc \
|
||||
void OpFunc \
|
||||
( \
|
||||
GeometricField \
|
||||
<typename product<Type, Form>::type, PatchField, GeoMesh>& gf, \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf1, \
|
||||
<typename product<Type, Form>::type, PatchField, GeoMesh>& result, \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1, \
|
||||
const dimensioned<Form>& dvs \
|
||||
); \
|
||||
\
|
||||
@ -370,9 +407,9 @@ tmp \
|
||||
GeometricField \
|
||||
<typename product<Type, Form>::type, PatchField, GeoMesh> \
|
||||
> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf1, \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1, \
|
||||
const dimensioned<Form>& dvs \
|
||||
); \
|
||||
\
|
||||
@ -389,9 +426,9 @@ tmp \
|
||||
GeometricField \
|
||||
<typename product<Form, Type>::type, PatchField, GeoMesh> \
|
||||
> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf1, \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f1, \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs \
|
||||
); \
|
||||
\
|
||||
@ -402,9 +439,9 @@ tmp \
|
||||
GeometricField \
|
||||
<typename product<Type, Form>::type, PatchField, GeoMesh> \
|
||||
> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1, \
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1, \
|
||||
const dimensioned<Form>& dvs \
|
||||
); \
|
||||
\
|
||||
@ -421,20 +458,20 @@ tmp \
|
||||
GeometricField \
|
||||
<typename product<Form, Type>::type, PatchField, GeoMesh> \
|
||||
> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1, \
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1, \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs \
|
||||
); \
|
||||
\
|
||||
template \
|
||||
<class Form, class Type, template<class> class PatchField, class GeoMesh> \
|
||||
void opFunc \
|
||||
void OpFunc \
|
||||
( \
|
||||
GeometricField \
|
||||
<typename product<Form, Type>::type, PatchField, GeoMesh>& gf, \
|
||||
<typename product<Form, Type>::type, PatchField, GeoMesh>& result, \
|
||||
const dimensioned<Form>& dvs, \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf1 \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
template \
|
||||
@ -444,10 +481,10 @@ tmp \
|
||||
GeometricField \
|
||||
<typename product<Form, Type>::type, PatchField, GeoMesh> \
|
||||
> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const dimensioned<Form>& dvs, \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf1 \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
template \
|
||||
@ -463,10 +500,10 @@ tmp \
|
||||
GeometricField \
|
||||
<typename product<Form, Type>::type, PatchField, GeoMesh> \
|
||||
> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs, \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf1 \
|
||||
const GeometricField<Type, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
template \
|
||||
@ -476,10 +513,10 @@ tmp \
|
||||
GeometricField \
|
||||
<typename product<Form, Type>::type, PatchField, GeoMesh> \
|
||||
> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const dimensioned<Form>& dvs, \
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf2 \
|
||||
); \
|
||||
\
|
||||
template \
|
||||
@ -495,10 +532,10 @@ tmp \
|
||||
GeometricField \
|
||||
<typename product<Form, Type>::type, PatchField, GeoMesh> \
|
||||
> \
|
||||
operator op \
|
||||
operator Op \
|
||||
( \
|
||||
const VectorSpace<Form,Cmpt,nCmpt>& vs, \
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
|
||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf2 \
|
||||
);
|
||||
|
||||
PRODUCT_OPERATOR(typeOfSum, +, add)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,32 +31,46 @@ License
|
||||
#define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
void Func \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& df \
|
||||
GeometricField<ReturnType, PatchField, GeoMesh>& result, \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tdf1 \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1 \
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define UNARY_OPERATOR(ReturnType, Type1, Op, opFunc, Dfunc) \
|
||||
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
void OpFunc \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& df1 \
|
||||
GeometricField<ReturnType, PatchField, GeoMesh>& result, \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tdf1 \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1 \
|
||||
);
|
||||
|
||||
|
||||
@ -64,6 +79,14 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
GeometricField<ReturnType, PatchField, GeoMesh>& result, \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& df1, \
|
||||
@ -73,22 +96,22 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& df1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tdf2 \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tdf1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& df2 \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tdf1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tdf2 \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
|
||||
);
|
||||
|
||||
|
||||
@ -97,62 +120,78 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
#define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
void Func \
|
||||
( \
|
||||
GeometricField<ReturnType, PatchField, GeoMesh>& result, \
|
||||
const dimensioned<Type1>& dt1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& df2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const Type1& t1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& df2 \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const dimensioned<Type1>& dt1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tdf2 \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const Type1& t1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tdf2 \
|
||||
const Type1& s1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const dimensioned<Type1>& dt1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const Type1& s1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
|
||||
);
|
||||
|
||||
|
||||
#define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
void Func \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& df1, \
|
||||
GeometricField<ReturnType, PatchField, GeoMesh>& result, \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const dimensioned<Type2>& dt2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& df1, \
|
||||
const Type2& t2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tdf1, \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const dimensioned<Type2>& dt2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tdf2, \
|
||||
const Type2& t2 \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const Type2& s2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const dimensioned<Type2>& dt2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const Type2& s2 \
|
||||
);
|
||||
|
||||
|
||||
@ -166,95 +205,119 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
void OpFunc \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& df1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& df2 \
|
||||
GeometricField<ReturnType, PatchField, GeoMesh>& result, \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& df1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tdf2 \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tdf1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& df2 \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tdf1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tdf2 \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
|
||||
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
void OpFunc \
|
||||
( \
|
||||
GeometricField<ReturnType, PatchField, GeoMesh>& result, \
|
||||
const dimensioned<Type1>& dt1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& df2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const Type1& t1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& df2 \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const dimensioned<Type1>& dt1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tdf2 \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const Type1& t1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tdf2 \
|
||||
const Type1& s1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const dimensioned<Type1>& dt1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const Type1& s1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
|
||||
);
|
||||
|
||||
|
||||
#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
|
||||
#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
void OpFunc \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& df1, \
|
||||
GeometricField<ReturnType, PatchField, GeoMesh>& result, \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const dimensioned<Type2>& dt2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& df1, \
|
||||
const Type2& t2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tdf1, \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const dimensioned<Type2>& dt2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tdf1, \
|
||||
const Type2& t2 \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const Type2& s2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const dimensioned<Type2>& dt2 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const Type2& s2 \
|
||||
);
|
||||
|
||||
|
||||
@ -263,4 +326,158 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
|
||||
BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define TERNARY_FUNCTION(ReturnType, Type1, Type2, Type3, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
GeometricField<Type1, PatchField, GeoMesh>& result, \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2, \
|
||||
const GeometricField<Type3, PatchField, GeoMesh>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2, \
|
||||
const GeometricField<Type3, PatchField, GeoMesh>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2, \
|
||||
const GeometricField<Type3, PatchField, GeoMesh>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
|
||||
const GeometricField<Type3, PatchField, GeoMesh>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2, \
|
||||
const tmp<GeometricField<Type3, PatchField, GeoMesh>>& tf3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
|
||||
const GeometricField<Type3, PatchField, GeoMesh>& f3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2, \
|
||||
const tmp<GeometricField<Type3, PatchField, GeoMesh>>& tf3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
|
||||
const tmp<GeometricField<Type3, PatchField, GeoMesh>>& tf3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
|
||||
const tmp<GeometricField<Type3, PatchField, GeoMesh>>& tf3 \
|
||||
);
|
||||
|
||||
|
||||
#define TERNARY_TYPE_FUNCTION_FFS(ReturnType, Type1, Type2, Type3, Func) \
|
||||
\
|
||||
TEMPLATE \
|
||||
void Func \
|
||||
( \
|
||||
GeometricField<Type1, PatchField, GeoMesh>& result, \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2, \
|
||||
const dimensioned<Type3>& dt3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2, \
|
||||
const dimensioned<Type3>& dt3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2, \
|
||||
const Type3& s3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2, \
|
||||
const dimensioned<Type3>& dt3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const GeometricField<Type2, PatchField, GeoMesh>& f2, \
|
||||
const Type3& s3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
|
||||
const dimensioned<Type3>& dt3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
|
||||
const Type3& s3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
|
||||
const dimensioned<Type3>& dt3 \
|
||||
); \
|
||||
\
|
||||
TEMPLATE \
|
||||
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
|
||||
( \
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
|
||||
const Type3& s3 \
|
||||
);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -76,6 +76,7 @@ inline bool reusable
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// One-parameter versions
|
||||
|
||||
template
|
||||
<
|
||||
@ -86,24 +87,46 @@ template
|
||||
>
|
||||
struct reuseTmpGeometricField
|
||||
{
|
||||
//- Pass-through to New GeometricField
|
||||
static tmp<GeometricField<TypeR, PatchField, GeoMesh>> New
|
||||
(
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tgf1,
|
||||
const GeometricField<Type1, PatchField, GeoMesh>& f1,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions
|
||||
)
|
||||
{
|
||||
const auto& gf1 = tgf1();
|
||||
return tmp<GeometricField<TypeR, PatchField, GeoMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
f1.instance(),
|
||||
f1.db()
|
||||
),
|
||||
f1.mesh(),
|
||||
dimensions
|
||||
);
|
||||
}
|
||||
|
||||
//- Dissimilar types: return new field
|
||||
static tmp<GeometricField<TypeR, PatchField, GeoMesh>> New
|
||||
(
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions
|
||||
)
|
||||
{
|
||||
const auto& f1 = tf1();
|
||||
|
||||
return tmp<GeometricField<TypeR, PatchField, GeoMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
gf1.instance(),
|
||||
gf1.db()
|
||||
f1.instance(),
|
||||
f1.db()
|
||||
),
|
||||
gf1.mesh(),
|
||||
f1.mesh(),
|
||||
dimensions
|
||||
);
|
||||
}
|
||||
@ -117,41 +140,41 @@ struct reuseTmpGeometricField<TypeR, TypeR, PatchField, GeoMesh>
|
||||
//- for identical input and output types
|
||||
static tmp<GeometricField<TypeR, PatchField, GeoMesh>> New
|
||||
(
|
||||
const tmp<GeometricField<TypeR, PatchField, GeoMesh>>& tgf1,
|
||||
const tmp<GeometricField<TypeR, PatchField, GeoMesh>>& tf1,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions,
|
||||
const bool initCopy = false
|
||||
)
|
||||
{
|
||||
if (Detail::reusable(tgf1))
|
||||
if (Detail::reusable(tf1))
|
||||
{
|
||||
auto& gf1 = tgf1.constCast();
|
||||
auto& f1 = tf1.constCast();
|
||||
|
||||
gf1.rename(name);
|
||||
gf1.dimensions().reset(dimensions);
|
||||
return tgf1;
|
||||
f1.rename(name);
|
||||
f1.dimensions().reset(dimensions);
|
||||
return tf1;
|
||||
}
|
||||
|
||||
const auto& gf1 = tgf1();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
auto rtgf = tmp<GeometricField<TypeR, PatchField, GeoMesh>>::New
|
||||
auto tresult = tmp<GeometricField<TypeR, PatchField, GeoMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
gf1.instance(),
|
||||
gf1.db()
|
||||
f1.instance(),
|
||||
f1.db()
|
||||
),
|
||||
gf1.mesh(),
|
||||
f1.mesh(),
|
||||
dimensions
|
||||
);
|
||||
|
||||
if (initCopy)
|
||||
{
|
||||
rtgf.ref() == gf1;
|
||||
tresult.ref() == f1;
|
||||
}
|
||||
|
||||
return rtgf;
|
||||
return tresult;
|
||||
}
|
||||
};
|
||||
|
||||
@ -163,7 +186,7 @@ tmp
|
||||
GeometricField<TypeR, PatchField, GeoMesh>
|
||||
> New
|
||||
(
|
||||
const tmp<GeometricField<TypeR, PatchField, GeoMesh>>& tgf1,
|
||||
const tmp<GeometricField<TypeR, PatchField, GeoMesh>>& tf1,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions,
|
||||
const bool initCopy = false
|
||||
@ -171,7 +194,7 @@ tmp
|
||||
{
|
||||
return reuseTmpGeometricField<TypeR, TypeR, PatchField, GeoMesh>::New
|
||||
(
|
||||
tgf1,
|
||||
tf1,
|
||||
name,
|
||||
dimensions,
|
||||
initCopy
|
||||
@ -192,23 +215,23 @@ struct reuseTmpTmpGeometricField
|
||||
{
|
||||
static tmp<GeometricField<TypeR, PatchField, GeoMesh>> New
|
||||
(
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tgf1,
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tgf2,
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1,
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions
|
||||
)
|
||||
{
|
||||
const auto& gf1 = tgf1();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
return tmp<GeometricField<TypeR, PatchField, GeoMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
gf1.instance(),
|
||||
gf1.db()
|
||||
f1.instance(),
|
||||
f1.db()
|
||||
),
|
||||
gf1.mesh(),
|
||||
f1.mesh(),
|
||||
dimensions
|
||||
);
|
||||
}
|
||||
@ -230,32 +253,32 @@ struct reuseTmpTmpGeometricField
|
||||
{
|
||||
static tmp<GeometricField<TypeR, PatchField, GeoMesh>> New
|
||||
(
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tgf1,
|
||||
const tmp<GeometricField<TypeR, PatchField, GeoMesh>>& tgf2,
|
||||
const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1,
|
||||
const tmp<GeometricField<TypeR, PatchField, GeoMesh>>& tf2,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions
|
||||
)
|
||||
{
|
||||
if (Detail::reusable(tgf2))
|
||||
if (Detail::reusable(tf2))
|
||||
{
|
||||
auto& gf2 = tgf2.constCast();
|
||||
auto& f2 = tf2.constCast();
|
||||
|
||||
gf2.rename(name);
|
||||
gf2.dimensions().reset(dimensions);
|
||||
return tgf2;
|
||||
f2.rename(name);
|
||||
f2.dimensions().reset(dimensions);
|
||||
return tf2;
|
||||
}
|
||||
|
||||
const auto& gf1 = tgf1();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
return tmp<GeometricField<TypeR, PatchField, GeoMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
gf1.instance(),
|
||||
gf1.db()
|
||||
f1.instance(),
|
||||
f1.db()
|
||||
),
|
||||
gf1.mesh(),
|
||||
f1.mesh(),
|
||||
dimensions
|
||||
);
|
||||
}
|
||||
@ -276,32 +299,32 @@ struct reuseTmpTmpGeometricField
|
||||
{
|
||||
static tmp<GeometricField<TypeR, PatchField, GeoMesh>> New
|
||||
(
|
||||
const tmp<GeometricField<TypeR, PatchField, GeoMesh>>& tgf1,
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tgf2,
|
||||
const tmp<GeometricField<TypeR, PatchField, GeoMesh>>& tf1,
|
||||
const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions
|
||||
)
|
||||
{
|
||||
if (Detail::reusable(tgf1))
|
||||
if (Detail::reusable(tf1))
|
||||
{
|
||||
auto& gf1 = tgf1.constCast();
|
||||
auto& f1 = tf1.constCast();
|
||||
|
||||
gf1.rename(name);
|
||||
gf1.dimensions().reset(dimensions);
|
||||
return tgf1;
|
||||
f1.rename(name);
|
||||
f1.dimensions().reset(dimensions);
|
||||
return tf1;
|
||||
}
|
||||
|
||||
const auto& gf1 = tgf1();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
return tmp<GeometricField<TypeR, PatchField, GeoMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
gf1.instance(),
|
||||
gf1.db()
|
||||
f1.instance(),
|
||||
f1.db()
|
||||
),
|
||||
gf1.mesh(),
|
||||
f1.mesh(),
|
||||
dimensions
|
||||
);
|
||||
}
|
||||
@ -316,47 +339,46 @@ struct reuseTmpTmpGeometricField
|
||||
{
|
||||
static tmp<GeometricField<TypeR, PatchField, GeoMesh>> New
|
||||
(
|
||||
const tmp<GeometricField<TypeR, PatchField, GeoMesh>>& tgf1,
|
||||
const tmp<GeometricField<TypeR, PatchField, GeoMesh>>& tgf2,
|
||||
const tmp<GeometricField<TypeR, PatchField, GeoMesh>>& tf1,
|
||||
const tmp<GeometricField<TypeR, PatchField, GeoMesh>>& tf2,
|
||||
const word& name,
|
||||
const dimensionSet& dimensions
|
||||
)
|
||||
{
|
||||
if (Detail::reusable(tgf1))
|
||||
if (Detail::reusable(tf1))
|
||||
{
|
||||
auto& gf1 = tgf1.constCast();
|
||||
auto& f1 = tf1.constCast();
|
||||
|
||||
gf1.rename(name);
|
||||
gf1.dimensions().reset(dimensions);
|
||||
return tgf1;
|
||||
f1.rename(name);
|
||||
f1.dimensions().reset(dimensions);
|
||||
return tf1;
|
||||
}
|
||||
if (Detail::reusable(tgf2))
|
||||
if (Detail::reusable(tf2))
|
||||
{
|
||||
auto& gf2 = tgf2.constCast();
|
||||
auto& f2 = tf2.constCast();
|
||||
|
||||
gf2.rename(name);
|
||||
gf2.dimensions().reset(dimensions);
|
||||
return tgf2;
|
||||
f2.rename(name);
|
||||
f2.dimensions().reset(dimensions);
|
||||
return tf2;
|
||||
}
|
||||
|
||||
const auto& gf1 = tgf1();
|
||||
const auto& f1 = tf1();
|
||||
|
||||
return tmp<GeometricField<TypeR, PatchField, GeoMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
gf1.instance(),
|
||||
gf1.db()
|
||||
f1.instance(),
|
||||
f1.db()
|
||||
),
|
||||
gf1.mesh(),
|
||||
f1.mesh(),
|
||||
dimensions
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -149,7 +149,7 @@ Type Foam::uniformInterpolationTable<Type>::interpolate(scalar x) const
|
||||
{
|
||||
if (bound_)
|
||||
{
|
||||
x = max(min(xMax() - SMALL*dx_, x), x0_);
|
||||
x = clamp(x, x0_, (xMax() - SMALL*dx_));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -76,7 +76,7 @@ Foam::label Foam::face::mostConcaveAngle
|
||||
|
||||
// NOTE: is -ve angle since left edge pointing in other direction
|
||||
scalar edgeCos = (leftEdge & rightEdge);
|
||||
scalar edgeAngle = acos(max(-1.0, min(1.0, edgeCos)));
|
||||
scalar edgeAngle = acos(clamp(edgeCos, -1, 1));
|
||||
|
||||
scalar angle;
|
||||
|
||||
@ -205,7 +205,7 @@ Foam::label Foam::face::split
|
||||
splitEdge.normalise();
|
||||
|
||||
const scalar splitCos = splitEdge & rightEdge;
|
||||
const scalar splitAngle = acos(max(-1.0, min(1.0, splitCos)));
|
||||
const scalar splitAngle = acos(clamp(splitCos, -1, 1));
|
||||
const scalar angleDiff = fabs(splitAngle - bisectAngle);
|
||||
|
||||
if (angleDiff < minDiff)
|
||||
|
||||
@ -101,7 +101,7 @@ bool Foam::polyMesh::checkFaceOrthogonality
|
||||
<< " between cells " << own[facei]
|
||||
<< " and " << nei[facei]
|
||||
<< ": Angle = "
|
||||
<< radToDeg(::acos(min(1.0, max(-1.0, ortho[facei]))))
|
||||
<< radToDeg(::acos(clamp(ortho[facei], -1, 1)))
|
||||
<< " deg." << endl;
|
||||
}
|
||||
|
||||
@ -130,9 +130,9 @@ bool Foam::polyMesh::checkFaceOrthogonality
|
||||
if (debug || report)
|
||||
{
|
||||
Info<< " Mesh non-orthogonality Max: "
|
||||
<< radToDeg(::acos(min(1.0, max(-1.0, minDDotS))))
|
||||
<< radToDeg(::acos(clamp(minDDotS, -1, 1)))
|
||||
<< " average: "
|
||||
<< radToDeg(::acos(min(1.0, max(-1.0, sumDDotS/nSummed))))
|
||||
<< radToDeg(::acos(clamp(sumDDotS/nSummed, -1, 1)))
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -334,7 +334,7 @@ inline Foam::scalar Foam::triangle<Point, PointRef>::circumRadius() const
|
||||
}
|
||||
|
||||
const scalar a = (d1 + d2)*(d2 + d3)*(d3 + d1) / denom;
|
||||
return 0.5*Foam::sqrt(min(GREAT, max(0, a)));
|
||||
return 0.5*Foam::sqrt(clamp(a, 0, GREAT));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ inline Type Foam::Function1Types::InputValueMapper<Type>::value
|
||||
}
|
||||
case mappingMode::MINMAX:
|
||||
{
|
||||
scalar tlim = min(max(t, min_), max_);
|
||||
scalar tlim = clamp(t, min_, max_);
|
||||
|
||||
return value_->value(tlim);
|
||||
}
|
||||
@ -86,8 +86,8 @@ Type Foam::Function1Types::InputValueMapper<Type>::integrate
|
||||
}
|
||||
case mappingMode::MINMAX:
|
||||
{
|
||||
scalar xlim0 = min(max(x1, min_), max_);
|
||||
scalar xlim1 = min(max(x2, min_), max_);
|
||||
scalar xlim0 = clamp(x1, min_, max_);
|
||||
scalar xlim1 = clamp(x2, min_, max_);
|
||||
|
||||
Type intValue = value_->integrate(xlim0, xlim1);
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ protected:
|
||||
//- that forms the basis of many more complex ramp functions
|
||||
inline scalar linearRamp(const scalar t) const
|
||||
{
|
||||
return max(min((t - start_)/duration_, 1), 0);
|
||||
return clamp((t - start_)/duration_, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -85,6 +85,7 @@ Description
|
||||
#define Foam_MinMax_H
|
||||
|
||||
#include "scalar.H"
|
||||
#include "zero.H"
|
||||
#include "Pair.H"
|
||||
#include "Tuple2.H"
|
||||
#include "VectorSpace.H"
|
||||
@ -97,8 +98,6 @@ namespace Foam
|
||||
|
||||
// Forward Declarations
|
||||
template<class T> class MinMax;
|
||||
class zero;
|
||||
class zero_one;
|
||||
|
||||
// Common min/max types
|
||||
typedef MinMax<label> labelMinMax; //!< A label min/max range
|
||||
|
||||
@ -395,7 +395,7 @@ Foam::scalar Foam::diff(const triad& A, const triad& B)
|
||||
(tmpA[dir] & tmpB[dir])
|
||||
/(Foam::mag(tmpA[dir])*Foam::mag(tmpA[dir]) + SMALL);
|
||||
|
||||
cosPhi = min(max(cosPhi, -1), 1);
|
||||
cosPhi = clamp(cosPhi, -1, 1);
|
||||
|
||||
sumDifference += mag(cosPhi - 1);
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ tmp<volScalarField> SpalartAllmarasIDDES<BasicTurbulenceModel>::dTilda
|
||||
if (fe_)
|
||||
{
|
||||
tmp<volScalarField> fe1 =
|
||||
2*(pos0(alpha)*pow(expTerm, -11.09) + neg(alpha)*pow(expTerm, -9.));
|
||||
2*lerp(pow(expTerm, -9.), pow(expTerm, -11.09), pos0(alpha));
|
||||
tmp<volScalarField> fe2 = 1 - max(ft(magGradU), fl(magGradU));
|
||||
tmp<volScalarField> fe = max(fe1 - 1, scalar(0))*psi*fe2;
|
||||
|
||||
@ -129,7 +129,7 @@ tmp<volScalarField> SpalartAllmarasIDDES<BasicTurbulenceModel>::dTilda
|
||||
// Simplified formulation from Gritskevich et al. paper (2011) where fe = 0
|
||||
return max
|
||||
(
|
||||
fdTilda*lRAS + (1 - fdTilda)*lLES,
|
||||
lerp(lLES, lRAS, fdTilda),
|
||||
dimensionedScalar("SMALL", dimLength, SMALL)
|
||||
);
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ tmp<volScalarField> kOmegaSSTIDDES<BasicTurbulenceModel>::dTilda
|
||||
if (fe_)
|
||||
{
|
||||
tmp<volScalarField> fe1 =
|
||||
2*(pos0(alpha)*pow(expTerm, -11.09) + neg(alpha)*pow(expTerm, -9.));
|
||||
2*lerp(pow(expTerm, -9.), pow(expTerm, -11.09), pos0(alpha));
|
||||
tmp<volScalarField> fe2 = 1 - max(ft(magGradU), fl(magGradU));
|
||||
tmp<volScalarField> fe = max(fe1 - 1, scalar(0))*fe2;
|
||||
|
||||
@ -124,7 +124,7 @@ tmp<volScalarField> kOmegaSSTIDDES<BasicTurbulenceModel>::dTilda
|
||||
// Simplified formulation from Gritskevich et al. paper (2011) where fe = 0
|
||||
return max
|
||||
(
|
||||
fdTilda*lRAS + (1 - fdTilda)*lLES,
|
||||
lerp(lLES, lRAS, fdTilda),
|
||||
dimensionedScalar(dimLength, SMALL)
|
||||
);
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ volScalarField dynamicKEqn<BasicTurbulenceModel>::Ce() const
|
||||
(
|
||||
0.5*(filter_(magSqr(this->U_)) - magSqr(filter_(this->U_)))
|
||||
);
|
||||
KK.max(dimensionedScalar("small", KK.dimensions(), SMALL));
|
||||
KK.clamp_min(SMALL);
|
||||
|
||||
return Ce(D, KK);
|
||||
}
|
||||
@ -245,7 +245,7 @@ void dynamicKEqn<BasicTurbulenceModel>::correct()
|
||||
tgradU.clear();
|
||||
|
||||
volScalarField KK(0.5*(filter_(magSqr(U)) - magSqr(filter_(U))));
|
||||
KK.max(dimensionedScalar("small", KK.dimensions(), SMALL));
|
||||
KK.clamp_min(SMALL);
|
||||
|
||||
tmp<fvScalarMatrix> kEqn
|
||||
(
|
||||
|
||||
@ -157,7 +157,7 @@ void turbulentMixingLengthDissipationRateInletFvPatchScalarField::updateCoeffs()
|
||||
patch().lookupPatchField<surfaceScalarField>(this->phiName_);
|
||||
|
||||
this->refValue() = (Cmu75/mixingLength_)*pow(kp, 1.5);
|
||||
this->valueFraction() = 1.0 - pos0(phip);
|
||||
this->valueFraction() = neg(phip);
|
||||
|
||||
inletOutletFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ void turbulentMixingLengthFrequencyInletFvPatchScalarField::updateCoeffs()
|
||||
patch().lookupPatchField<surfaceScalarField>(this->phiName_);
|
||||
|
||||
this->refValue() = sqrt(kp)/(Cmu25*mixingLength_);
|
||||
this->valueFraction() = 1.0 - pos0(phip);
|
||||
this->valueFraction() = neg(phip);
|
||||
|
||||
inletOutletFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ tmp<volScalarField::Internal> kOmegaSSTLM<BasicTurbulenceModel>::epsilonByk
|
||||
) const
|
||||
{
|
||||
return
|
||||
min(max(gammaIntEff_, scalar(0.1)), scalar(1))
|
||||
clamp(gammaIntEff_, scalarMinMax(0.1, 1))
|
||||
*kOmegaSST<BasicTurbulenceModel>::epsilonByk(F1, gradU);
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ tmp<volScalarField::Internal> kOmegaSSTLM<BasicTurbulenceModel>::ReThetat0
|
||||
}
|
||||
|
||||
lambda = sqr(thetat)/nu[celli]*dUsds[celli];
|
||||
lambda = max(min(lambda, 0.1), -0.1);
|
||||
lambda = clamp(lambda, -0.1, 0.1);
|
||||
|
||||
lambdaErr = mag(lambda - lambda0);
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ tmp<volScalarField> realizableKE<BasicTurbulenceModel>::rCmu
|
||||
|
||||
volScalarField phis
|
||||
(
|
||||
(1.0/3.0)*acos(min(max(sqrt(6.0)*W, -scalar(1)), scalar(1)))
|
||||
(1.0/3.0)*acos(clamp(sqrt(6.0)*W, scalarMinMax(-1, 1)))
|
||||
);
|
||||
volScalarField As(sqrt(6.0)*cos(phis));
|
||||
volScalarField Us(sqrt(S2/2.0 + magSqr(skew(gradU))));
|
||||
|
||||
@ -39,20 +39,15 @@ void Foam::ReynoldsStress<BasicTurbulenceModel>::boundNormalStress
|
||||
volSymmTensorField& R
|
||||
) const
|
||||
{
|
||||
scalar kMin = this->kMin_.value();
|
||||
const scalar kMin = this->kMin_.value();
|
||||
|
||||
R.max
|
||||
R.clamp_min
|
||||
(
|
||||
dimensionedSymmTensor
|
||||
symmTensor
|
||||
(
|
||||
"zero",
|
||||
R.dimensions(),
|
||||
symmTensor
|
||||
(
|
||||
kMin, -GREAT, -GREAT,
|
||||
kMin, -GREAT,
|
||||
kMin
|
||||
)
|
||||
kMin, -GREAT, -GREAT,
|
||||
kMin, -GREAT,
|
||||
kMin
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -109,13 +109,13 @@ void Foam::combustionModels::EDC<ReactionThermo>::correct()
|
||||
const scalar nu = mu[i]/(rho[i] + SMALL);
|
||||
|
||||
const scalar Da =
|
||||
max(min(sqrt(nu/(epsilon[i] + SMALL))/tc[i], 10), 1e-10);
|
||||
clamp(sqrt(nu/(epsilon[i] + SMALL))/tc[i], 1e-10, 10);
|
||||
|
||||
const scalar ReT = sqr(k[i])/(nu*epsilon[i] + SMALL);
|
||||
const scalar CtauI = min(C1_/(Da*sqrt(ReT + 1)), 2.1377);
|
||||
|
||||
const scalar CgammaI =
|
||||
max(min(C2_*sqrt(Da*(ReT + 1)), 5), 0.4082);
|
||||
clamp(C2_*sqrt(Da*(ReT + 1)), 0.4082, 5);
|
||||
|
||||
const scalar gammaL =
|
||||
CgammaI*pow025(nu*epsilon[i]/(sqr(k[i]) + SMALL));
|
||||
|
||||
@ -136,8 +136,7 @@ void Foam::reactionRateFlameAreaModels::relaxation::correct
|
||||
- fvm::SuSp(rho*(tau + Rc), omega_)
|
||||
);
|
||||
|
||||
omega_.min(omega0);
|
||||
omega_.max(0.0);
|
||||
omega_.clamp_range(0, omega0.value());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@
|
||||
);
|
||||
dimensionedScalar AkEst = gSum(mgb*mesh.V().field());
|
||||
|
||||
StCorr.value() = max(min((Ak/AkEst).value(), 10.0), 1.0);
|
||||
StCorr.value() = clamp((Ak/AkEst).value(), 1, 10);
|
||||
|
||||
Info<< "StCorr = " << StCorr.value() << endl;
|
||||
}
|
||||
|
||||
@ -130,8 +130,12 @@ void Foam::coupledFaPatchField<Type>::evaluate(const Pstream::commsTypes)
|
||||
{
|
||||
Field<Type>::operator=
|
||||
(
|
||||
this->patch().weights()*this->patchInternalField()
|
||||
+ (1.0 - this->patch().weights())*patchNeighbourField()
|
||||
lerp
|
||||
(
|
||||
this->patchNeighbourField(),
|
||||
this->patchInternalField(),
|
||||
this->patch().weights()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -198,12 +198,11 @@ void Foam::mixedFaPatchField<Type>::evaluate(const Pstream::commsTypes)
|
||||
|
||||
Field<Type>::operator=
|
||||
(
|
||||
valueFraction_*refValue_
|
||||
+
|
||||
(1.0 - valueFraction_)*
|
||||
lerp
|
||||
(
|
||||
this->patchInternalField()
|
||||
+ refGrad_/this->patch().deltaCoeffs()
|
||||
this->patchInternalField() + refGrad_/this->patch().deltaCoeffs(),
|
||||
refValue_,
|
||||
valueFraction_
|
||||
)
|
||||
);
|
||||
|
||||
@ -214,11 +213,12 @@ void Foam::mixedFaPatchField<Type>::evaluate(const Pstream::commsTypes)
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::mixedFaPatchField<Type>::snGrad() const
|
||||
{
|
||||
return
|
||||
return lerp
|
||||
(
|
||||
refGrad_,
|
||||
(refValue_ - this->patchInternalField())*this->patch().deltaCoeffs(),
|
||||
valueFraction_
|
||||
*(refValue_ - this->patchInternalField())
|
||||
*this->patch().deltaCoeffs()
|
||||
+ (1.0 - valueFraction_)*refGrad_;
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -238,9 +238,12 @@ Foam::tmp<Foam::Field<Type>> Foam::mixedFaPatchField<Type>::valueBoundaryCoeffs
|
||||
const tmp<scalarField>&
|
||||
) const
|
||||
{
|
||||
return
|
||||
valueFraction_*refValue_
|
||||
+ (1.0 - valueFraction_)*refGrad_/this->patch().deltaCoeffs();
|
||||
return lerp
|
||||
(
|
||||
refGrad_/this->patch().deltaCoeffs(),
|
||||
refValue_,
|
||||
valueFraction_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -256,9 +259,12 @@ template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::mixedFaPatchField<Type>::gradientBoundaryCoeffs() const
|
||||
{
|
||||
return
|
||||
valueFraction_*this->patch().deltaCoeffs()*refValue_
|
||||
+ (1.0 - valueFraction_)*refGrad_;
|
||||
return lerp
|
||||
(
|
||||
refGrad_,
|
||||
this->patch().deltaCoeffs()*refValue_,
|
||||
valueFraction_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -126,7 +126,7 @@ void Foam::inletOutletFaPatchField<Type>::updateCoeffs()
|
||||
const Field<scalar>& phip =
|
||||
this->patch().template lookupPatchField<edgeScalarField>(phiName_);
|
||||
|
||||
this->valueFraction() = 1.0 - pos(phip);
|
||||
this->valueFraction() = neg(phip);
|
||||
|
||||
mixedFaPatchField<Type>::updateCoeffs();
|
||||
}
|
||||
|
||||
@ -529,11 +529,7 @@ void Foam::edgeInterpolation::makeCorrectionVectors() const
|
||||
if (owner.size() > 0)
|
||||
{
|
||||
scalarField sinAlpha(deltaCoeffs*mag(CorrVecs.internalField()));
|
||||
|
||||
forAll(sinAlpha, edgeI)
|
||||
{
|
||||
sinAlpha[edgeI] = max(-1, min(sinAlpha[edgeI], 1));
|
||||
}
|
||||
sinAlpha.clamp_range(-1, 1);
|
||||
|
||||
NonOrthogCoeff = max(Foam::asin(sinAlpha)*180.0/M_PI);
|
||||
}
|
||||
|
||||
@ -110,9 +110,9 @@ public:
|
||||
gradcf = stabilise(gradcf, SMALL);
|
||||
|
||||
scalar phict = 1 - 0.5*gradf/gradcf;
|
||||
scalar limiter = min(max(phict/k_, 0), 1);
|
||||
scalar limiter = clamp(phict/k_, 0, 1);
|
||||
|
||||
return limiter*cdWeight + (1 - limiter)*udWeight;
|
||||
return lerp(udWeight, cdWeight, limiter);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ void Foam::SRFFreestreamVelocityFvPatchVectorField::updateCoeffs()
|
||||
}
|
||||
|
||||
// Set the inlet-outlet choice based on the direction of the freestream
|
||||
valueFraction() = 1.0 - pos0(refValue() & patch().Sf());
|
||||
valueFraction() = neg(refValue() & patch().Sf());
|
||||
|
||||
mixedFvPatchField<vector>::updateCoeffs();
|
||||
}
|
||||
|
||||
@ -234,25 +234,14 @@ Foam::exprMixedFvPatchField<Type>::exprMixedFvPatchField
|
||||
}
|
||||
else
|
||||
{
|
||||
// Emulate mixedFvPatchField<Type>::evaluate,
|
||||
// Like mixedFvPatchField<Type>::evaluate()
|
||||
// but avoid our own updateCoeffs
|
||||
if (!this->updated())
|
||||
{
|
||||
this->parent_bctype::updateCoeffs();
|
||||
mixedFvPatchField<Type>::updateCoeffs();
|
||||
}
|
||||
|
||||
Field<Type>::operator=
|
||||
(
|
||||
this->valueFraction()*this->refValue()
|
||||
+
|
||||
(1.0 - this->valueFraction())*
|
||||
(
|
||||
this->patchInternalField()
|
||||
+ this->refGrad()/this->patch().deltaCoeffs()
|
||||
)
|
||||
);
|
||||
|
||||
fvPatchField<Type>::evaluate();
|
||||
mixedFvPatchField<Type>::evaluate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -139,8 +139,12 @@ void Foam::coupledFvPatchField<Type>::evaluate(const Pstream::commsTypes)
|
||||
|
||||
Field<Type>::operator=
|
||||
(
|
||||
this->patch().weights()*this->patchInternalField()
|
||||
+ (1.0 - this->patch().weights())*this->patchNeighbourField()
|
||||
lerp
|
||||
(
|
||||
this->patchNeighbourField(),
|
||||
this->patchInternalField(),
|
||||
this->patch().weights()
|
||||
)
|
||||
);
|
||||
|
||||
fvPatchField<Type>::evaluate();
|
||||
|
||||
@ -209,7 +209,6 @@ void Foam::mixedFvPatchField<Type>::rmap
|
||||
template<class Type>
|
||||
void Foam::mixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
|
||||
{
|
||||
|
||||
if (!this->updated())
|
||||
{
|
||||
this->updateCoeffs();
|
||||
@ -217,11 +216,11 @@ void Foam::mixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
|
||||
|
||||
Field<Type>::operator=
|
||||
(
|
||||
valueFraction_*refValue_
|
||||
+ (1.0 - valueFraction_)
|
||||
*(
|
||||
this->patchInternalField()
|
||||
+ refGrad_/this->patch().deltaCoeffs()
|
||||
lerp
|
||||
(
|
||||
this->patchInternalField() + refGrad_/this->patch().deltaCoeffs(),
|
||||
refValue_,
|
||||
valueFraction_
|
||||
)
|
||||
);
|
||||
|
||||
@ -233,11 +232,12 @@ template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::mixedFvPatchField<Type>::snGrad() const
|
||||
{
|
||||
return
|
||||
return lerp
|
||||
(
|
||||
refGrad_,
|
||||
(refValue_ - this->patchInternalField())*this->patch().deltaCoeffs(),
|
||||
valueFraction_
|
||||
*(refValue_ - this->patchInternalField())
|
||||
*this->patch().deltaCoeffs()
|
||||
+ (1.0 - valueFraction_)*refGrad_;
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -259,9 +259,12 @@ Foam::mixedFvPatchField<Type>::valueBoundaryCoeffs
|
||||
const tmp<scalarField>&
|
||||
) const
|
||||
{
|
||||
return
|
||||
valueFraction_*refValue_
|
||||
+ (1.0 - valueFraction_)*refGrad_/this->patch().deltaCoeffs();
|
||||
return lerp
|
||||
(
|
||||
refGrad_/this->patch().deltaCoeffs(),
|
||||
refValue_,
|
||||
valueFraction_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -277,9 +280,12 @@ template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::mixedFvPatchField<Type>::gradientBoundaryCoeffs() const
|
||||
{
|
||||
return
|
||||
valueFraction_*this->patch().deltaCoeffs()*refValue_
|
||||
+ (1.0 - valueFraction_)*refGrad_;
|
||||
return lerp
|
||||
(
|
||||
refGrad_,
|
||||
this->patch().deltaCoeffs()*refValue_,
|
||||
valueFraction_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -249,22 +249,18 @@ void Foam::activeBaffleVelocityFvPatchVectorField::updateCoeffs()
|
||||
}
|
||||
|
||||
openFraction_ =
|
||||
max
|
||||
(
|
||||
min
|
||||
openFraction_
|
||||
+ min
|
||||
(
|
||||
openFraction_
|
||||
+ min
|
||||
(
|
||||
this->db().time().deltaTValue()/openingTime_,
|
||||
maxOpenFractionDelta_
|
||||
)
|
||||
*(orientation_*sign(forceDiff)),
|
||||
1 - 1e-6
|
||||
),
|
||||
1e-6
|
||||
this->db().time().deltaTValue()/openingTime_,
|
||||
maxOpenFractionDelta_
|
||||
)
|
||||
*(orientation_*sign(forceDiff))
|
||||
);
|
||||
|
||||
openFraction_ = clamp(openFraction_, 1e-6, 1 - 1e-6);
|
||||
|
||||
Info<< "openFraction = " << openFraction_ << endl;
|
||||
|
||||
vectorField::subField Sfw = this->patch().patch().faceAreas();
|
||||
|
||||
@ -299,27 +299,18 @@ void Foam::activePressureForceBaffleVelocityFvPatchVectorField::updateCoeffs()
|
||||
if (mag(valueDiff) > mag(minThresholdValue_) || baffleActivated_)
|
||||
{
|
||||
openFraction_ =
|
||||
max
|
||||
(
|
||||
openFraction_
|
||||
+ min
|
||||
(
|
||||
min
|
||||
(
|
||||
openFraction_
|
||||
+ min
|
||||
(
|
||||
this->db().time().deltaT().value()/openingTime_,
|
||||
maxOpenFractionDelta_
|
||||
),
|
||||
1 - 1e-6
|
||||
),
|
||||
1e-6
|
||||
);
|
||||
this->db().time().deltaT().value()/openingTime_,
|
||||
maxOpenFractionDelta_
|
||||
)
|
||||
);
|
||||
|
||||
baffleActivated_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
openFraction_ = max(min(1 - 1e-6, openFraction_), 1e-6);
|
||||
baffleActivated_ = true;
|
||||
}
|
||||
openFraction_ = clamp(openFraction_, 1e-6, 1 - 1e-6);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
|
||||
@ -212,7 +212,7 @@ void Foam::fixedJumpFvPatchField<Type>::relax()
|
||||
return;
|
||||
}
|
||||
|
||||
jump_ = relaxFactor_*jump_ + (1 - relaxFactor_)*jump0_;
|
||||
jump_ = lerp(jump0_, jump_, relaxFactor_);
|
||||
|
||||
if (timeIndex_ != this->db().time().timeIndex())
|
||||
{
|
||||
|
||||
@ -128,7 +128,7 @@ void Foam::inletOutletFvPatchField<Type>::updateCoeffs()
|
||||
const Field<scalar>& phip =
|
||||
this->patch().template lookupPatchField<surfaceScalarField>(phiName_);
|
||||
|
||||
this->valueFraction() = 1.0 - pos0(phip);
|
||||
this->valueFraction() = neg(phip);
|
||||
|
||||
mixedFvPatchField<Type>::updateCoeffs();
|
||||
}
|
||||
|
||||
@ -181,8 +181,8 @@ void Foam::inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs()
|
||||
scalar gM1ByG = (gamma_ - 1.0)/gamma_;
|
||||
|
||||
this->refValue() =
|
||||
T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos0(phip))*magSqr(Up));
|
||||
this->valueFraction() = 1.0 - pos0(phip);
|
||||
T0_/(1.0 + 0.5*psip*gM1ByG*(neg(phip))*magSqr(Up));
|
||||
this->valueFraction() = neg(phip);
|
||||
|
||||
inletOutletFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
@ -153,8 +153,12 @@ Foam::partialSlipFvPatchField<Type>::snGrad() const
|
||||
|
||||
return
|
||||
(
|
||||
valueFraction_*refValue_
|
||||
+ (1.0 - valueFraction_)*transform(I - sqr(nHat), pif) - pif
|
||||
lerp
|
||||
(
|
||||
transform(I - sqr(nHat), pif),
|
||||
refValue_,
|
||||
valueFraction_
|
||||
) - pif
|
||||
)*this->patch().deltaCoeffs();
|
||||
}
|
||||
|
||||
@ -174,10 +178,12 @@ void Foam::partialSlipFvPatchField<Type>::evaluate
|
||||
|
||||
Field<Type>::operator=
|
||||
(
|
||||
valueFraction_*refValue_
|
||||
+
|
||||
(1.0 - valueFraction_)
|
||||
*transform(I - sqr(nHat), this->patchInternalField())
|
||||
lerp
|
||||
(
|
||||
transform(I - sqr(nHat), this->patchInternalField()),
|
||||
refValue_,
|
||||
valueFraction_
|
||||
)
|
||||
);
|
||||
|
||||
parent_bctype::evaluate();
|
||||
|
||||
@ -148,9 +148,9 @@ void Foam::phaseHydrostaticPressureFvPatchScalarField::updateCoeffs()
|
||||
meshObjects::gravity::New(db().time());
|
||||
|
||||
// scalar rhor = 1000;
|
||||
// scalarField alphap1 = max(min(alphap, scalar(1)), scalar(0));
|
||||
// scalarField alphap1 = clamp(alphap, zero_one{});
|
||||
// valueFraction() = alphap1/(alphap1 + rhor*(1.0 - alphap1));
|
||||
valueFraction() = max(min(alphap, scalar(1)), scalar(0));
|
||||
valueFraction() = clamp(alphap, zero_one{});
|
||||
|
||||
refValue() =
|
||||
pRefValue_
|
||||
@ -180,7 +180,7 @@ void Foam::phaseHydrostaticPressureFvPatchScalarField::operator=
|
||||
{
|
||||
fvPatchScalarField::operator=
|
||||
(
|
||||
valueFraction()*refValue() + (1 - valueFraction())*ptf
|
||||
lerp(ptf, refValue(), valueFraction())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -272,7 +272,12 @@ void Foam::plenumPressureFvPatchScalarField::updateCoeffs()
|
||||
// Limit to prevent outflow
|
||||
const scalarField p_new
|
||||
(
|
||||
(1.0 - pos0(phi))*t*plenumPressure + pos0(phi)*max(p, plenumPressure)
|
||||
lerp
|
||||
(
|
||||
t*plenumPressure, // Negative phi
|
||||
max(p, plenumPressure), // Positive phi
|
||||
pos0(phi) // 0-1 selector
|
||||
)
|
||||
);
|
||||
|
||||
// Relaxation fraction
|
||||
@ -280,7 +285,7 @@ void Foam::plenumPressureFvPatchScalarField::updateCoeffs()
|
||||
const scalar fraction = oneByFraction < 1.0 ? 1.0 : 1.0/oneByFraction;
|
||||
|
||||
// Set the new value
|
||||
operator==((1.0 - fraction)*p_old + fraction*p_new);
|
||||
operator==(lerp(p_old, p_new, fraction));
|
||||
fixedValueFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -176,7 +176,7 @@ void Foam::pressureDirectedInletOutletVelocityFvPatchVectorField::updateCoeffs()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
valueFraction() = 1.0 - pos0(phip);
|
||||
valueFraction() = neg(phip);
|
||||
|
||||
mixedFvPatchVectorField::updateCoeffs();
|
||||
}
|
||||
@ -204,8 +204,7 @@ void Foam::pressureDirectedInletOutletVelocityFvPatchVectorField::operator=
|
||||
{
|
||||
fvPatchField<vector>::operator=
|
||||
(
|
||||
valueFraction()*(inletDir_*(inletDir_ & pvf))
|
||||
+ (1 - valueFraction())*pvf
|
||||
lerp(pvf, inletDir_*(inletDir_ & pvf), valueFraction())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -150,7 +150,7 @@ void Foam::pressureInletOutletParSlipVelocityFvPatchVectorField::updateCoeffs()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
valueFraction() = 1.0 - pos0(phip);
|
||||
valueFraction() = neg(phip);
|
||||
|
||||
mixedFvPatchVectorField::updateCoeffs();
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -146,7 +146,7 @@ void Foam::pressureNormalInletOutletVelocityFvPatchVectorField::updateCoeffs()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
valueFraction() = 1.0 - pos0(phip);
|
||||
valueFraction() = neg(phip);
|
||||
|
||||
mixedFvPatchVectorField::updateCoeffs();
|
||||
}
|
||||
@ -171,10 +171,11 @@ void Foam::pressureNormalInletOutletVelocityFvPatchVectorField::operator=
|
||||
const fvPatchField<vector>& pvf
|
||||
)
|
||||
{
|
||||
tmp<vectorField> n = patch().nf();
|
||||
|
||||
fvPatchField<vector>::operator=
|
||||
(
|
||||
valueFraction()*(patch().nf()*(patch().nf() & pvf))
|
||||
+ (1 - valueFraction())*pvf
|
||||
lerp(pvf, n()*(n() & pvf), valueFraction())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -155,7 +155,7 @@ updateCoeffs()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
valueFraction() = 1.0 - pos0(phip);
|
||||
valueFraction() = neg(phip);
|
||||
|
||||
if (alphaName_ != "none")
|
||||
{
|
||||
@ -202,8 +202,7 @@ void Foam::pressurePermeableAlphaInletOutletVelocityFvPatchVectorField
|
||||
|
||||
fvPatchField<vector>::operator=
|
||||
(
|
||||
valueFraction()*(n()*(n() & pvf))
|
||||
+ (1 - valueFraction())*pvf
|
||||
lerp(pvf, n()*(n() & pvf), valueFraction())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -215,7 +215,7 @@ void Foam::prghPermeableAlphaTotalPressureFvPatchScalarField::updateSnGrad
|
||||
tmp<scalarField> p
|
||||
(
|
||||
p0_->value(t)
|
||||
- 0.5*rhop*(1.0 - pos0(phip))*magSqr(Up)
|
||||
- 0.5*rhop*(neg(phip))*magSqr(Up)
|
||||
- rhop*((g.value() & patch().Cf()) - ghRef.value())
|
||||
);
|
||||
|
||||
|
||||
@ -136,7 +136,7 @@ void Foam::prghTotalHydrostaticPressureFvPatchScalarField::updateCoeffs()
|
||||
operator==
|
||||
(
|
||||
ph_rghp
|
||||
- 0.5*rhop*(1.0 - pos0(phip))*magSqr(Up)
|
||||
- 0.5*rhop*(neg(phip))*magSqr(Up)
|
||||
);
|
||||
|
||||
fixedValueFvPatchScalarField::updateCoeffs();
|
||||
|
||||
@ -178,7 +178,7 @@ void Foam::prghTotalPressureFvPatchScalarField::updateCoeffs()
|
||||
operator==
|
||||
(
|
||||
p0_
|
||||
- 0.5*rhop*(1.0 - pos0(phip))*magSqr(Up)
|
||||
- 0.5*rhop*(neg(phip))*magSqr(Up)
|
||||
- rhop*((g.value() & patch().Cf()) - ghRef.value())
|
||||
);
|
||||
|
||||
|
||||
@ -178,7 +178,7 @@ void Foam::totalPressureFvPatchScalarField::updateCoeffs
|
||||
const auto& rho =
|
||||
patch().lookupPatchField<volScalarField>(rhoName_);
|
||||
|
||||
operator==(p0p - 0.5*rho*(1.0 - pos0(phip))*magSqr(Up));
|
||||
operator==(p0p - 0.5*rho*(neg(phip))*magSqr(Up));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -196,14 +196,14 @@ void Foam::totalPressureFvPatchScalarField::updateCoeffs
|
||||
p0p
|
||||
/pow
|
||||
(
|
||||
(1.0 + 0.5*psip*gM1ByG*(1.0 - pos0(phip))*magSqr(Up)),
|
||||
(1.0 + 0.5*psip*gM1ByG*(neg(phip))*magSqr(Up)),
|
||||
1.0/gM1ByG
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
operator==(p0p/(1.0 + 0.5*psip*(1.0 - pos0(phip))*magSqr(Up)));
|
||||
operator==(p0p/(1.0 + 0.5*psip*(neg(phip))*magSqr(Up)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ void Foam::totalPressureFvPatchScalarField::updateCoeffs
|
||||
else if (internalField().dimensions() == dimPressure/dimDensity)
|
||||
{
|
||||
// Incompressible flow
|
||||
operator==(p0p - 0.5*(1.0 - pos0(phip))*magSqr(Up));
|
||||
operator==(p0p - 0.5*(neg(phip))*magSqr(Up));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -170,7 +170,7 @@ void Foam::totalTemperatureFvPatchScalarField::updateCoeffs()
|
||||
|
||||
operator==
|
||||
(
|
||||
T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos0(phip))*magSqr(Up))
|
||||
T0_/(1.0 + 0.5*psip*gM1ByG*(neg(phip))*magSqr(Up))
|
||||
);
|
||||
|
||||
fixedValueFvPatchScalarField::updateCoeffs();
|
||||
|
||||
@ -140,7 +140,7 @@ updateCoeffs()
|
||||
patch().lookupPatchField<surfaceScalarField>(this->phiName_);
|
||||
|
||||
this->refValue() = 1.5*sqr(intensity_)*magSqr(Up);
|
||||
this->valueFraction() = 1.0 - pos0(phip);
|
||||
this->valueFraction() = neg(phip);
|
||||
|
||||
inletOutletFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ void Foam::uniformInletOutletFvPatchField<Type>::updateCoeffs()
|
||||
phiName_
|
||||
);
|
||||
|
||||
this->valueFraction() = 1.0 - pos0(phip);
|
||||
this->valueFraction() = neg(phip);
|
||||
|
||||
mixedFvPatchField<Type>::updateCoeffs();
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ void Foam::uniformTotalPressureFvPatchScalarField::updateCoeffs
|
||||
const auto& rho =
|
||||
patch().lookupPatchField<volScalarField>(rhoName_);
|
||||
|
||||
operator==(p0 - 0.5*rho*(1.0 - pos0(phip))*magSqr(Up));
|
||||
operator==(p0 - 0.5*rho*(neg(phip))*magSqr(Up));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -184,14 +184,14 @@ void Foam::uniformTotalPressureFvPatchScalarField::updateCoeffs
|
||||
p0
|
||||
/pow
|
||||
(
|
||||
(1.0 + 0.5*psip*gM1ByG*(1.0 - pos0(phip))*magSqr(Up)),
|
||||
(1.0 + 0.5*psip*gM1ByG*(neg(phip))*magSqr(Up)),
|
||||
1.0/gM1ByG
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
operator==(p0/(1.0 + 0.5*psip*(1.0 - pos0(phip))*magSqr(Up)));
|
||||
operator==(p0/(1.0 + 0.5*psip*(neg(phip))*magSqr(Up)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,7 +199,7 @@ void Foam::uniformTotalPressureFvPatchScalarField::updateCoeffs
|
||||
else if (internalField().dimensions() == dimPressure/dimDensity)
|
||||
{
|
||||
// Incompressible flow
|
||||
operator==(p0 - 0.5*(1.0 - pos0(phip))*magSqr(Up));
|
||||
operator==(p0 - 0.5*(neg(phip))*magSqr(Up));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user