ENH: simpler logic for doTransform() check

- test pTraits rank first (compile-time) and then parallel()
This commit is contained in:
Mark Olesen
2023-01-09 20:19:10 +01:00
parent 33c9df7741
commit 248e5ff86f
15 changed files with 45 additions and 58 deletions

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cyclicPointPatchField_H
#define cyclicPointPatchField_H
#ifndef Foam_cyclicPointPatchField_H
#define Foam_cyclicPointPatchField_H
#include "coupledPointPatchField.H"
#include "cyclicPointPatch.H"
@ -142,7 +142,7 @@ public:
//- Does the patch field perform the transformation
virtual bool doTransform() const
{
return !(cyclicPatch_.parallel() || pTraits<Type>::rank == 0);
return (pTraits<Type>::rank && !cyclicPatch_.parallel());
}
//- Return face transformation tensor

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef processorPointPatchField_H
#define processorPointPatchField_H
#ifndef Foam_processorPointPatchField_H
#define Foam_processorPointPatchField_H
#include "coupledPointPatchField.H"
#include "processorPointPatch.H"
@ -145,10 +145,10 @@ public:
virtual bool doTransform() const
{
return
!(
procPatch_.procPolyPatch().parallel()
|| pTraits<Type>::rank == 0
);
(
pTraits<Type>::rank
&& !procPatch_.procPolyPatch().parallel()
);
}

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef processorCyclicPointPatchField_H
#define processorCyclicPointPatchField_H
#ifndef Foam_processorCyclicPointPatchField_H
#define Foam_processorCyclicPointPatchField_H
#include "coupledPointPatchField.H"
#include "processorCyclicPointPatch.H"
@ -149,10 +149,10 @@ public:
virtual bool doTransform() const
{
return
!(
pTraits<Type>::rank == 0
|| procPatch_.procPolyPatch().parallel()
);
(
pTraits<Type>::rank
&& !procPatch_.procPolyPatch().parallel()
);
}

View File

@ -39,8 +39,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cyclicFaPatchField_H
#define cyclicFaPatchField_H
#ifndef Foam_cyclicFaPatchField_H
#define Foam_cyclicFaPatchField_H
#include "coupledFaPatchField.H"
#include "cyclicLduInterfaceField.H"
@ -205,7 +205,7 @@ public:
//- Does the patch field perform the transformation
virtual bool doTransform() const
{
return !(cyclicPatch_.parallel() || pTraits<Type>::rank == 0);
return (pTraits<Type>::rank && !cyclicPatch_.parallel());
}
//- Return face transformation tensor

View File

@ -38,8 +38,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef processorFaPatchField_H
#define processorFaPatchField_H
#ifndef Foam_processorFaPatchField_H
#define Foam_processorFaPatchField_H
#include "coupledFaPatchField.H"
#include "processorLduInterfaceField.H"
@ -254,7 +254,7 @@ public:
//- Does the patch field perform the transformation
virtual bool doTransform() const
{
return !(procPatch_.parallel() || pTraits<Type>::rank == 0);
return (pTraits<Type>::rank && !procPatch_.parallel());
}
//- Return face transformation tensor

View File

@ -53,8 +53,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cyclicFvPatchField_H
#define cyclicFvPatchField_H
#ifndef Foam_cyclicFvPatchField_H
#define Foam_cyclicFvPatchField_H
#include "coupledFvPatchField.H"
#include "cyclicLduInterfaceField.H"
@ -220,7 +220,7 @@ public:
//- Does the patch field perform the transformation
virtual bool doTransform() const
{
return !(cyclicPatch_.parallel() || pTraits<Type>::rank == 0);
return (pTraits<Type>::rank && !cyclicPatch_.parallel());
}
//- Return face transformation tensor

View File

@ -183,7 +183,7 @@ Foam::cyclicACMIFvPatchField<Type>::patchNeighbourField() const
if (doTransform())
{
tpnf.ref() = transform(forwardT(), tpnf());
transform(tpnf.ref(), forwardT(), tpnf());
}
return tpnf;

View File

