diff --git a/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.C b/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.C index fd79d3835a..7c68958b15 100644 --- a/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.C +++ b/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.C @@ -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 @@ -628,197 +628,245 @@ BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#define PRODUCT_OPERATOR(product, op, opFunc) \ - \ -template class Field, class Type1, class Type2> \ -void opFunc \ -( \ - FieldField::type>& f, \ - const FieldField& f1, \ - const FieldField& f2 \ -) \ -{ \ - forAll(f, i) \ - { \ - opFunc(f[i], f1[i], f2[i]); \ - } \ -} \ - \ -template class Field, class Type1, class Type2> \ -tmp::type> > \ -operator op \ -( \ - const FieldField& f1, \ - const FieldField& f2 \ -) \ -{ \ - typedef typename product::type productType; \ - tmp > tRes \ - ( \ - FieldField::NewCalculatedType(f1) \ - ); \ - opFunc(tRes(), f1, f2); \ - return tRes; \ -} \ - \ -template class Field, class Type1, class Type2> \ -tmp::type> > \ -operator op \ -( \ - const FieldField& f1, \ - const tmp >& tf2 \ -) \ -{ \ - typedef typename product::type productType; \ - tmp > tRes \ - ( \ - reuseTmpFieldField::New(tf2) \ - ); \ - opFunc(tRes(), f1, tf2()); \ - reuseTmpFieldField::clear(tf2); \ - return tRes; \ -} \ - \ -template class Field, class Type1, class Type2> \ -tmp::type> > \ -operator op \ -( \ - const tmp >& tf1, \ - const FieldField& f2 \ -) \ -{ \ - typedef typename product::type productType; \ - tmp > tRes \ - ( \ - reuseTmpFieldField::New(tf1) \ - ); \ - opFunc(tRes(), tf1(), f2); \ - reuseTmpFieldField::clear(tf1); \ - return tRes; \ -} \ - \ -template class Field, class Type1, class Type2> \ -tmp::type> > \ -operator op \ -( \ - const tmp >& tf1, \ - const tmp >& tf2 \ -) \ -{ \ - typedef typename product::type productType; \ - tmp > tRes \ - ( \ - reuseTmpTmpFieldField::New \ - (tf1, tf2) \ - ); \ - opFunc(tRes(), tf1(), tf2()); \ - reuseTmpTmpFieldField::clear \ - (tf1, tf2); \ - return tRes; \ -} \ - \ -template \ - class Field, class Type, class Form, class Cmpt, int nCmpt> \ -void opFunc \ -( \ - FieldField::type>& f, \ - const FieldField& f1, \ - const VectorSpace& vs \ -) \ -{ \ - forAll(f, i) \ - { \ - opFunc(f[i], f1[i], vs); \ - } \ -} \ - \ -template \ - class Field, class Type, class Form, class Cmpt, int nCmpt> \ -tmp::type> > \ -operator op \ -( \ - const FieldField& f1, \ - const VectorSpace& vs \ -) \ -{ \ - typedef typename product::type productType; \ - tmp > tRes \ - ( \ - FieldField::NewCalculatedType(f1) \ - ); \ - opFunc(tRes(), f1, static_cast(vs)); \ - return tRes; \ -} \ - \ -template \ - class Field, class Type, class Form, class Cmpt, int nCmpt> \ -tmp::type> > \ -operator op \ -( \ - const tmp >& tf1, \ - const VectorSpace& vs \ -) \ -{ \ - typedef typename product::type productType; \ - tmp > tRes \ - ( \ - reuseTmpFieldField::New(tf1) \ - ); \ - opFunc(tRes(), tf1(), static_cast(vs)); \ - reuseTmpFieldField::clear(tf1); \ - return tRes; \ -} \ - \ -template \ - class Field, class Form, class Cmpt, int nCmpt, class Type> \ -void opFunc \ -( \ - FieldField::type>& f, \ - const VectorSpace& vs, \ - const FieldField& f1 \ -) \ -{ \ - forAll(f, i) \ - { \ - opFunc(f[i], vs, f1[i]); \ - } \ -} \ - \ -template \ - class Field, class Form, class Cmpt, int nCmpt, class Type> \ -tmp::type> > \ -operator op \ -( \ - const VectorSpace& vs, \ - const FieldField& f1 \ -) \ -{ \ - typedef typename product::type productType; \ - tmp > tRes \ - ( \ - FieldField::NewCalculatedType(f1) \ - ); \ - opFunc(tRes(), static_cast(vs), f1); \ - return tRes; \ -} \ - \ -template \ - class Field, class Form, class Cmpt, int nCmpt, class Type> \ -tmp::type> > \ -operator op \ -( \ - const VectorSpace& vs, \ - const tmp >& tf1 \ -) \ -{ \ - typedef typename product::type productType; \ - tmp > tRes \ - ( \ - reuseTmpFieldField::New(tf1) \ - ); \ - opFunc(tRes(), static_cast(vs), tf1()); \ - reuseTmpFieldField::clear(tf1); \ - return tRes; \ +#define PRODUCT_OPERATOR(product, op, opFunc) \ + \ +template \ +< \ + template class Field1, \ + template class Field2, \ + class Type1, \ + class Type2 \ +> \ +void opFunc \ +( \ + FieldField::type>& f, \ + const FieldField& f1, \ + const FieldField& f2 \ +) \ +{ \ + forAll(f, i) \ + { \ + opFunc(f[i], f1[i], f2[i]); \ + } \ +} \ + \ +template \ +< \ + template class Field1, \ + template class Field2, \ + class Type1, \ + class Type2 \ +> \ +tmp::type> > \ +operator op \ +( \ + const FieldField& f1, \ + const FieldField& f2 \ +) \ +{ \ + typedef typename product::type productType; \ + tmp > tRes \ + ( \ + FieldField::NewCalculatedType(f1) \ + ); \ + opFunc(tRes(), f1, f2); \ + return tRes; \ +} \ + \ +template class Field, class Type1, class Type2> \ +tmp::type> > \ +operator op \ +( \ + const FieldField& f1, \ + const tmp >& tf2 \ +) \ +{ \ + typedef typename product::type productType; \ + tmp > tRes \ + ( \ + reuseTmpFieldField::New(tf2) \ + ); \ + opFunc(tRes(), f1, tf2()); \ + reuseTmpFieldField::clear(tf2); \ + return tRes; \ +} \ + \ +template \ +< \ + template class Field1, \ + template class Field2, \ + class Type1, \ + class Type2 \ +> \ +tmp::type> > \ +operator op \ +( \ + const FieldField& f1, \ + const tmp >& tf2 \ +) \ +{ \ + typedef typename product::type productType; \ + tmp > tRes \ + ( \ + FieldField::NewCalculatedType(f1) \ + ); \ + opFunc(tRes(), f1, tf2()); \ + tf2.clear(); \ + return tRes; \ +} \ + \ +template \ +< \ + template class Field1, \ + template class Field2, \ + class Type1, \ + class Type2 \ +> \ +tmp::type> > \ +operator op \ +( \ + const tmp >& tf1, \ + const FieldField& f2 \ +) \ +{ \ + typedef typename product::type productType; \ + tmp > tRes \ + ( \ + reuseTmpFieldField::New(tf1) \ + ); \ + opFunc(tRes(), tf1(), f2); \ + reuseTmpFieldField::clear(tf1); \ + return tRes; \ +} \ + \ +template \ +< \ + template class Field1, \ + template class Field2, \ + class Type1, \ + class Type2 \ +> \ +tmp::type> > \ +operator op \ +( \ + const tmp >& tf1, \ + const tmp >& tf2 \ +) \ +{ \ + typedef typename product::type productType; \ + tmp > tRes \ + ( \ + reuseTmpTmpFieldField::New \ + (tf1, tf2) \ + ); \ + opFunc(tRes(), tf1(), tf2()); \ + reuseTmpTmpFieldField::clear \ + (tf1, tf2); \ + return tRes; \ +} \ + \ +template \ + class Field, class Type, class Form, class Cmpt, int nCmpt> \ +void opFunc \ +( \ + FieldField::type>& f, \ + const FieldField& f1, \ + const VectorSpace& vs \ +) \ +{ \ + forAll(f, i) \ + { \ + opFunc(f[i], f1[i], vs); \ + } \ +} \ + \ +template \ + class Field, class Type, class Form, class Cmpt, int nCmpt> \ +tmp::type> > \ +operator op \ +( \ + const FieldField& f1, \ + const VectorSpace& vs \ +) \ +{ \ + typedef typename product::type productType; \ + tmp > tRes \ + ( \ + FieldField::NewCalculatedType(f1) \ + ); \ + opFunc(tRes(), f1, static_cast(vs)); \ + return tRes; \ +} \ + \ +template \ + class Field, class Type, class Form, class Cmpt, int nCmpt> \ +tmp::type> > \ +operator op \ +( \ + const tmp >& tf1, \ + const VectorSpace& vs \ +) \ +{ \ + typedef typename product::type productType; \ + tmp > tRes \ + ( \ + reuseTmpFieldField::New(tf1) \ + ); \ + opFunc(tRes(), tf1(), static_cast(vs)); \ + reuseTmpFieldField::clear(tf1); \ + return tRes; \ +} \ + \ +template \ + class Field, class Form, class Cmpt, int nCmpt, class Type> \ +void opFunc \ +( \ + FieldField::type>& f, \ + const VectorSpace& vs, \ + const FieldField& f1 \ +) \ +{ \ + forAll(f, i) \ + { \ + opFunc(f[i], vs, f1[i]); \ + } \ +} \ + \ +template \ + class Field, class Form, class Cmpt, int nCmpt, class Type> \ +tmp::type> > \ +operator op \ +( \ + const VectorSpace& vs, \ + const FieldField& f1 \ +) \ +{ \ + typedef typename product::type productType; \ + tmp > tRes \ + ( \ + FieldField::NewCalculatedType(f1) \ + ); \ + opFunc(tRes(), static_cast(vs), f1); \ + return tRes; \ +} \ + \ +template \ + class Field, class Form, class Cmpt, int nCmpt, class Type> \ +tmp::type> > \ +operator op \ +( \ + const VectorSpace& vs, \ + const tmp >& tf1 \ +) \ +{ \ + typedef typename product::type productType; \ + tmp > tRes \ + ( \ + reuseTmpFieldField::New(tf1) \ + ); \ + opFunc(tRes(), static_cast(vs), tf1()); \ + reuseTmpFieldField::clear(tf1); \ + return tRes; \ } PRODUCT_OPERATOR(typeOfSum, +, add) diff --git a/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.H b/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.H index ba4be61880..65f68b34ec 100644 --- a/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.H +++ b/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.H @@ -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 @@ -267,100 +267,138 @@ BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#define PRODUCT_OPERATOR(product, op, opFunc) \ - \ -template class Field, class Type1, class Type2> \ -void opFunc \ -( \ - FieldField::type>& f, \ - const FieldField& f1, \ - const FieldField& f2 \ -); \ - \ -template class Field, class Type1, class Type2> \ -tmp::type> > \ -operator op \ -( \ - const FieldField& f1, \ - const FieldField& f2 \ -); \ - \ -template class Field, class Type1, class Type2> \ -tmp::type> > \ -operator op \ -( \ - const FieldField& f1, \ - const tmp >& tf2 \ -); \ - \ -template class Field, class Type1, class Type2> \ -tmp::type> > \ -operator op \ -( \ - const tmp >& tf1, \ - const FieldField& f2 \ -); \ - \ -template class Field, class Type1, class Type2> \ -tmp::type> > \ -operator op \ -( \ - const tmp >& tf1, \ - const tmp >& tf2 \ -); \ - \ -template \ - class Field, class Type, class Form, class Cmpt, int nCmpt> \ -void opFunc \ -( \ - FieldField::type>& f, \ - const FieldField& f1, \ - const VectorSpace& vs \ -); \ - \ -template \ - class Field, class Type, class Form, class Cmpt, int nCmpt> \ -tmp::type> > \ -operator op \ -( \ - const FieldField& f1, \ - const VectorSpace& vs \ -); \ - \ -template \ - class Field, class Type, class Form, class Cmpt, int nCmpt> \ -tmp::type> > \ -operator op \ -( \ - const tmp >& tf1, \ - const VectorSpace& vs \ -); \ - \ -template \ - class Field, class Form, class Cmpt, int nCmpt, class Type> \ -void opFunc \ -( \ - FieldField::type>& f, \ - const VectorSpace& vs, \ - const FieldField& f1 \ -); \ - \ -template \ - class Field, class Form, class Cmpt, int nCmpt, class Type> \ -tmp::type> > \ -operator op \ -( \ - const VectorSpace& vs, \ - const FieldField& f1 \ -); \ - \ -template \ - class Field, class Form, class Cmpt, int nCmpt, class Type> \ -tmp::type> > \ -operator op \ -( \ - const VectorSpace& vs, \ - const tmp >& tf1 \ +#define PRODUCT_OPERATOR(product, op, opFunc) \ + \ +template \ +< \ + template class Field1, \ + template class Field2, \ + class Type1, \ + class Type2 \ +> \ +void opFunc \ +( \ + FieldField::type>& f, \ + const FieldField& f1, \ + const FieldField& f2 \ +); \ + \ +template \ +< \ + template class Field1, \ + template class Field2, \ + class Type1, \ + class Type2 \ +> \ +tmp::type> > \ +operator op \ +( \ + const FieldField& f1, \ + const FieldField& f2 \ +); \ + \ +template class Field, class Type1, class Type2> \ +tmp::type> > \ +operator op \ +( \ + const FieldField& f1, \ + const tmp >& tf2 \ +); \ + \ +template \ +< \ + template class Field1, \ + template class Field2, \ + class Type1, \ + class Type2 \ +> \ +tmp::type> > \ +operator op \ +( \ + const FieldField& f1, \ + const tmp >& tf2 \ +); \ + \ +template \ +< \ + template class Field1, \ + template class Field2, \ + class Type1, \ + class Type2 \ +> \ +tmp::type> > \ +operator op \ +( \ + const tmp >& tf1, \ + const FieldField& f2 \ +); \ + \ +template \ +< \ + template class Field1, \ + template class Field2, \ + class Type1, \ + class Type2 \ +> \ +tmp::type> > \ +operator op \ +( \ + const tmp >& tf1, \ + const tmp >& tf2 \ +); \ + \ +template \ + class Field, class Type, class Form, class Cmpt, int nCmpt> \ +void opFunc \ +( \ + FieldField::type>& f, \ + const FieldField& f1, \ + const VectorSpace& vs \ +); \ + \ +template \ + class Field, class Type, class Form, class Cmpt, int nCmpt> \ +tmp::type> > \ +operator op \ +( \ + const FieldField& f1, \ + const VectorSpace& vs \ +); \ + \ +template \ + class Field, class Type, class Form, class Cmpt, int nCmpt> \ +tmp::type> > \ +operator op \ +( \ + const tmp >& tf1, \ + const VectorSpace& vs \ +); \ + \ +template \ + class Field, class Form, class Cmpt, int nCmpt, class Type> \ +void opFunc \ +( \ + FieldField::type>& f, \ + const VectorSpace& vs, \ + const FieldField& f1 \ +); \ + \ +template \ + class Field, class Form, class Cmpt, int nCmpt, class Type> \ +tmp::type> > \ +operator op \ +( \ + const VectorSpace& vs, \ + const FieldField& f1 \ +); \ + \ +template \ + class Field, class Form, class Cmpt, int nCmpt, class Type> \ +tmp::type> > \ +operator op \ +( \ + const VectorSpace& vs, \ + const tmp >& tf1 \ ); PRODUCT_OPERATOR(typeOfSum, +, add)