Commit b002a232 authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: modernize code for FieldFieldFunctions (#1160)

- use forwarding tmp factory methods, auto types
parent 63655609
......@@ -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.
......@@ -231,15 +231,15 @@ FieldField<Field, Type>::component
const direction d
) const
{
tmp<FieldField<Field, cmptType>> Component
(
FieldField<Field, typename FieldField<Field, Type>::cmptType>::
NewCalculatedType(*this)
);
auto tres =
FieldField
<
Field, typename FieldField<Field, Type>::cmptType
>::NewCalculatedType(*this);
::Foam::component(Component.ref(), *this, d);
::Foam::component(tres.ref(), *this, d);
return Component;
return tres;
}
......@@ -274,22 +274,22 @@ void FieldField<Field, Type>::replace
template<template<class> class Field, class Type>
tmp<FieldField<Field, Type>> FieldField<Field, Type>::T() const
{
auto tresult
auto tres
(
FieldField<Field, Type>::NewCalculatedType(*this)
);
::Foam::T(tresult.ref(), *this);
return tresult;
::Foam::T(tres.ref(), *this);
return tres;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<template<class> class Field, class Type>
void FieldField<Field, Type>::operator=(const FieldField<Field, Type>& f)
void FieldField<Field, Type>::operator=(const FieldField<Field, Type>& ff)
{
if (this == &f)
if (this == &ff)
{
FatalErrorInFunction
<< "attempted assignment to self"
......@@ -299,7 +299,7 @@ void FieldField<Field, Type>::operator=(const FieldField<Field, Type>& f)
forAll(*this, i)
{
this->operator[](i) = f[i];
this->operator[](i) = ff[i];
}
}
......@@ -341,11 +341,11 @@ void FieldField<Field, Type>::operator=(const tmp<FieldField>& tf)
template<template<class> class Field, class Type>
void FieldField<Field, Type>::operator=(const Type& t)
void FieldField<Field, Type>::operator=(const Type& val)
{
forAll(*this, i)
{
this->operator[](i) = t;
this->operator[](i) = val;
}
}
......
......@@ -161,7 +161,7 @@ public:
void operator=(const tmp<FieldField<Field, Type>>&);
//- Assign uniform value
void operator=(const Type&);
void operator=(const Type& val);
void operator+=(const FieldField<Field, Type>&);
void operator+=(const tmp<FieldField<Field, Type>>&);
......
......@@ -86,6 +86,7 @@ template<template<class> class Field, class Type>
tmp<FieldField<Field, typename outerProduct<Type, Type>::type>>
sqr(const tmp<FieldField<Field, Type>>& tf);
template<template<class> class Field, class Type>
void magSqr(FieldField<Field, scalar>& sf, const FieldField<Field, Type>& f);
......@@ -95,6 +96,7 @@ tmp<FieldField<Field, scalar>> magSqr(const FieldField<Field, Type>& f);
template<template<class> class Field, class Type>
tmp<FieldField<Field, scalar>> magSqr(const tmp<FieldField<Field, Type>>& tf);
template<template<class> class Field, class Type>
void mag(FieldField<Field, scalar>& sf, const FieldField<Field, Type>& f);
......@@ -190,26 +192,31 @@ tmp<FieldField<Field, Type>> cmptMag
template<template<class> class Field, class Type> \
returnType func(const tmp<FieldField<Field, Type>>& tf1);
template<template<class> class Field, class Type>
Type max(const FieldField<Field, Type>& f);
TMP_UNARY_FUNCTION(Type, max)
template<template<class> class Field, class Type>
Type min(const FieldField<Field, Type>& f);
TMP_UNARY_FUNCTION(Type, min)
template<template<class> class Field, class Type>
Type sum(const FieldField<Field, Type>& f);
TMP_UNARY_FUNCTION(Type, sum)
template<template<class> class Field, class Type>
scalar sumMag(const FieldField<Field, Type>& f);
TMP_UNARY_FUNCTION(scalar, sumMag)
template<template<class> class Field, class Type>
Type average(const FieldField<Field, Type>& f);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment