37 void Foam::extendedUpwindCellToFaceStencil::selectOppositeFaces
40 const scalar minOpposedness,
43 DynamicList<label>& oppositeFaces
50 SortableList<scalar> opposedness(cFaces.size(), -GREAT);
55 label otherFacei = cFaces[i];
57 if (otherFacei != facei && nonEmptyFace[otherFacei])
59 if ((own[otherFacei] == celli) == (own[facei] == celli))
61 opposedness[i] = -(areas[otherFacei] & areas[facei]);
65 opposedness[i] = (areas[otherFacei] & areas[facei]);
70 label sz = opposedness.size();
72 oppositeFaces.clear();
74 scalar myAreaSqr =
magSqr(areas[facei]);
76 if (myAreaSqr > VSMALL)
80 opposedness[i] /= myAreaSqr;
86 oppositeFaces.append(cFaces[opposedness.indices()[sz-1]]);
88 for (label i = sz-2; i >= 0; --i)
90 if (opposedness[i] < minOpposedness)
94 oppositeFaces.append(cFaces[opposedness.indices()[i]]);
104 oppositeFaces.append(cFaces[opposedness.indices()[sz-1]]);
109 void Foam::extendedUpwindCellToFaceStencil::transportStencil
113 const scalar minOpposedness,
116 const bool stencilHasNeighbour,
118 DynamicList<label>& oppositeFaces,
123 label globalOwn = faceStencil[facei][0];
124 label globalNei = -1;
125 if (stencilHasNeighbour && faceStencil[facei].size() >= 2)
127 globalNei = faceStencil[facei][1];
141 faceStencilSet.clear();
144 const labelList& fStencil = faceStencil[oppositeFaces[i]];
148 label globalI = fStencil[j];
150 if (globalI != globalOwn && globalI != globalNei)
152 faceStencilSet.insert(globalI);
158 if (stencilHasNeighbour)
160 transportedStencil.setSize(faceStencilSet.size()+2);
162 transportedStencil[
n++] = globalOwn;
163 transportedStencil[
n++] = globalNei;
165 for (
const label stencili : faceStencilSet)
167 if (stencili != globalOwn && stencili != globalNei)
169 transportedStencil[
n++] = stencili;
172 if (
n != transportedStencil.size())
175 <<
"problem:" << faceStencilSet
181 transportedStencil.setSize(faceStencilSet.size()+1);
183 transportedStencil[
n++] = globalOwn;
185 for (
const label stencili : faceStencilSet)
187 if (stencili != globalOwn)
189 transportedStencil[
n++] = stencili;
192 if (
n != transportedStencil.size())
195 <<
"problem:" << faceStencilSet
202 void Foam::extendedUpwindCellToFaceStencil::transportStencils
205 const scalar minOpposedness,
210 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
211 const label nBnd = mesh_.nBoundaryFaces();
212 const labelList& own = mesh_.faceOwner();
213 const labelList& nei = mesh_.faceNeighbour();
216 DynamicList<label> oppositeFaces;
221 boolList nonEmptyFace(mesh_.nFaces(),
true);
224 const polyPatch& pp =
patches[patchi];
226 if (isA<emptyPolyPatch>(pp))
228 label facei = pp.
start();
231 nonEmptyFace[facei++] =
false;
241 ownStencil.setSize(mesh_.nFaces());
244 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
263 const polyPatch& pp =
patches[patchi];
264 label facei = pp.
start();
286 else if (!isA<emptyPolyPatch>(pp))
314 for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
316 neiBndStencil[facei-mesh_.nInternalFaces()] = ownStencil[facei];
335 neiStencil.setSize(mesh_.nFaces());
338 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
358 const polyPatch& pp =
patches[patchi];
359 label facei = pp.
start();
365 neiStencil[facei].transfer
367 neiBndStencil[facei-mesh_.nInternalFaces()]
382 Foam::extendedUpwindCellToFaceStencil::extendedUpwindCellToFaceStencil
385 const bool pureUpwind,
386 const scalar minOpposedness
390 pureUpwind_(pureUpwind)
466 collectData(ownMapPtr_(), ownStencil_,
mesh.
C(), stencilPoints);
469 forAll(stencilPoints, facei)
475 const labelList& stencil = ownStencil_[facei];
480 if (((
points[i]-fc) & fArea) < 0)
482 newStencil.append(stencil[i]);
485 if (newStencil.size() != stencil.size())
487 ownStencil_[facei].transfer(newStencil);
495 collectData(neiMapPtr_(), neiStencil_,
mesh.
C(), stencilPoints);
498 forAll(stencilPoints, facei)
504 const labelList& stencil = neiStencil_[facei];
509 if (((
points[i]-fc) & fArea) > 0)
511 newStencil.append(stencil[i]);
514 if (newStencil.size() != stencil.size())
516 neiStencil_[facei].transfer(newStencil);
526 Foam::extendedUpwindCellToFaceStencil::extendedUpwindCellToFaceStencil
536 ownStencil_ = stencil;
554 collectData(ownMapPtr_(), ownStencil_,
mesh.
C(), stencilPoints);
557 neiStencil_.
setSize(ownStencil_.size());
559 forAll(stencilPoints, facei)
565 const labelList& stencil = ownStencil_[facei];
571 if (((
points[i]-fc) & fArea) > 0)
573 newNeiStencil.append(stencil[i]);
577 newOwnStencil.append(stencil[i]);
580 if (newNeiStencil.size() > 0)
582 ownStencil_[facei].transfer(newOwnStencil);
583 neiStencil_[facei].transfer(newNeiStencil);