38 const dictionary&
dict,
42 const bool forceReference
47 regionNeedReference.setSize(regions.nRegions(),
true);
48 regionRefCells.setSize(regions.nRegions(), -1);
49 regionRefValues.setSize(regions.nRegions(), 0);
53 const volScalarField::GeometricBoundaryField& bfld =
54 fieldRef.boundaryField();
58 if (bfld[patchI].fixesValue())
62 const labelUList& fc = bfld[patchI].patch().patch().faceCells();
66 regionNeedReference[regions[fc[faceI]]] =
false;
71 Pstream::listCombineReduce(regionNeedReference, orEqOp<bool>());
76 forAll(regionNeedReference, regionI)
78 if (regionNeedReference[regionI])
91 word refCellName =
field.name() +
"RefCells";
92 word refPointName =
field.name() +
"RefPoints";
93 word refValueName =
field.name() +
"RefValues";
103 if (
dict.found(refCellName))
107 if (Pstream::master())
111 if (refCells.size() != regionNeedReference.size())
114 <<
"Number of refCells " << refCells.size()
115 <<
" does not correspond to number of regions " 116 << regionNeedReference.size()
122 label regionI = regions[refCells[i]];
124 if (regionNeedReference[regionI])
126 regionRefCells[regionI] = refCells[i];
127 regionRefValues[regionI] = refValues[i];
132 forAll(regionNeedReference, regionI)
136 regionNeedReference[regionI]
137 && regionRefCells[regionI] == -1
141 <<
"Have no reference cell for region " << regionI
143 <<
"Overall per-region reference cells " 150 else if (
dict.found(refPointName))
154 if (refPoints.size() != regionNeedReference.size())
157 <<
"Number of refPoints " << refPoints.size()
158 <<
" does not correspond to number of regions " 159 << regionNeedReference.size()
172 label celli =
field.mesh().findCell
180 Pout<<
"Found point " << refPoints[i]
181 <<
" in reference cell " << celli
182 <<
" at " <<
field.mesh().cellCentres()[celli]
183 <<
" for region " << regions[celli]
186 regionRefCells[regions[celli]] = celli;
187 hasRef[regions[celli]] = 1;
191 Pstream::listReduce(hasRef, sumOp<label>());
195 if (hasRef[regionI] != 1)
198 <<
"Unable to set reference cell for field " <<
field.name()
200 <<
" Reference points " << refPointName
202 <<
nl <<
" For region " << regionI
203 <<
" found on " << hasRef[regionI]
204 <<
" domains (should be one)" 212 <<
"Unable to set reference cell for field " <<
field.name()
214 <<
" Please supply either " << refCellName
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Find the reference cell nearest (in index) to the given cell but which is not on a cyclic...
UList< label > labelUList
A UList of labels.
#define forAll(list, i)
Loop across all elements in list.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
vectorField pointField
pointField is a vectorField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void setRefCells(const volScalarField &field, const volScalarField &fieldRef, const dictionary &dict, const label refCelli, const scalar refValue, boolList &needReference, labelList &refCells, scalarField &refValues, const bool forceReference=false)
Set reference cells for multi-region domains. Returns per region:
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
List< label > labelList
A List of labels.
List< bool > boolList
A List of bools.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)