@ -52,8 +52,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cyclicACMIFvPatchField_H
#define cyclicACMIFvPatchField_H
#ifndef Foam_cyclicACMIFvPatchField_H
#define Foam_cyclicACMIFvPatchField_H
#include "coupledFvPatchField.H"
#include "cyclicACMILduInterfaceField.H"
@ -255,8 +255,7 @@ public:
//- Does the patch field perform the transformation
virtual bool doTransform() const
{
return
!(cyclicACMIPatch_.parallel() || pTraits<Type>::rank == 0);
return (pTraits<Type>::rank && !cyclicACMIPatch_.parallel());
}
//- Return face transformation tensor

View File

@ -168,7 +168,7 @@ Foam::cyclicAMIFvPatchField<Type>::patchNeighbourField() const
if (doTransform())
{
tpnf.ref() = transform(forwardT(), tpnf());
transform(tpnf.ref(), forwardT(), tpnf());
}
return tpnf;

View File

@ -57,9 +57,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cyclicAMIFvPatchField_H
#define cyclicAMIFvPatchField_H
#ifndef Foam_cyclicAMIFvPatchField_H
#define Foam_cyclicAMIFvPatchField_H
#include "coupledFvPatchField.H"
#include "cyclicAMILduInterfaceField.H"
@ -242,8 +241,7 @@ public:
//- Does the patch field perform the transformation
virtual bool doTransform() const
{
return
!(cyclicAMIPatch_.parallel() || pTraits<Type>::rank == 0);
return (pTraits<Type>::rank && !cyclicAMIPatch_.parallel());
}
//- Return face transformation tensor

View File

@ -120,7 +120,7 @@ Foam::jumpCyclicAMIFvPatchField<Type>::patchNeighbourField() const
if (this->doTransform())
{
tpnf = transform(this->forwardT(), tpnf);
transform(tpnf.ref(), this->forwardT(), tpnf());
}
tmp<Field<Type>> tjf = jump();

View File

@ -47,8 +47,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef processorFvPatchField_H
#define processorFvPatchField_H
#ifndef Foam_processorFvPatchField_H
#define Foam_processorFvPatchField_H
#include "coupledFvPatchField.H"
#include "processorLduInterfaceField.H"
@ -253,7 +253,6 @@ public:
) const;
//- Processor coupled interface functions
//- Return communicator used for comms
@ -277,7 +276,7 @@ public:
//- Does the patch field perform the transformation
virtual bool doTransform() const
{
return !(procPatch_.parallel() || pTraits<Type>::rank == 0);
return (pTraits<Type>::rank && !procPatch_.parallel());
}
//- Return face transformation tensor
@ -291,7 +290,6 @@ public:
{
return pTraits<Type>::rank;
}
};

View File

@ -53,8 +53,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef processorCyclicFvPatchField_H
#define processorCyclicFvPatchField_H
#ifndef Foam_processorCyclicFvPatchField_H
#define Foam_processorCyclicFvPatchField_H
#include "processorCyclicFvPatch.H"
#include "processorFvPatchField.H"
@ -162,7 +162,7 @@ public:
//- Does the patch field perform the transformation
virtual bool doTransform() const
{
return !(procPatch_.parallel() || pTraits<Type>::rank == 0);
return (pTraits<Type>::rank && !procPatch_.parallel());
}
//- Return face transformation tensor

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cyclicACMIPointPatchField_H
#define cyclicACMIPointPatchField_H
#ifndef Foam_cyclicACMIPointPatchField_H
#define Foam_cyclicACMIPointPatchField_H
#include "coupledPointPatchField.H"
#include "cyclicACMIPointPatch.H"
@ -189,11 +189,7 @@ public:
//- Does the patch field perform the transformation
virtual bool doTransform() const
{
return
!(
cyclicACMIPatch_.parallel()
|| pTraits<Type>::rank == 0
);
return (pTraits<Type>::rank && !cyclicACMIPatch_.parallel());
}
//- Return face transformation tensor

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cyclicAMIPointPatchField_H
#define cyclicAMIPointPatchField_H
#ifndef Foam_cyclicAMIPointPatchField_H
#define Foam_cyclicAMIPointPatchField_H
#include "coupledPointPatchField.H"
#include "cyclicAMIPointPatch.H"
@ -189,11 +189,7 @@ public:
//- Does the patch field perform the transformation
virtual bool doTransform() const
{
return
!(
cyclicAMIPatch_.parallel()
|| pTraits<Type>::rank == 0
);
return (pTraits<Type>::rank && !cyclicAMIPatch_.parallel());
}
//- Return face transformation tensor