STYLE: modernize code for GeometricFieldFunctions (#1160)

- use forwarding tmp factory methods, auto types
This commit is contained in:
Mark Olesen
2019-01-10 17:06:04 +01:00
parent b002a232d6
commit 7e48f2c6b3
4 changed files with 234 additions and 294 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1021,9 +1021,7 @@ template<class Type, template<class> class PatchField, class GeoMesh>
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
Foam::GeometricField<Type, PatchField, GeoMesh>::T() const
{
tmp<GeometricField<Type, PatchField, GeoMesh>> result
(
new GeometricField<Type, PatchField, GeoMesh>
auto tresult = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
(
IOobject
(
@ -1033,13 +1031,12 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::T() const
),
this->mesh(),
this->dimensions()
)
);
Foam::T(result.ref().primitiveFieldRef(), primitiveField());
Foam::T(result.ref().boundaryFieldRef(), boundaryField());
Foam::T(tresult.ref().primitiveFieldRef(), primitiveField());
Foam::T(tresult.ref().boundaryFieldRef(), boundaryField());
return result;
return tresult;
}
@ -1058,9 +1055,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::component
const direction d
) const
{
tmp<GeometricField<cmptType, PatchField, GeoMesh>> Component
(
new GeometricField<cmptType, PatchField, GeoMesh>
auto tresult = tmp<GeometricField<cmptType, PatchField, GeoMesh>>::New
(
IOobject
(
@ -1070,13 +1065,12 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::component
),
this->mesh(),
this->dimensions()
)
);
Foam::component(Component.ref().primitiveFieldRef(), primitiveField(), d);
Foam::component(Component.ref().boundaryFieldRef(), boundaryField(), d);
Foam::component(tresult.ref().primitiveFieldRef(), primitiveField(), d);
Foam::component(tresult.ref().boundaryFieldRef(), boundaryField(), d);
return Component;
return tresult;
}

View File

