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);
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++)
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++)
359 label facei =
pp.start();
365 neiStencil[facei].transfer
367 neiBndStencil[facei-mesh_.nInternalFaces()]
382 Foam::extendedUpwindCellToFaceStencil::extendedUpwindCellToFaceStencil
384 const cellToFaceStencil& stencil,
385 const bool pureUpwind,
386 const scalar minOpposedness
389 extendedCellToFaceStencil(stencil.
mesh()),
390 pureUpwind_(pureUpwind)
435 stencil.globalNumbering(),
449 stencil.globalNumbering(),
459 const fvMesh&
mesh =
dynamic_cast<const fvMesh&
>(stencil.mesh());
461 List<List<point>> stencilPoints(ownStencil_.
size());
469 forAll(stencilPoints, facei)
471 const point& fc =
mesh.faceCentres()[facei];
472 const vector& fArea =
mesh.faceAreas()[facei];
474 const List<point>&
points = stencilPoints[facei];
475 const labelList& stencil = ownStencil_[facei];
477 DynamicList<label> newStencil(stencil.size());
480 if (((
points[i]-fc) & fArea) < 0)
482 newStencil.append(stencil[i]);
485 if (newStencil.size() != stencil.size())
487 ownStencil_[facei].
transfer(newStencil);
498 forAll(stencilPoints, facei)
500 const point& fc =
mesh.faceCentres()[facei];
501 const vector& fArea =
mesh.faceAreas()[facei];
503 const List<point>&
points = stencilPoints[facei];
504 const labelList& stencil = neiStencil_[facei];
506 DynamicList<label> newStencil(stencil.size());
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
528 const cellToFaceStencil& stencil
531 extendedCellToFaceStencil(stencil.
mesh()),
536 ownStencil_ = stencil;
544 stencil.globalNumbering(),
551 const fvMesh&
mesh =
dynamic_cast<const fvMesh&
>(stencil.mesh());
553 List<List<point>> stencilPoints(ownStencil_.
size());
559 forAll(stencilPoints, facei)
561 const point& fc =
mesh.faceCentres()[facei];
562 const vector& fArea =
mesh.faceAreas()[facei];
564 const List<point>&
points = stencilPoints[facei];
565 const labelList& stencil = ownStencil_[facei];
567 DynamicList<label> newOwnStencil(stencil.size());
568 DynamicList<label> newNeiStencil(stencil.size());
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);
588 neiMapPtr_.reset(
new mapDistribute(ownMapPtr_()));
void size(const label n)
Older name for setAddressableSize.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const cellList & cells() const
List< labelList > labelListList
List of labelList.
#define forAll(list, i)
Loop across all elements in list.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
void setSize(const label n)
Alias for resize()
virtual const labelList & faceOwner() const
Return face owner.
errorManip< error > abort(error &err)
static void collectData(const mapDistribute &map, const labelListList &stencil, const GeometricField< T, fvPatchField, volMesh > &fld, List< List< T >> &stencilFld)
Use map to get the data into stencil order.
vector point
Point is a vector.
const vectorField & faceAreas() const
const polyBoundaryMesh & patches
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< label > labelList
A List of labels.
List< bool > boolList
A List of bools.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())