mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
FieldField: support different Field types for binary operators e.g. fvPatchField and fvsPatchField.
The Field type of the result is that of the LH argument so now // Update the phi BCs from U before p BCs are updated phi.boundaryField() = mesh.Sf().boundaryField() & U.boundaryField(); is possible.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -630,12 +630,18 @@ BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide)
|
||||
|
||||
#define PRODUCT_OPERATOR(product, op, opFunc) \
|
||||
\
|
||||
template<template<class> class Field, class Type1, class Type2> \
|
||||
template \
|
||||
< \
|
||||
template<class> class Field1, \
|
||||
template<class> class Field2, \
|
||||
class Type1, \
|
||||
class Type2 \
|
||||
> \
|
||||
void opFunc \
|
||||
( \
|
||||
FieldField<Field, typename product<Type1, Type2>::type>& f, \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
FieldField<Field1, typename product<Type1, Type2>::type>& f, \
|
||||
const FieldField<Field1, Type1>& f1, \
|
||||
const FieldField<Field2, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
forAll(f, i) \
|
||||
@ -644,18 +650,24 @@ void opFunc \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
template<template<class> class Field, class Type1, class Type2> \
|
||||
tmp<FieldField<Field, typename product<Type1, Type2>::type> > \
|
||||
template \
|
||||
< \
|
||||
template<class> class Field1, \
|
||||
template<class> class Field2, \
|
||||
class Type1, \
|
||||
class Type2 \
|
||||
> \
|
||||
tmp<FieldField<Field1, typename product<Type1, Type2>::type> > \
|
||||
operator op \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
const FieldField<Field1, Type1>& f1, \
|
||||
const FieldField<Field2, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
tmp<FieldField<Field, productType> > tRes \
|
||||
tmp<FieldField<Field1, productType> > tRes \
|
||||
( \
|
||||
FieldField<Field, productType>::NewCalculatedType(f1) \
|
||||
FieldField<Field1, productType>::NewCalculatedType(f1) \
|
||||
); \
|
||||
opFunc(tRes(), f1, f2); \
|
||||
return tRes; \
|
||||
@ -679,40 +691,76 @@ operator op \
|
||||
return tRes; \
|
||||
} \
|
||||
\
|
||||
template<template<class> class Field, class Type1, class Type2> \
|
||||
template \
|
||||
< \
|
||||
template<class> class Field1, \
|
||||
template<class> class Field2, \
|
||||
class Type1, \
|
||||
class Type2 \
|
||||
> \
|
||||
tmp<FieldField<Field, typename product<Type1, Type2>::type> > \
|
||||
operator op \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1> >& tf1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
const FieldField<Field1, Type1>& f1, \
|
||||
const tmp<FieldField<Field2, Type2> >& tf2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
tmp<FieldField<Field, productType> > tRes \
|
||||
tmp<FieldField<Field1, productType> > tRes \
|
||||
( \
|
||||
reuseTmpFieldField<Field, productType, Type1>::New(tf1) \
|
||||
FieldField<Field1, productType>::NewCalculatedType(f1) \
|
||||
); \
|
||||
opFunc(tRes(), tf1(), f2); \
|
||||
reuseTmpFieldField<Field, productType, Type1>::clear(tf1); \
|
||||
opFunc(tRes(), f1, tf2()); \
|
||||
tf2.clear(); \
|
||||
return tRes; \
|
||||
} \
|
||||
\
|
||||
template<template<class> class Field, class Type1, class Type2> \
|
||||
tmp<FieldField<Field, typename product<Type1, Type2>::type> > \
|
||||
template \
|
||||
< \
|
||||
template<class> class Field1, \
|
||||
template<class> class Field2, \
|
||||
class Type1, \
|
||||
class Type2 \
|
||||
> \
|
||||
tmp<FieldField<Field1, typename product<Type1, Type2>::type> > \
|
||||
operator op \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1> >& tf1, \
|
||||
const tmp<FieldField<Field, Type2> >& tf2 \
|
||||
const tmp<FieldField<Field1, Type1> >& tf1, \
|
||||
const FieldField<Field2, Type2>& f2 \
|
||||
) \
|
||||
{ \
|
||||
typedef typename product<Type1, Type2>::type productType; \
|
||||
tmp<FieldField<Field, productType> > tRes \
|
||||
tmp<FieldField<Field1, productType> > tRes \
|
||||
( \
|
||||
reuseTmpTmpFieldField<Field, productType, Type1, Type1, Type2>::New \
|
||||
reuseTmpFieldField<Field1, productType, Type1>::New(tf1) \
|
||||
); \
|
||||
opFunc(tRes(), tf1(), f2); \
|
||||
reuseTmpFieldField<Field1, productType, Type1>::clear(tf1); \
|
||||
return tRes; \
|
||||
} \
|
||||
\
|
||||
template \
|
||||
< \
|
||||
template<class> class Field1, \
|
||||
template<class> class Field2, \
|
||||
class Type1, \
|
||||
class Type2 \
|
||||
> \
|
||||
tmp<FieldField<Field1, typename product<Type1, Type2>::type> > \
|
||||
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 \
|
||||
( \
|
||||
reuseTmpTmpFieldField<Field1, productType, Type1, Type1, Type2>::New \
|
||||
(tf1, tf2) \
|
||||
); \
|
||||
opFunc(tRes(), tf1(), tf2()); \
|
||||
reuseTmpTmpFieldField<Field, productType, Type1, Type1, Type2>::clear \
|
||||
reuseTmpTmpFieldField<Field1, productType, Type1, Type1, Type2>::clear \
|
||||
(tf1, tf2); \
|
||||
return tRes; \
|
||||
} \
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -269,20 +269,32 @@ BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide)
|
||||
|
||||
#define PRODUCT_OPERATOR(product, op, opFunc) \
|
||||
\
|
||||
template<template<class> class Field, class Type1, class Type2> \
|
||||
template \
|
||||
< \
|
||||
template<class> class Field1, \
|
||||
template<class> class Field2, \
|
||||
class Type1, \
|
||||
class Type2 \
|
||||
> \
|
||||
void opFunc \
|
||||
( \
|
||||
FieldField<Field, typename product<Type1, Type2>::type>& f, \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
FieldField<Field1, typename product<Type1, Type2>::type>& f, \
|
||||
const FieldField<Field1, Type1>& f1, \
|
||||
const FieldField<Field2, Type2>& f2 \
|
||||
); \
|
||||
\
|
||||
template<template<class> class Field, class Type1, class Type2> \
|
||||
tmp<FieldField<Field, typename product<Type1, Type2>::type> > \
|
||||
template \
|
||||
< \
|
||||
template<class> class Field1, \
|
||||
template<class> class Field2, \
|
||||
class Type1, \
|
||||
class Type2 \
|
||||
> \
|
||||
tmp<FieldField<Field1, typename product<Type1, Type2>::type> > \
|
||||
operator op \
|
||||
( \
|
||||
const FieldField<Field, Type1>& f1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
const FieldField<Field1, Type1>& f1, \
|
||||
const FieldField<Field2, Type2>& f2 \
|
||||
); \
|
||||
\
|
||||
template<template<class> class Field, class Type1, class Type2> \
|
||||
@ -293,20 +305,46 @@ operator op \
|
||||
const tmp<FieldField<Field, Type2> >& tf2 \
|
||||
); \
|
||||
\
|
||||
template<template<class> class Field, class Type1, class Type2> \
|
||||
tmp<FieldField<Field, typename product<Type1, Type2>::type> > \
|
||||
template \
|
||||
< \
|
||||
template<class> class Field1, \
|
||||
template<class> class Field2, \
|
||||
class Type1, \
|
||||
class Type2 \
|
||||
> \
|
||||
tmp<FieldField<Field1, typename product<Type1, Type2>::type> > \
|
||||
operator op \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1> >& tf1, \
|
||||
const FieldField<Field, Type2>& f2 \
|
||||
const FieldField<Field1, Type1>& f1, \
|
||||
const tmp<FieldField<Field2, Type2> >& tf2 \
|
||||
); \
|
||||
\
|
||||
template<template<class> class Field, class Type1, class Type2> \
|
||||
tmp<FieldField<Field, typename product<Type1, Type2>::type> > \
|
||||
template \
|
||||
< \
|
||||
template<class> class Field1, \
|
||||
template<class> class Field2, \
|
||||
class Type1, \
|
||||
class Type2 \
|
||||
> \
|
||||
tmp<FieldField<Field1, typename product<Type1, Type2>::type> > \
|
||||
operator op \
|
||||
( \
|
||||
const tmp<FieldField<Field, Type1> >& tf1, \
|
||||
const tmp<FieldField<Field, Type2> >& tf2 \
|
||||
const tmp<FieldField<Field1, Type1> >& tf1, \
|
||||
const FieldField<Field2, Type2>& f2 \
|
||||
); \
|
||||
\
|
||||
template \
|
||||
< \
|
||||
template<class> class Field1, \
|
||||
template<class> class Field2, \
|
||||
class Type1, \
|
||||
class Type2 \
|
||||
> \
|
||||
tmp<FieldField<Field1, typename product<Type1, Type2>::type> > \
|
||||
operator op \
|
||||
( \
|
||||
const tmp<FieldField<Field1, Type1> >& tf1, \
|
||||
const tmp<FieldField<Field2, Type2> >& tf2 \
|
||||
); \
|
||||
\
|
||||
template \
|
||||
|
||||
Reference in New Issue
Block a user