@ -103,9 +103,8 @@ pow
{
typedef typename powProduct<Type, r>::type powProductType;
tmp<GeometricField<powProductType, PatchField, GeoMesh>> tPow
(
new GeometricField<powProductType, PatchField, GeoMesh>
auto tres =
tmp<GeometricField<powProductType, PatchField, GeoMesh>>::New
(
IOobject
(
@ -117,12 +116,11 @@ pow
),
gf.mesh(),
pow(gf.dimensions(), r)
)
);
pow<Type, r, PatchField, GeoMesh>(tPow.ref(), gf);
pow<Type, r, PatchField, GeoMesh>(tres.ref(), gf);
return tPow;
return tres;
}
@ -144,9 +142,8 @@ pow
const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
tmp<GeometricField<powProductType, PatchField, GeoMesh>> tPow
(
new GeometricField<powProductType, PatchField, GeoMesh>
auto tres =
tmp<GeometricField<powProductType, PatchField, GeoMesh>>::New
(
IOobject
(
@ -158,14 +155,12 @@ pow
),
gf.mesh(),
pow(gf.dimensions(), r)
)
);
pow<Type, r, PatchField, GeoMesh>(tPow.ref(), gf);
pow<Type, r, PatchField, GeoMesh>(tres.ref(), gf);
tgf.clear();
return tPow;
return tres;
}
@ -197,9 +192,8 @@ sqr(const GeometricField<Type, PatchField, GeoMesh>& gf)
{
typedef typename outerProduct<Type, Type>::type outerProductType;
tmp<GeometricField<outerProductType, PatchField, GeoMesh>> tSqr
(
new GeometricField<outerProductType, PatchField, GeoMesh>
auto tres =
tmp<GeometricField<outerProductType, PatchField, GeoMesh>>::New
(
IOobject
(
@ -211,12 +205,11 @@ sqr(const GeometricField<Type, PatchField, GeoMesh>& gf)
),
gf.mesh(),
sqr(gf.dimensions())
)
);
sqr(tSqr.ref(), gf);
sqr(tres.ref(), gf);
return tSqr;
return tres;
}
@ -236,9 +229,8 @@ sqr(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf)
const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
tmp<GeometricField<outerProductType, PatchField, GeoMesh>> tSqr
(
new GeometricField<outerProductType, PatchField, GeoMesh>
auto tres =
tmp<GeometricField<outerProductType, PatchField, GeoMesh>>::New
(
IOobject
(
@ -250,14 +242,13 @@ sqr(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf)
),
gf.mesh(),
sqr(gf.dimensions())
)
);
sqr(tSqr.ref(), gf);
sqr(tres.ref(), gf);
tgf.clear();
return tSqr;
return tres;
}
@ -280,9 +271,8 @@ tmp<GeometricField<scalar, PatchField, GeoMesh>> magSqr
const GeometricField<Type, PatchField, GeoMesh>& gf
)
{
tmp<GeometricField<scalar, PatchField, GeoMesh>> tMagSqr
(
new GeometricField<scalar, PatchField, GeoMesh>
auto tres =
tmp<GeometricField<scalar, PatchField, GeoMesh>>::New
(
IOobject
(
@ -294,12 +284,11 @@ tmp<GeometricField<scalar, PatchField, GeoMesh>> magSqr
),
gf.mesh(),
sqr(gf.dimensions())
)
);
magSqr(tMagSqr.ref(), gf);
magSqr(tres.ref(), gf);
return tMagSqr;
return tres;
}
template<class Type, template<class> class PatchField, class GeoMesh>
@ -310,9 +299,8 @@ tmp<GeometricField<scalar, PatchField, GeoMesh>> magSqr
{
const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
tmp<GeometricField<scalar, PatchField, GeoMesh>> tMagSqr
(
new GeometricField<scalar, PatchField, GeoMesh>
auto tres =
tmp<GeometricField<scalar, PatchField, GeoMesh>>::New
(
IOobject
(
@ -324,14 +312,13 @@ tmp<GeometricField<scalar, PatchField, GeoMesh>> magSqr
),
gf.mesh(),
sqr(gf.dimensions())
)
);
magSqr(tMagSqr.ref(), gf);
magSqr(tres.ref(), gf);
tgf.clear();
return tMagSqr;
return tres;
}
@ -354,9 +341,8 @@ tmp<GeometricField<scalar, PatchField, GeoMesh>> mag
const GeometricField<Type, PatchField, GeoMesh>& gf
)
{
tmp<GeometricField<scalar, PatchField, GeoMesh>> tMag
(
new GeometricField<scalar, PatchField, GeoMesh>
auto tres =
tmp<GeometricField<scalar, PatchField, GeoMesh>>::New
(
IOobject
(
@ -368,12 +354,11 @@ tmp<GeometricField<scalar, PatchField, GeoMesh>> mag
),
gf.mesh(),
gf.dimensions()
)
);
mag(tMag.ref(), gf);
mag(tres.ref(), gf);
return tMag;
return tres;
}
template<class Type, template<class> class PatchField, class GeoMesh>
@ -384,9 +369,8 @@ tmp<GeometricField<scalar, PatchField, GeoMesh>> mag
{
const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
tmp<GeometricField<scalar, PatchField, GeoMesh>> tMag
(
new GeometricField<scalar, PatchField, GeoMesh>
auto tres =
tmp<GeometricField<scalar, PatchField, GeoMesh>>::New
(
IOobject
(
@ -398,14 +382,13 @@ tmp<GeometricField<scalar, PatchField, GeoMesh>> mag
),
gf.mesh(),
gf.dimensions()
)
);
mag(tMag.ref(), gf);
mag(tres.ref(), gf);
tgf.clear();
return tMag;
return tres;
}
@ -441,9 +424,8 @@ cmptAv(const GeometricField<Type, PatchField, GeoMesh>& gf)
typedef typename GeometricField<Type, PatchField, GeoMesh>::cmptType
cmptType;
tmp<GeometricField<cmptType, PatchField, GeoMesh>> CmptAv
(
new GeometricField<scalar, PatchField, GeoMesh>
auto tres =
tmp<GeometricField<cmptType, PatchField, GeoMesh>>::New
(
IOobject
(
@ -455,12 +437,11 @@ cmptAv(const GeometricField<Type, PatchField, GeoMesh>& gf)
),
gf.mesh(),
gf.dimensions()
)
);
cmptAv(CmptAv.ref(), gf);
cmptAv(tres.ref(), gf);
return CmptAv;
return tres;
}
@ -481,9 +462,8 @@ cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf)
const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
tmp<GeometricField<cmptType, PatchField, GeoMesh>> CmptAv
(
new GeometricField<scalar, PatchField, GeoMesh>
auto tres =
tmp<GeometricField<cmptType, PatchField, GeoMesh>>::New
(
IOobject
(
@ -495,14 +475,13 @@ cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf)
),
gf.mesh(),
gf.dimensions()
)
);
cmptAv(CmptAv.ref(), gf);
cmptAv(tres.ref(), gf);
tgf.clear();
return CmptAv;
return tres;
}
@ -649,9 +628,9 @@ operator op \
) \
{ \
typedef typename product<Type1, Type2>::type productType; \
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes \
( \
new GeometricField<productType, PatchField, GeoMesh> \
\
auto tres = \
tmp<GeometricField<productType, PatchField, GeoMesh>>::New \
( \
IOobject \
( \
@ -663,14 +642,14 @@ operator op \
), \
gf1.mesh(), \
gf1.dimensions() op gf2.dimensions() \
) \
); \
\
Foam::opFunc(tRes.ref(), gf1, gf2); \
Foam::opFunc(tres.ref(), gf1, gf2); \
\
return tRes; \
return tres; \
} \
\
\
template \
<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
tmp \
@ -687,7 +666,7 @@ operator op \
\
const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
\
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes = \
auto tres = \
reuseTmpGeometricField<productType, Type2, PatchField, GeoMesh>::New \
( \
tgf2, \
@ -695,11 +674,11 @@ operator op \
gf1.dimensions() op gf2.dimensions() \
); \
\
Foam::opFunc(tRes.ref(), gf1, gf2); \
Foam::opFunc(tres.ref(), gf1, gf2); \
\
tgf2.clear(); \
\
return tRes; \
return tres; \
} \
\
template \
@ -718,7 +697,7 @@ operator op \
\
const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
\
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes = \
auto tres = \
reuseTmpGeometricField<productType, Type1, PatchField, GeoMesh>::New \
( \
tgf1, \
@ -726,11 +705,11 @@ operator op \
gf1.dimensions() op gf2.dimensions() \
); \
\
Foam::opFunc(tRes.ref(), gf1, gf2); \
Foam::opFunc(tres.ref(), gf1, gf2); \
\
tgf1.clear(); \
\
return tRes; \
return tres; \
} \
\
template \
@ -750,7 +729,7 @@ operator op \
const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
\
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes = \
auto tres = \
reuseTmpTmpGeometricField \
<productType, Type1, Type1, Type2, PatchField, GeoMesh>::New \
( \
@ -760,12 +739,12 @@ operator op \
gf1.dimensions() op gf2.dimensions() \
); \
\
Foam::opFunc(tRes.ref(), gf1, gf2); \
Foam::opFunc(tres.ref(), gf1, gf2); \
\
tgf1.clear(); \
tgf2.clear(); \
\
return tRes; \
return tres; \
} \
\
template \
@ -794,9 +773,8 @@ operator op \
{ \
typedef typename product<Type, Form>::type productType; \
\
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes \
( \
new GeometricField<productType, PatchField, GeoMesh> \
auto tres = \
tmp<GeometricField<productType, PatchField, GeoMesh>>::New \
( \
IOobject \
( \
@ -808,12 +786,11 @@ operator op \
), \
gf1.mesh(), \
gf1.dimensions() op dvs.dimensions() \
) \
); \
\
Foam::opFunc(tRes.ref(), gf1, dvs); \
Foam::opFunc(tres.ref(), gf1, dvs); \
\
return tRes; \
return tres; \
} \
\
template \
@ -848,7 +825,7 @@ operator op \
\
const GeometricField<Type, PatchField, GeoMesh>& gf1 = tgf1(); \
\
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes = \
auto tres = \
reuseTmpGeometricField<productType, Type, PatchField, GeoMesh>::New \
( \
tgf1, \
@ -856,11 +833,11 @@ operator op \
gf1.dimensions() op dvs.dimensions() \
); \
\
Foam::opFunc(tRes.ref(), gf1, dvs); \
Foam::opFunc(tres.ref(), gf1, dvs); \
\
tgf1.clear(); \
\
return tRes; \
return tres; \
} \
\
template \
@ -907,9 +884,9 @@ operator op \
) \
{ \
typedef typename product<Form, Type>::type productType; \
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes \
( \
new GeometricField<productType, PatchField, GeoMesh> \
\
auto tres = \
tmp<GeometricField<productType, PatchField, GeoMesh>>::New \
( \
IOobject \
( \
@ -921,12 +898,11 @@ operator op \
), \
gf1.mesh(), \
dvs.dimensions() op gf1.dimensions() \
) \
); \
\
Foam::opFunc(tRes.ref(), dvs, gf1); \
Foam::opFunc(tres.ref(), dvs, gf1); \
\
return tRes; \
return tres; \
} \
\
template \
@ -960,7 +936,7 @@ operator op \
\
const GeometricField<Type, PatchField, GeoMesh>& gf1 = tgf1(); \
\
tmp<GeometricField<productType, PatchField, GeoMesh>> tRes = \
auto tres = \
reuseTmpGeometricField<productType, Type, PatchField, GeoMesh>::New \
( \
tgf1, \
@ -968,11 +944,11 @@ operator op \
dvs.dimensions() op gf1.dimensions() \
); \
\
Foam::opFunc(tRes.ref(), dvs, gf1); \
Foam::opFunc(tres.ref(), dvs, gf1); \
\
tgf1.clear(); \
\
return tRes; \
return tres; \
} \
\
template \

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -46,15 +46,15 @@ void Func \
res.oriented() = gf1.oriented(); \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
( \
const GeometricField<Type1, PatchField, GeoMesh>& gf1 \
) \
{ \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
new GeometricField<ReturnType, PatchField, GeoMesh> \
auto tres = \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>>::New \
( \
IOobject \
( \
@ -66,14 +66,14 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
), \
gf1.mesh(), \
Dfunc(gf1.dimensions()) \
) \
); \
\
Foam::Func(tRes.ref(), gf1); \
Foam::Func(tres.ref(), gf1); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
( \
@ -82,21 +82,19 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
{ \
const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
\
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
auto tres = \
reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
( \
tgf1, \
#Func "(" + gf1.name() + ')', \
Dfunc(gf1.dimensions()) \
) \
); \
\
Foam::Func(tRes.ref(), gf1); \
Foam::Func(tres.ref(), gf1); \
\
tgf1.clear(); \
\
return tRes; \
return tres; \
}
@ -122,9 +120,8 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
const GeometricField<Type1, PatchField, GeoMesh>& gf1 \
) \
{ \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
new GeometricField<ReturnType, PatchField, GeoMesh> \
auto tres = \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>>::New \
( \
IOobject \
( \
@ -136,14 +133,14 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
), \
gf1.mesh(), \
Dfunc(gf1.dimensions()) \
) \
); \
\
Foam::OpFunc(tRes.ref(), gf1); \
Foam::OpFunc(tres.ref(), gf1); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
( \
@ -152,21 +149,19 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
{ \
const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
\
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
auto tres = \
reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
( \
tgf1, \
#Op + gf1.name(), \
Dfunc(gf1.dimensions()) \
) \
); \
\
Foam::OpFunc(tRes.ref(), gf1); \
Foam::OpFunc(tres.ref(), gf1); \
\
tgf1.clear(); \
\
return tRes; \
return tres; \
}
@ -197,6 +192,7 @@ void Func \
res.oriented() = Func(gf1.oriented(), gf2.oriented()); \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
( \
@ -204,9 +200,8 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
) \
{ \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
new GeometricField<ReturnType, PatchField, GeoMesh> \
auto tres = \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>>::New \
( \
IOobject \
( \
@ -218,14 +213,14 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
), \
gf1.mesh(), \
Func(gf1.dimensions(), gf2.dimensions()) \
) \
); \
\
Foam::Func(tRes.ref(), gf1, gf2); \
Foam::Func(tres.ref(), gf1, gf2); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
( \
@ -235,23 +230,22 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
{ \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
\
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
auto tres = \
reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
( \
tgf2, \
#Func "(" + gf1.name() + ',' + gf2.name() + ')', \
Func(gf1.dimensions(), gf2.dimensions()) \
) \
); \
\
Foam::Func(tRes.ref(), gf1, gf2); \
Foam::Func(tres.ref(), gf1, gf2); \
\
tgf2.clear(); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
( \
@ -261,23 +255,22 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
{ \
const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
\
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
auto tres = \
reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
( \
tgf1, \
#Func "(" + gf1.name() + ',' + gf2.name() + ')', \
Func(gf1.dimensions(), gf2.dimensions()) \
) \
); \
\
Foam::Func(tRes.ref(), gf1, gf2); \
Foam::Func(tres.ref(), gf1, gf2); \
\
tgf1.clear(); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
( \
@ -288,8 +281,7 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
\
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
auto tres = \
reuseTmpTmpGeometricField \
<ReturnType, Type1, Type1, Type2, PatchField, GeoMesh> \
::New \
@ -298,17 +290,17 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
tgf2, \
#Func "(" + gf1.name() + ',' + gf2.name() + ')', \
Func(gf1.dimensions(), gf2.dimensions()) \
) \
); \
\
Foam::Func(tRes.ref(), gf1, gf2); \
Foam::Func(tres.ref(), gf1, gf2); \
\
tgf1.clear(); \
tgf2.clear(); \
\
return tRes; \
return tres; \
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
@ -326,6 +318,7 @@ void Func \
res.oriented() = gf2.oriented(); \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
( \
@ -333,9 +326,8 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
) \
{ \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
new GeometricField<ReturnType, PatchField, GeoMesh> \
auto tres = \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>>::New \
( \
IOobject \
( \
@ -347,14 +339,14 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
), \
gf2.mesh(), \
Func(dt1.dimensions(), gf2.dimensions()) \
) \
); \
\
Foam::Func(tRes.ref(), dt1, gf2); \
Foam::Func(tres.ref(), dt1, gf2); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
( \
@ -375,23 +367,22 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
{ \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
\
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
auto tres = \
reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
( \
tgf2, \
#Func "(" + dt1.name() + gf2.name() + ',' + ')', \
Func(dt1.dimensions(), gf2.dimensions()) \
) \
); \
\
Foam::Func(tRes.ref(), dt1, gf2); \
Foam::Func(tres.ref(), dt1, gf2); \
\
tgf2.clear(); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
( \
@ -418,6 +409,7 @@ void Func \
res.oriented() = gf1.oriented(); \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
( \
@ -425,9 +417,8 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
const dimensioned<Type2>& dt2 \
) \
{ \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
new GeometricField<ReturnType, PatchField, GeoMesh> \
auto tres = \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>>::New \
( \
IOobject \
( \
@ -439,14 +430,14 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
), \
gf1.mesh(), \
Func(gf1.dimensions(), dt2.dimensions()) \
) \
); \
\
Foam::Func(tRes.ref(), gf1, dt2); \
Foam::Func(tres.ref(), gf1, dt2); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
( \
@ -467,23 +458,22 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
{ \
const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
\
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
auto tres = \
reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
( \
tgf1, \
#Func "(" + gf1.name() + ',' + dt2.name() + ')', \
Func(gf1.dimensions(), dt2.dimensions()) \
) \
); \
\
Foam::Func(tRes.ref(), gf1, dt2); \
Foam::Func(tres.ref(), gf1, dt2); \
\
tgf1.clear(); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
( \
@ -519,6 +509,7 @@ void OpFunc \
res.oriented() = gf1.oriented() Op gf2.oriented(); \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
( \
@ -526,9 +517,8 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
) \
{ \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
new GeometricField<ReturnType, PatchField, GeoMesh> \
auto tres = \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>>::New \
( \
IOobject \
( \
@ -540,14 +530,14 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
), \
gf1.mesh(), \
gf1.dimensions() Op gf2.dimensions() \
) \
); \
\
Foam::OpFunc(tRes.ref(), gf1, gf2); \
Foam::OpFunc(tres.ref(), gf1, gf2); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
( \
@ -557,23 +547,22 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
{ \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
\
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
auto tres = \
reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
( \
tgf2, \
'(' + gf1.name() + OpName + gf2.name() + ')', \
gf1.dimensions() Op gf2.dimensions() \
) \
); \
\
Foam::OpFunc(tRes.ref(), gf1, gf2); \
Foam::OpFunc(tres.ref(), gf1, gf2); \
\
tgf2.clear(); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
( \
@ -583,23 +572,22 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
{ \
const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
\
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
auto tres = \
reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
( \
tgf1, \
'(' + gf1.name() + OpName + gf2.name() + ')', \
gf1.dimensions() Op gf2.dimensions() \
) \
); \
\
Foam::OpFunc(tRes.ref(), gf1, gf2); \
Foam::OpFunc(tres.ref(), gf1, gf2); \
\
tgf1.clear(); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
( \
@ -610,8 +598,7 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
\
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
auto tres = \
reuseTmpTmpGeometricField \
<ReturnType, Type1, Type1, Type2, PatchField, GeoMesh>::New \
( \
@ -619,15 +606,14 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
tgf2, \
'(' + gf1.name() + OpName + gf2.name() + ')', \
gf1.dimensions() Op gf2.dimensions() \
) \
); \
\
Foam::OpFunc(tRes.ref(), gf1, gf2); \
Foam::OpFunc(tres.ref(), gf1, gf2); \
\
tgf1.clear(); \
tgf2.clear(); \
\
return tRes; \
return tres; \
}
@ -656,9 +642,8 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
) \
{ \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
new GeometricField<ReturnType, PatchField, GeoMesh> \
auto tres = \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>>::New \
( \
IOobject \
( \
@ -670,14 +655,14 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
), \
gf2.mesh(), \
dt1.dimensions() Op gf2.dimensions() \
) \
); \
\
Foam::OpFunc(tRes.ref(), dt1, gf2); \
Foam::OpFunc(tres.ref(), dt1, gf2); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
( \
@ -698,23 +683,22 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
{ \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
\
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
auto tres = \
reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
( \
tgf2, \
'(' + dt1.name() + OpName + gf2.name() + ')', \
dt1.dimensions() Op gf2.dimensions() \
) \
) ; \
\
Foam::OpFunc(tRes.ref(), dt1, gf2); \
Foam::OpFunc(tres.ref(), dt1, gf2); \
\
tgf2.clear(); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
( \
@ -741,6 +725,7 @@ void OpFunc \
res.oriented() = gf1.oriented(); \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
( \
@ -748,9 +733,8 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
const dimensioned<Type2>& dt2 \
) \
{ \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
new GeometricField<ReturnType, PatchField, GeoMesh> \
auto tres = \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>>::New \
( \
IOobject \
( \
@ -762,14 +746,14 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
), \
gf1.mesh(), \
gf1.dimensions() Op dt2.dimensions() \
) \
); \
\
Foam::OpFunc(tRes.ref(), gf1, dt2); \
Foam::OpFunc(tres.ref(), gf1, dt2); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
( \
@ -790,23 +774,22 @@ tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
{ \
const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
\
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> tRes \
( \
auto tres = \
reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
( \
tgf1, \
'(' + gf1.name() + OpName + dt2.name() + ')', \
gf1.dimensions() Op dt2.dimensions() \
) \
); \
\
Foam::OpFunc(tRes.ref(), gf1, dt2); \
Foam::OpFunc(tres.ref(), gf1, dt2); \
\
tgf1.clear(); \
\
return tRes; \
return tres; \
} \
\
\
TEMPLATE \
tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
( \

View File

@ -23,7 +23,6 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class GeoField>
@ -37,9 +36,7 @@ Foam::tmp<GeoField> Foam::uniformInterpolate
const GeoField& field0 = *(*fields.begin());
// Interpolate
tmp<GeoField> tfld
(
new GeoField
auto tfld = tmp<GeoField>::New
(
IOobject
(
@ -50,9 +47,8 @@ Foam::tmp<GeoField> Foam::uniformInterpolate
IOobject::AUTO_WRITE
),
weights[0]*(*fields[indices[0]])
)
);
GeoField& fld = tfld();
auto& fld = tfld();
for (label i = 1; i < indices.size(); ++i)
{
@ -91,25 +87,16 @@ Foam::tmp<GeoField> Foam::uniformInterpolate
// Interpolate
tmp<GeoField> tfld(new GeoField(fieldIO, weights[0]*field0));
auto tfld = tmp<GeoField>::New(fieldIO, weights[0]*field0);
GeoField& fld = tfld.ref();
for (label i = 1; i < times.size(); ++i)
{
const objectRegistry& timeIFields = fieldsCache.lookupObject
<
const objectRegistry
>
(
times[i]
);
const GeoField& fieldi = timeIFields.lookupObject
<
const GeoField
>
(
fieldName
);
const objectRegistry& timeIFields =
fieldsCache.lookupObject<const objectRegistry>(times[i]);
const GeoField& fieldi =
timeIFields.lookupObject<const GeoField>(fieldName);
fld += weights[i]*fieldi;
}