Merge remote branch 'remotes/origin/hotfix/harmonicBC' into HrvojeJasak

This commit is contained in:
Hrvoje Jasak 2011-03-22 13:10:27 +00:00
commit 1709f904c0
2 changed files with 52 additions and 20 deletions

View file

@ -180,25 +180,27 @@ void regionCoupleFvPatchField<Type>::evaluate
Field<Type> fOwn = this->patchInternalField(); Field<Type> fOwn = this->patchInternalField();
Field<Type> fNei = this->patchNeighbourField(); Field<Type> fNei = this->patchNeighbourField();
scalarField mOwn = mag(fOwn); scalarField magFOwn = mag(fOwn);
scalarField mNei = mag(fNei); scalarField magFNei = mag(fNei);
scalarField mean = 2*(mOwn*mNei)/(mOwn + mNei + SMALL);
scalarField weights(fOwn.size(), 0.5); // Calculate internal weights using field magnitude
scalarField weights(fOwn.size());
scalar den;
forAll (weights, faceI) forAll (weights, faceI)
{ {
den = mOwn[faceI] - mNei[faceI]; scalar mOwn = magFOwn[faceI];
scalar mNei = magFNei[faceI];
scalar den = mOwn - mNei;
if (mag(den) > SMALL) if (mag(den) > SMALL)
{ {
weights[faceI] = (mean[faceI] - mNei[faceI])/den; scalar mean = 2.0*mOwn*mNei/(mOwn + mNei);
weights[faceI] = (mean - mNei)/den;
} }
else else
{ {
// Use 0.5 weights weights[faceI] = 0.5;
} }
} }

View file

@ -131,33 +131,63 @@ public:
scalarField magPhi = mag(phi); scalarField magPhi = mag(phi);
// Initialise weights to 0.5 for uniform field (den = 0)
scalarField& wIn = w.internalField(); scalarField& wIn = w.internalField();
wIn = 0.5;
// Calculate internal weights using field magnitude // Calculate internal weights using field magnitude
scalar mOwn, mNei, den, mean;
forAll (owner, faceI) forAll (owner, faceI)
{ {
mOwn = magPhi[owner[faceI]]; scalar mOwn = magPhi[owner[faceI]];
mNei = magPhi[neighbour[faceI]]; scalar mNei = magPhi[neighbour[faceI]];
mean = 2*(mOwn*mNei)/(mOwn + mNei + SMALL); scalar den = mOwn - mNei;
den = mOwn - mNei;
if (mag(den) > SMALL) if (mag(den) > SMALL)
{ {
scalar mean = 2.0*mOwn*mNei/(mOwn + mNei);
wIn[faceI] = (mean - mNei)/den; wIn[faceI] = (mean - mNei)/den;
} }
else else
{ {
// Use 0.5 weights wIn[faceI] = 0.5;
} }
} }
// Boundary weights are 1 forAll (phi.boundaryField(), pi)
w.boundaryField() = 1; {
fvsPatchScalarField& wp = w.boundaryField()[pi];
const fvPatchField<Type>& patchPhi = phi.boundaryField()[pi];
if (patchPhi.coupled())
{
scalarField magPhiOwn = mag(patchPhi.patchInternalField());
scalarField magPhiNei = mag(patchPhi.patchNeighbourField());
// Calculate internal weights using field magnitude
forAll (patchPhi, faceI)
{
scalar mOwn = magPhiOwn[faceI];
scalar mNei = magPhiNei[faceI];
scalar den = mOwn - mNei;
if (mag(den) > SMALL)
{
scalar mean = 2.0*mOwn*mNei/(mOwn + mNei);
wp[faceI] = (mean - mNei)/den;
}
else
{
wp[faceI] = 0.5;
}
}
}
else
{
// Boundary weights for uncoupled patches are 1
wp = 1;
}
}
return tw; return tw;
} }