37void Foam::extendedUpwindCellToFaceStencil::selectOppositeFaces
39 const boolList& nonEmptyFace,
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]]);
109void 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
202void 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()]
385 const bool pureUpwind,
386 const scalar minOpposedness
390 pureUpwind_(pureUpwind)
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);
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);
536 ownStencil_ = stencil;
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);
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
void setSize(const label n)
Alias for resize()
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
void size(const label n)
Older name for setAddressableSize.
Base class for extended cell-to-face stencils (face values from neighbouring cells)
const polyMesh & mesh() const
const globalIndex & globalNumbering() const
Global numbering for cells and boundary faces.
Calculates/constains the extended cell-to-face stencil.
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.
Creates upwind stencil by shifting a centred stencil to upwind and downwind faces and optionally remo...
Mesh data needed to do the Finite Volume discretisation.
const volVectorField & C() const
Return cell centres as volVectorField.
Class containing processor-to-processor mapping information.
label start() const noexcept
The start label of boundary faces in the polyMesh face list.
virtual const labelList & faceOwner() const
Return face owner.
const vectorField & faceCentres() const
const vectorField & faceAreas() const
const cellList & cells() const
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< label > labelList
A List of labels.
List< labelList > labelListList
A List of labelList.
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< bool > boolList
A List of bools.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
#define forAll(list, i)
Loop across all elements in list.