ENH: avoid unneeded transform operations for scalar pointField BCs
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -87,20 +88,27 @@ void Foam::basicSymmetryPointPatchField<Type>::evaluate
|
||||
const Pstream::commsTypes
|
||||
)
|
||||
{
|
||||
const vectorField& nHat = this->patch().pointNormals();
|
||||
if constexpr (!is_rotational_vectorspace_v<Type>)
|
||||
{
|
||||
// Rotational-invariant type : no-op
|
||||
}
|
||||
else
|
||||
{
|
||||
const vectorField& nHat = this->patch().pointNormals();
|
||||
|
||||
tmp<Field<Type>> tvalues =
|
||||
(
|
||||
const Field<Type> pif(this->patchInternalField());
|
||||
|
||||
// Could write as loop instead...
|
||||
tmp<Field<Type>> tvalues
|
||||
(
|
||||
this->patchInternalField()
|
||||
+ transform(I - 2.0*sqr(nHat), this->patchInternalField())
|
||||
)/2.0
|
||||
);
|
||||
0.5*(pif + transform(I - 2.0*sqr(nHat), pif))
|
||||
);
|
||||
|
||||
// Get internal field to insert values into
|
||||
Field<Type>& iF = const_cast<Field<Type>&>(this->primitiveField());
|
||||
// Get internal field to insert values into
|
||||
auto& iF = const_cast<Field<Type>&>(this->primitiveField());
|
||||
|
||||
this->setInInternalField(iF, tvalues());
|
||||
this->setInInternalField(iF, tvalues());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fixedValuePointPatchField.H"
|
||||
#include "boolList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -84,20 +84,27 @@ Foam::cyclicSlipPointPatchField<Type>::cyclicSlipPointPatchField
|
||||
template<class Type>
|
||||
void Foam::cyclicSlipPointPatchField<Type>::evaluate(const Pstream::commsTypes)
|
||||
{
|
||||
const vectorField& nHat = this->patch().pointNormals();
|
||||
if constexpr (!is_rotational_vectorspace_v<Type>)
|
||||
{
|
||||
// Rotational-invariant type : no-op
|
||||
}
|
||||
else
|
||||
{
|
||||
const vectorField& nHat = this->patch().pointNormals();
|
||||
|
||||
tmp<Field<Type>> tvalues =
|
||||
(
|
||||
const Field<Type> pif(this->patchInternalField());
|
||||
|
||||
// Could write as loop instead...
|
||||
tmp<Field<Type>> tvalues
|
||||
(
|
||||
this->patchInternalField()
|
||||
+ transform(I - 2.0*sqr(nHat), this->patchInternalField())
|
||||
)/2.0
|
||||
);
|
||||
0.5*(pif + transform(I - 2.0*sqr(nHat), pif))
|
||||
);
|
||||
|
||||
// Get internal field to insert values into
|
||||
Field<Type>& iF = const_cast<Field<Type>&>(this->primitiveField());
|
||||
// Get internal field to insert values into
|
||||
auto& iF = const_cast<Field<Type>&>(this->primitiveField());
|
||||
|
||||
this->setInInternalField(iF, tvalues());
|
||||
this->setInInternalField(iF, tvalues());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -91,20 +91,27 @@ void Foam::nonuniformTransformCyclicPointPatchField<Type>::evaluate
|
||||
const Pstream::commsTypes
|
||||
)
|
||||
{
|
||||
const vectorField& nHat = this->patch().pointNormals();
|
||||
if constexpr (!is_rotational_vectorspace_v<Type>)
|
||||
{
|
||||
// Rotational-invariant type : no-op
|
||||
}
|
||||
else
|
||||
{
|
||||
const vectorField& nHat = this->patch().pointNormals();
|
||||
|
||||
tmp<Field<Type>> tvalues =
|
||||
(
|
||||
const Field<Type> pif(this->patchInternalField());
|
||||
|
||||
// Could write as loop instead...
|
||||
tmp<Field<Type>> tvalues
|
||||
(
|
||||
this->patchInternalField()
|
||||
+ transform(I - 2.0*sqr(nHat), this->patchInternalField())
|
||||
)/2.0
|
||||
);
|
||||
0.5*(pif + transform(I - 2.0*sqr(nHat), pif))
|
||||
);
|
||||
|
||||
// Get internal field to insert values into
|
||||
Field<Type>& iF = const_cast<Field<Type>&>(this->primitiveField());
|
||||
// Get internal field to insert values into
|
||||
auto& iF = const_cast<Field<Type>&>(this->primitiveField());
|
||||
|
||||
this->setInInternalField(iF, tvalues());
|
||||
this->setInInternalField(iF, tvalues());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -106,20 +106,27 @@ void Foam::symmetryPlanePointPatchField<Type>::evaluate
|
||||
const Pstream::commsTypes
|
||||
)
|
||||
{
|
||||
vector nHat = symmetryPlanePatch_.n();
|
||||
if constexpr (!is_rotational_vectorspace_v<Type>)
|
||||
{
|
||||
// Rotational-invariant type : no-op
|
||||
}
|
||||
else
|
||||
{
|
||||
const symmTensor rot(I - 2.0*sqr(symmetryPlanePatch_.n()));
|
||||
|
||||
tmp<Field<Type>> tvalues =
|
||||
(
|
||||
const Field<Type> pif(this->patchInternalField());
|
||||
|
||||
// Could write as loop instead...
|
||||
tmp<Field<Type>> tvalues
|
||||
(
|
||||
this->patchInternalField()
|
||||
+ transform(I - 2.0*sqr(nHat), this->patchInternalField())
|
||||
)/2.0
|
||||
);
|
||||
0.5*(pif + transform(rot, pif))
|
||||
);
|
||||
|
||||
// Get internal field to insert values into
|
||||
Field<Type>& iF = const_cast<Field<Type>&>(this->primitiveField());
|
||||
// Get internal field to insert values into
|
||||
auto& iF = const_cast<Field<Type>&>(this->primitiveField());
|
||||
|
||||
this->setInInternalField(iF, tvalues());
|
||||
this->setInInternalField(iF, tvalues());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,7 +29,6 @@ License
|
||||
#include "wedgePointPatchField.H"
|
||||
#include "transformField.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
@ -101,17 +101,28 @@ Foam::wedgePointPatchField<Type>::wedgePointPatchField
|
||||
template<class Type>
|
||||
void Foam::wedgePointPatchField<Type>::evaluate(const Pstream::commsTypes)
|
||||
{
|
||||
// In order to ensure that the wedge patch is always flat, take the
|
||||
// normal vector from the first point
|
||||
const vector& nHat = this->patch().pointNormals()[0];
|
||||
if constexpr (!is_rotational_vectorspace_v<Type>)
|
||||
{
|
||||
// Rotational-invariant type : no-op
|
||||
}
|
||||
else
|
||||
{
|
||||
// In order to ensure that the wedge patch is always flat, take the
|
||||
// normal vector from the first point
|
||||
|
||||
tmp<Field<Type>> tvalues =
|
||||
transform(I - nHat*nHat, this->patchInternalField());
|
||||
const symmTensor rot(I - 2.0*sqr(this->patch().pointNormals()[0]));
|
||||
|
||||
// Get internal field to insert values into
|
||||
Field<Type>& iF = const_cast<Field<Type>&>(this->primitiveField());
|
||||
// Could write as loop instead...
|
||||
tmp<Field<Type>> tvalues
|
||||
(
|
||||
transform(rot, this->patchInternalField())
|
||||
);
|
||||
|
||||
this->setInInternalField(iF, tvalues());
|
||||
// Get internal field to insert values into
|
||||
auto& iF = const_cast<Field<Type>&>(this->primitiveField());
|
||||
|
||||
this->setInInternalField(iF, tvalues());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -88,13 +89,22 @@ void Foam::fixedNormalSlipPointPatchField<Type>::evaluate
|
||||
const Pstream::commsTypes
|
||||
)
|
||||
{
|
||||
tmp<Field<Type>> tvalues =
|
||||
transform(I - n_*n_, this->patchInternalField());
|
||||
if constexpr (!is_rotational_vectorspace_v<Type>)
|
||||
{
|
||||
// Rotational-invariant type : no-op
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp<Field<Type>> tvalues
|
||||
(
|
||||
transform(I - n_*n_, this->patchInternalField())
|
||||
);
|
||||
|
||||
// Get internal field to insert values into
|
||||
Field<Type>& iF = const_cast<Field<Type>&>(this->primitiveField());
|
||||
// Get internal field to insert values into
|
||||
auto& iF = const_cast<Field<Type>&>(this->primitiveField());
|
||||
|
||||
this->setInInternalField(iF, tvalues());
|
||||
this->setInInternalField(iF, tvalues());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -167,13 +167,13 @@ public:
|
||||
}
|
||||
|
||||
//- Return processor number
|
||||
int myProcNo() const
|
||||
int myProcNo() const noexcept
|
||||
{
|
||||
return procPolyPatch_.myProcNo();
|
||||
}
|
||||
|
||||
//- Return neighbour processor number
|
||||
int neighbProcNo() const
|
||||
int neighbProcNo() const noexcept
|
||||
{
|
||||
return procPolyPatch_.neighbProcNo();
|
||||
}
|
||||
@ -191,13 +191,13 @@ public:
|
||||
}
|
||||
|
||||
//- Return the underlying processorPolyPatch
|
||||
const processorPolyPatch& procPolyPatch() const
|
||||
const processorPolyPatch& procPolyPatch() const noexcept
|
||||
{
|
||||
return procPolyPatch_;
|
||||
}
|
||||
|
||||
//- Return mesh points in the correct order for the receiving side
|
||||
const labelList& reverseMeshPoints() const
|
||||
const labelList& reverseMeshPoints() const noexcept
|
||||
{
|
||||
return reverseMeshPoints_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user