Skip to content
Snippets Groups Projects
Commit 4d45cfd5 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: lerp for patch/neighbour weights

parent 128516b8
No related branches found
No related tags found
1 merge request!593Field functions for lerp and clamp. Add clamping as Field methods
......@@ -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()
)
);
}
......
......@@ -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);
}
};
......
......@@ -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();
......
......@@ -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
......
......@@ -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
(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment