/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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 .
\*---------------------------------------------------------------------------*/
#include "GeometricFieldReuseFunctions.H"
#define TEMPLATE \
template class PatchField, class GeoMesh>
#include "GeometricFieldFunctionsM.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
template class PatchField, class GeoMesh>
void component
(
GeometricField
<
typename GeometricField::cmptType,
PatchField,
GeoMesh
>& gcf,
const GeometricField& gf,
const direction d
)
{
component(gcf.internalField(), gf.internalField(), d);
component(gcf.boundaryField(), gf.boundaryField(), d);
}
template class PatchField, class GeoMesh>
void T
(
GeometricField& gf,
const GeometricField& gf1
)
{
T(gf.internalField(), gf1.internalField());
T(gf.boundaryField(), gf1.boundaryField());
}
template class PatchField, class GeoMesh, int r>
void pow
(
GeometricField::type, PatchField, GeoMesh>& gf,
const GeometricField& gf1
)
{
pow(gf.internalField(), gf1.internalField(), r);
pow(gf.boundaryField(), gf1.boundaryField(), r);
}
template class PatchField, class GeoMesh, int r>
tmp::type, PatchField, GeoMesh> >
pow
(
const GeometricField& gf,
typename powProduct::type
)
{
typedef typename powProduct::type powProductType;
tmp > tPow
(
new GeometricField
(
IOobject
(
"pow(" + gf.name() + ',' + name(r) + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
pow(gf.dimensions(), r)
)
);
pow(tPow(), gf);
return tPow;
}
template class PatchField, class GeoMesh, int r>
tmp::type, PatchField, GeoMesh> >
pow
(
const tmp >& tgf,
typename powProduct::type
)
{
typedef typename powProduct::type powProductType;
const GeometricField& gf = tgf();
tmp > tPow
(
new GeometricField
(
IOobject
(
"pow(" + gf.name() + ',' + name(r) + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
pow(gf.dimensions(), r)
)
);
pow(tPow(), gf);
tgf.clear();
return tPow;
}
template class PatchField, class GeoMesh>
void sqr
(
GeometricField
::type, PatchField, GeoMesh>& gf,
const GeometricField& gf1
)
{
sqr(gf.internalField(), gf1.internalField());
sqr(gf.boundaryField(), gf1.boundaryField());
}
template class PatchField, class GeoMesh>
tmp
<
GeometricField
<
typename outerProduct::type,
PatchField,
GeoMesh
>
>
sqr(const GeometricField& gf)
{
typedef typename outerProduct::type outerProductType;
tmp > tSqr
(
new GeometricField
(
IOobject
(
"sqr(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
sqr(gf.dimensions())
)
);
sqr(tSqr(), gf);
return tSqr;
}
template class PatchField, class GeoMesh>
tmp
<
GeometricField
<
typename outerProduct::type,
PatchField,
GeoMesh
>
>
sqr(const tmp >& tgf)
{
typedef typename outerProduct::type outerProductType;
const GeometricField& gf = tgf();
tmp > tSqr
(
new GeometricField
(
IOobject
(
"sqr(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
sqr(gf.dimensions())
)
);
sqr(tSqr(), gf);
tgf.clear();
return tSqr;
}
template class PatchField, class GeoMesh>
void magSqr
(
GeometricField& gsf,
const GeometricField& gf
)
{
magSqr(gsf.internalField(), gf.internalField());
magSqr(gsf.boundaryField(), gf.boundaryField());
}
template class PatchField, class GeoMesh>
tmp > magSqr
(
const GeometricField& gf
)
{
tmp > tMagSqr
(
new GeometricField
(
IOobject
(
"magSqr(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
sqr(gf.dimensions())
)
);
magSqr(tMagSqr(), gf);
return tMagSqr;
}
template class PatchField, class GeoMesh>
tmp > magSqr
(
const tmp >& tgf
)
{
const GeometricField& gf = tgf();
tmp > tMagSqr
(
new GeometricField
(
IOobject
(
"magSqr(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
sqr(gf.dimensions())
)
);
magSqr(tMagSqr(), gf);
tgf.clear();
return tMagSqr;
}
template class PatchField, class GeoMesh>
void mag
(
GeometricField& gsf,
const GeometricField& gf
)
{
mag(gsf.internalField(), gf.internalField());
mag(gsf.boundaryField(), gf.boundaryField());
}
template class PatchField, class GeoMesh>
tmp > mag
(
const GeometricField& gf
)
{
tmp > tMag
(
new GeometricField
(
IOobject
(
"mag(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
gf.dimensions()
)
);
mag(tMag(), gf);
return tMag;
}
template class PatchField, class GeoMesh>
tmp > mag
(
const tmp >& tgf
)
{
const GeometricField& gf = tgf();
tmp > tMag
(
new GeometricField
(
IOobject
(
"mag(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
gf.dimensions()
)
);
mag(tMag(), gf);
tgf.clear();
return tMag;
}
template class PatchField, class GeoMesh>
void cmptAv
(
GeometricField
<
typename GeometricField::cmptType,
PatchField,
GeoMesh
>& gcf,
const GeometricField& gf
)
{
cmptAv(gcf.internalField(), gf.internalField());
cmptAv(gcf.boundaryField(), gf.boundaryField());
}
template class PatchField, class GeoMesh>
tmp
<
GeometricField
<
typename GeometricField::cmptType,
PatchField,
GeoMesh
>
>
cmptAv(const GeometricField& gf)
{
typedef typename GeometricField::cmptType
cmptType;
tmp > CmptAv
(
new GeometricField
(
IOobject
(
"cmptAv(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
gf.dimensions()
)
);
cmptAv(CmptAv(), gf);
return CmptAv;
}
template class PatchField, class GeoMesh>
tmp
<
GeometricField
<
typename GeometricField::cmptType,
PatchField,
GeoMesh
>
>
cmptAv(const tmp >& tgf)
{
typedef typename GeometricField::cmptType
cmptType;
const GeometricField& gf = tgf();
tmp > CmptAv
(
new GeometricField
(
IOobject
(
"cmptAv(" + gf.name() + ')',
gf.instance(),
gf.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
gf.mesh(),
gf.dimensions()
)
);
cmptAv(CmptAv(), gf);
tgf.clear();
return CmptAv;
}
#define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc) \
\
template class PatchField, class GeoMesh> \
dimensioned func \
( \
const GeometricField& gf \
) \
{ \
return dimensioned \
( \
#func "(" + gf.name() + ')', \
gf.dimensions(), \
Foam::func(gFunc(gf.internalField()), gFunc(gf.boundaryField())) \
); \
} \
\
template class PatchField, class GeoMesh> \
dimensioned func \
( \
const tmp >& tgf1 \
) \
{ \
dimensioned res = func(tgf1()); \
tgf1.clear(); \
return res; \
}
UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, max, gMax)
UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, min, gMin)
#undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
#define UNARY_REDUCTION_FUNCTION(returnType, func, gFunc) \
\
template class PatchField, class GeoMesh> \
dimensioned func \
( \
const GeometricField& gf \
) \
{ \
return dimensioned \
( \
#func "(" + gf.name() + ')', \
gf.dimensions(), \
gFunc(gf.internalField()) \
); \
} \
\
template class PatchField, class GeoMesh> \
dimensioned func \
( \
const tmp >& tgf1 \
) \
{ \
dimensioned res = func(tgf1()); \
tgf1.clear(); \
return res; \
}
UNARY_REDUCTION_FUNCTION(Type, sum, gSum)
UNARY_REDUCTION_FUNCTION(scalar, sumMag, gSumMag)
UNARY_REDUCTION_FUNCTION(Type, average, gAverage)
#undef UNARY_REDUCTION_FUNCTION
BINARY_FUNCTION(Type, Type, Type, max)
BINARY_FUNCTION(Type, Type, Type, min)
BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
BINARY_FUNCTION(Type, Type, Type, cmptDivide)
BINARY_TYPE_FUNCTION(Type, Type, Type, max)
BINARY_TYPE_FUNCTION(Type, Type, Type, min)
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
// * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
UNARY_OPERATOR(Type, Type, -, negate, transform)
#ifndef __INTEL_COMPILER
BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
#endif
BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define PRODUCT_OPERATOR(product, op, opFunc) \
\
template \
class PatchField, class GeoMesh> \
void opFunc \
( \
GeometricField \
::type, PatchField, GeoMesh>& gf, \
const GeometricField& gf1, \
const GeometricField& gf2 \
) \
{ \
Foam::opFunc(gf.internalField(), gf1.internalField(), gf2.internalField());\
Foam::opFunc(gf.boundaryField(), gf1.boundaryField(), gf2.boundaryField());\
} \
\
template \
class PatchField, class GeoMesh> \
tmp \
< \
GeometricField::type, PatchField, GeoMesh> \
> \
operator op \
( \
const GeometricField& gf1, \
const GeometricField& gf2 \
) \
{ \
typedef typename product::type productType; \
tmp > tRes \
( \
new GeometricField \
( \
IOobject \
( \
'(' + gf1.name() + #op + gf2.name() + ')', \
gf1.instance(), \
gf1.db(), \
IOobject::NO_READ, \
IOobject::NO_WRITE \
), \
gf1.mesh(), \
gf1.dimensions() op gf2.dimensions() \
) \
); \
\
Foam::opFunc(tRes(), gf1, gf2); \
\
return tRes; \
} \
\
template \
class PatchField, class GeoMesh> \
tmp \
< \
GeometricField::type, PatchField, GeoMesh> \
> \
operator op \
( \
const GeometricField& gf1, \
const tmp >& tgf2 \
) \
{ \
typedef typename product::type productType; \
\
const GeometricField& gf2 = tgf2(); \
\
tmp > tRes = \
reuseTmpGeometricField::New \
( \
tgf2, \
'(' + gf1.name() + #op + gf2.name() + ')', \
gf1.dimensions() op gf2.dimensions() \
); \
\
Foam::opFunc(tRes(), gf1, gf2); \
\
reuseTmpGeometricField \
::clear(tgf2); \
\
return tRes; \
} \
\
template \
class PatchField, class GeoMesh> \
tmp \
< \
GeometricField::type, PatchField, GeoMesh> \
> \
operator op \
( \
const tmp >& tgf1, \
const GeometricField& gf2 \
) \
{ \
typedef typename product::type productType; \
\
const GeometricField& gf1 = tgf1(); \
\
tmp > tRes = \
reuseTmpGeometricField::New \
( \
tgf1, \
'(' + gf1.name() + #op + gf2.name() + ')', \
gf1.dimensions() op gf2.dimensions() \
); \
\
Foam::opFunc(tRes(), gf1, gf2); \
\
reuseTmpGeometricField \
::clear(tgf1); \
\
return tRes; \
} \
\
template \
class PatchField, class GeoMesh> \
tmp \
< \
GeometricField::type, PatchField, GeoMesh> \
> \
operator op \
( \
const tmp >& tgf1, \
const tmp >& tgf2 \
) \
{ \
typedef typename product::type productType; \
\
const GeometricField& gf1 = tgf1(); \
const GeometricField& gf2 = tgf2(); \
\
tmp > tRes = \
reuseTmpTmpGeometricField \
::New \
( \
tgf1, \
tgf2, \
'(' + gf1.name() + #op + gf2.name() + ')', \
gf1.dimensions() op gf2.dimensions() \
); \
\
Foam::opFunc(tRes(), gf1, gf2); \
\
reuseTmpTmpGeometricField \
\
::clear(tgf1, tgf2); \
\
return tRes; \
} \
\
template \
class PatchField, class GeoMesh> \
void opFunc \
( \
GeometricField \
::type, PatchField, GeoMesh>& gf, \
const GeometricField& gf1, \
const dimensioned