Added min-max safety on weights
This commit is contained in:
parent
0cbb60d99b
commit
4da8b59c9f
2 changed files with 65 additions and 27 deletions
|
@ -185,7 +185,7 @@ regionCouplingFvPatchField<Type>::shadowPatchField() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return neighbour field given internal cell data
|
// Return neighbour field
|
||||||
template<class Type>
|
template<class Type>
|
||||||
tmp<Field<Type> > regionCouplingFvPatchField<Type>::patchNeighbourField() const
|
tmp<Field<Type> > regionCouplingFvPatchField<Type>::patchNeighbourField() const
|
||||||
{
|
{
|
||||||
|
@ -238,7 +238,6 @@ tmp<Field<Type> > regionCouplingFvPatchField<Type>::patchNeighbourField
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void regionCouplingFvPatchField<Type>::initEvaluate
|
void regionCouplingFvPatchField<Type>::initEvaluate
|
||||||
(
|
(
|
||||||
|
@ -288,7 +287,9 @@ void regionCouplingFvPatchField<Type>::initEvaluate
|
||||||
// HJ, 28/Sep/2011
|
// HJ, 28/Sep/2011
|
||||||
if (mag(den) > kSmall)
|
if (mag(den) > kSmall)
|
||||||
{
|
{
|
||||||
weights[faceI] = (mNei[faceI] - mean[faceI])/den;
|
// Limit weights for round-off safety
|
||||||
|
weights[faceI] =
|
||||||
|
Foam::max(0, Foam::min((mNei[faceI] - mean[faceI])/den, 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -340,7 +341,9 @@ void regionCouplingFvPatchField<Type>::initEvaluate
|
||||||
pDeltaCoeffs[faceI]
|
pDeltaCoeffs[faceI]
|
||||||
);
|
);
|
||||||
|
|
||||||
weights[faceI] = (magPhiNei[faceI] - mean)/den;
|
// Limit weights for round-off safety
|
||||||
|
weights[faceI] =
|
||||||
|
Foam::max(0, Foam::min((magPhiNei[faceI] - mean)/den, 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -410,6 +413,8 @@ void regionCouplingFvPatchField<Type>::initInterfaceMatrixUpdate
|
||||||
const direction cmpt,
|
const direction cmpt,
|
||||||
const Pstream::commsTypes
|
const Pstream::commsTypes
|
||||||
) const
|
) const
|
||||||
|
{
|
||||||
|
if (regionCouplePatch_.coupled())
|
||||||
{
|
{
|
||||||
// Prepare local matrix update buffer for the remote side.
|
// Prepare local matrix update buffer for the remote side.
|
||||||
// Note that only remote side will have access to its psiInternal
|
// Note that only remote side will have access to its psiInternal
|
||||||
|
@ -423,6 +428,16 @@ void regionCouplingFvPatchField<Type>::initInterfaceMatrixUpdate
|
||||||
this->patch().patchInternalField(psiInternal)
|
this->patch().patchInternalField(psiInternal)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"regionCouplingFvPatchField<Type>::initInterfaceMatrixUpdate"
|
||||||
|
) << "init matrix update calld in detached state"
|
||||||
|
<< abort(FatalError);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return matrix product for coupled boundary
|
// Return matrix product for coupled boundary
|
||||||
|
@ -436,6 +451,8 @@ void regionCouplingFvPatchField<Type>::updateInterfaceMatrix
|
||||||
const direction ,
|
const direction ,
|
||||||
const Pstream::commsTypes
|
const Pstream::commsTypes
|
||||||
) const
|
) const
|
||||||
|
{
|
||||||
|
if (regionCouplePatch_.coupled())
|
||||||
{
|
{
|
||||||
// Note: interpolation involves parallel communications and needs to
|
// Note: interpolation involves parallel communications and needs to
|
||||||
// happen during init. This changes the use of matrix update buffer
|
// happen during init. This changes the use of matrix update buffer
|
||||||
|
@ -451,6 +468,16 @@ void regionCouplingFvPatchField<Type>::updateInterfaceMatrix
|
||||||
result[fc[elemI]] -= coeffs[elemI]*pnf[elemI];
|
result[fc[elemI]] -= coeffs[elemI]*pnf[elemI];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"regionCouplingFvPatchField<Type>::updateInterfaceMatrix"
|
||||||
|
) << "Matrix update calld in detached state"
|
||||||
|
<< abort(FatalError);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
|
@ -162,8 +162,9 @@ public:
|
||||||
// HJ, 28/Sep/2011
|
// HJ, 28/Sep/2011
|
||||||
if (mag(den) > kSmall)
|
if (mag(den) > kSmall)
|
||||||
{
|
{
|
||||||
// mOwn > mNei
|
// Limit weights for round-off safety
|
||||||
wIn[faceI] = (magPhi[nei] - mean)/den;
|
wIn[faceI] =
|
||||||
|
Foam::max(0, Foam::min((magPhi[nei] - mean)/den, 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -209,7 +210,17 @@ public:
|
||||||
pDeltaCoeffs[faceI]
|
pDeltaCoeffs[faceI]
|
||||||
);
|
);
|
||||||
|
|
||||||
wp[faceI] = (magPhiNei[faceI] - mean)/den;
|
// Limit weights for round-off safety
|
||||||
|
wp[faceI] =
|
||||||
|
Foam::max
|
||||||
|
(
|
||||||
|
0,
|
||||||
|
Foam::min
|
||||||
|
(
|
||||||
|
(magPhi[faceI] - mean)/den,
|
||||||
|
1
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Reference in a new issue