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=
(
this->patch().weights()*this->patchInternalField()
+ (1.0 - this->patch().weights())*patchNeighbourField()
lerp
(
this->patchNeighbourField(),
this->patchInternalField(),
this->patch().weights()
)
);
}

View File

@ -112,7 +112,7 @@ public:
scalar phict = 1 - 0.5*gradf/gradcf;
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=
(
this->patch().weights()*this->patchInternalField()
+ (1.0 - this->patch().weights())*this->patchNeighbourField()
lerp
(
this->patchNeighbourField(),
this->patchInternalField(),
this->patch().weights()
)
);
fvPatchField<Type>::evaluate();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -264,6 +264,9 @@ Foam::surfaceInterpolationScheme<Type>::dotInterpolate
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]]);
}
@ -282,9 +285,11 @@ Foam::surfaceInterpolationScheme<Type>::dotInterpolate
{
psf =
pSf
& (
pLambda*vf.boundaryField()[pi].patchInternalField()
+ (1.0 - pLambda)*vf.boundaryField()[pi].patchNeighbourField()
& lerp
(
vf.boundaryField()[pi].patchNeighbourField(),
vf.boundaryField()[pi].patchInternalField(),
pLambda
);
}
else

View File

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