37void Foam::extendedUpwindCellToFaceStencil::selectOppositeFaces
39 const boolList& nonEmptyFace,
40 const scalar minOpposedness,
43 DynamicList<label>& oppositeFaces
48 const cell& cFaces =
mesh_.cells()[celli];
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,
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,
211 const label nBnd = mesh_.nBoundaryFaces();
212 const labelList& own = mesh_.faceOwner();
213 const labelList& nei = mesh_.faceNeighbour();
221 boolList nonEmptyFace(mesh_.nFaces(),
true);
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();
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()]
382Foam::extendedUpwindCellToFaceStencil::extendedUpwindCellToFaceStencil
385 const bool pureUpwind,
386 const scalar minOpposedness
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);
526Foam::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());
557 neiStencil_.setSize(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_()));
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
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 setSize(const label n)
Same as resize().
void size(const label n)
Older name for setAddressableSize.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
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.
extendedCellToFaceStencil(const polyMesh &)
Construct from mesh.
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.
Mesh data needed to do the Finite Volume discretisation.
Class containing processor-to-processor mapping information.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
A patch is a list of labels that address the faces in the global face list.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
List< bool > boolList
A List of bools.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
#define forAll(list, i)
Loop across all elements in list.