34 void Foam::extendedUpwindCellToFaceStencil::selectOppositeFaces
37 const scalar minOpposedness,
40 DynamicList<label>& oppositeFaces
47 SortableList<scalar> opposedness(cFaces.size(), -great);
52 label otherFacei = cFaces[i];
54 if (otherFacei != facei && nonEmptyFace[otherFacei])
56 if ((own[otherFacei] == celli) == (own[facei] == celli))
58 opposedness[i] = -(areas[otherFacei] & areas[facei]);
62 opposedness[i] = (areas[otherFacei] & areas[facei]);
67 label sz = opposedness.size();
69 oppositeFaces.clear();
71 scalar myAreaSqr =
magSqr(areas[facei]);
73 if (myAreaSqr > vSmall)
77 opposedness[i] /= myAreaSqr;
83 oppositeFaces.append(cFaces[opposedness.indices()[sz-1]]);
85 for (
label i = sz-2; i >= 0; --i)
87 if (opposedness[i] < minOpposedness)
91 oppositeFaces.append(cFaces[opposedness.indices()[i]]);
101 oppositeFaces.append(cFaces[opposedness.indices()[sz-1]]);
106 void Foam::extendedUpwindCellToFaceStencil::transportStencil
110 const scalar minOpposedness,
113 const bool stencilHasNeighbour,
115 DynamicList<label>& oppositeFaces,
120 label globalOwn = faceStencil[facei][0];
121 label globalNei = -1;
122 if (stencilHasNeighbour && faceStencil[facei].size() >= 2)
124 globalNei = faceStencil[facei][1];
138 faceStencilSet.clear();
141 const labelList& fStencil = faceStencil[oppositeFaces[i]];
145 label globalI = fStencil[j];
147 if (globalI != globalOwn && globalI != globalNei)
149 faceStencilSet.insert(globalI);
155 if (stencilHasNeighbour)
157 transportedStencil.setSize(faceStencilSet.size()+2);
159 transportedStencil[
n++] = globalOwn;
160 transportedStencil[
n++] = globalNei;
164 if (iter.key() != globalOwn && iter.key() != globalNei)
166 transportedStencil[
n++] = iter.key();
169 if (
n != transportedStencil.size())
172 <<
"problem:" << faceStencilSet
178 transportedStencil.setSize(faceStencilSet.size()+1);
180 transportedStencil[
n++] = globalOwn;
184 if (iter.key() != globalOwn)
186 transportedStencil[
n++] = iter.key();
189 if (
n != transportedStencil.size())
192 <<
"problem:" << faceStencilSet
199 void Foam::extendedUpwindCellToFaceStencil::transportStencils
202 const scalar minOpposedness,
207 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
208 const label nBnd = mesh_.nFaces()-mesh_.nInternalFaces();
209 const labelList& own = mesh_.faceOwner();
210 const labelList& nei = mesh_.faceNeighbour();
213 DynamicList<label> oppositeFaces;
218 boolList nonEmptyFace(mesh_.nFaces(),
true);
223 if (isA<emptyPolyPatch>(pp))
225 label facei = pp.start();
228 nonEmptyFace[facei++] =
false;
238 ownStencil.setSize(mesh_.nFaces());
241 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
261 label facei = pp.start();
283 else if (!isA<emptyPolyPatch>(pp))
311 for (
label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
313 neiBndStencil[facei-mesh_.nInternalFaces()] = ownStencil[facei];
332 neiStencil.setSize(mesh_.nFaces());
335 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
356 label facei = pp.start();
362 neiStencil[facei].transfer
364 neiBndStencil[facei-mesh_.nInternalFaces()]
382 const bool pureUpwind,
383 const scalar minOpposedness
387 pureUpwind_(pureUpwind)
463 collectData(ownMapPtr_(), ownStencil_, mesh.
C(), stencilPoints);
466 forAll(stencilPoints, facei)
472 const labelList& stencil = ownStencil_[facei];
477 if (((
points[i]-fc) & fArea) < 0)
479 newStencil.
append(stencil[i]);
482 if (newStencil.
size() != stencil.
size())
484 ownStencil_[facei].
transfer(newStencil);
492 collectData(neiMapPtr_(), neiStencil_, mesh.
C(), stencilPoints);
495 forAll(stencilPoints, facei)
501 const labelList& stencil = neiStencil_[facei];
506 if (((
points[i]-fc) & fArea) > 0)
508 newStencil.
append(stencil[i]);
511 if (newStencil.
size() != stencil.
size())
513 neiStencil_[facei].
transfer(newStencil);
533 ownStencil_ = stencil;
551 collectData(ownMapPtr_(), ownStencil_, mesh.
C(), stencilPoints);
556 forAll(stencilPoints, facei)
562 const labelList& stencil = ownStencil_[facei];
568 if (((
points[i]-fc) & fArea) > 0)
570 newNeiStencil.
append(stencil[i]);
574 newOwnStencil.
append(stencil[i]);
577 if (newNeiStencil.
size() > 0)
579 ownStencil_[facei].
transfer(newOwnStencil);
580 neiStencil_[facei].
transfer(newNeiStencil);
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the 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 > &)
Transfer the contents of the argument List into this list.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Base class for extended cell-to-face stencils (face values from neighbouring cells)
const globalIndex & globalNumbering() const
Global numbering for cells and boundary faces.
const polyMesh & mesh() const
Class containing processor-to-processor mapping information.
Calculates/contains the extended cell-to-face stencil.
static void collectData(const distributionMap &map, const labelListList &stencil, const VolField< Type > &fld, List< List< Type >> &stencilFld)
Use map to get the data into stencil order.
extendedUpwindCellToFaceStencil(const cellToFaceStencil &, const bool pureUpwind, const scalar minOpposedness)
Construct from mesh and uncompacted centred face stencil.
Mesh data needed to do the Finite Volume discretisation.
const volVectorField & C() const
Return cell centres.
virtual const labelList & faceOwner() const
Return face owner.
const vectorField & faceCentres() const
const vectorField & faceAreas() const
const cellList & cells() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fvPatchList & patches
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManip< error > abort(error &err)
List< bool > boolList
Bool container classes.
List< labelList > labelListList
A List of labelList.
Field< vector > vectorField
Specialisation of Field<T> for vector.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
dimensioned< scalar > magSqr(const dimensioned< Type > &)