ENH: lerp for patch/neighbour weights

This commit is contained in:
Mark Olesen
2023-01-20 11:55:12 +01:00
parent 128516b874
commit 4d45cfd5a9
5 changed files with 28 additions and 14 deletions

View File

@ -130,8 +130,12 @@ void Foam::coupledFaPatchField<Type>::evaluate(const Pstream::commsTypes)
{ {
Field<Type>::operator= Field<Type>::operator=
( (
this->patch().weights()*this->patchInternalField() lerp
+ (1.0 - this->patch().weights())*patchNeighbourField() (
this->patchNeighbourField(),
this->patchInternalField(),
this->patch().weights()
)
); );
} }

View File

@ -112,7 +112,7 @@ public:
scalar phict = 1 - 0.5*gradf/gradcf; scalar phict = 1 - 0.5*gradf/gradcf;
scalar limiter = min(max(phict/k_, 0), 1); scalar limiter = min(max(phict/k_, 0), 1);
return limiter*cdWeight + (1 - limiter)*udWeight; return lerp(udWeight, cdWeight, limiter);
} }
}; };

View File

@ -139,8 +139,12 @@ void Foam::coupledFvPatchField<Type>::evaluate(const Pstream::commsTypes)
Field<Type>::operator= Field<Type>::operator=
( (
this->patch().weights()*this->patchInternalField() lerp
+ (1.0 - this->patch().weights())*this->patchNeighbourField() (
this->patchNeighbourField(),
this->patchInternalField(),
this->patch().weights()
)
); );
fvPatchField<Type>::evaluate(); fvPatchField<Type>::evaluate();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -264,6 +264,9 @@ Foam::surfaceInterpolationScheme<Type>::dotInterpolate
for (label fi=0; fi<P.size(); fi++) for (label fi=0; fi<P.size(); fi++)
{ {
// Same as:
// sfi[fi] = Sfi[fi] & lerp(vfi[N[fi]], vfi[P[fi]], lambda[fi]);
// but maybe the compiler notices the fused multiply add form
sfi[fi] = Sfi[fi] & (lambda[fi]*(vfi[P[fi]] - vfi[N[fi]]) + vfi[N[fi]]); sfi[fi] = Sfi[fi] & (lambda[fi]*(vfi[P[fi]] - vfi[N[fi]]) + vfi[N[fi]]);
} }
@ -282,9 +285,11 @@ Foam::surfaceInterpolationScheme<Type>::dotInterpolate
{ {
psf = psf =
pSf pSf
& ( & lerp
pLambda*vf.boundaryField()[pi].patchInternalField() (
+ (1.0 - pLambda)*vf.boundaryField()[pi].patchNeighbourField() vf.boundaryField()[pi].patchNeighbourField(),
vf.boundaryField()[pi].patchInternalField(),
pLambda
); );
} }
else else

View File

@ -111,11 +111,12 @@ Foam::isoSurfacePoint::adaptPatchFields
sliceFldBf[patchi] sliceFldBf[patchi]
); );
const scalarField& w = mesh.weights().boundaryField()[patchi]; tmp<Field<Type>> f = lerp
(
tmp<Field<Type>> f = pfld.patchNeighbourField(),
w*pfld.patchInternalField() pfld.patchInternalField(),
+ (1.0-w)*pfld.patchNeighbourField(); mesh.weights().boundaryField()[patchi]
);
bitSet isCollocated bitSet isCollocated
( (