34 bool Foam::blockDescriptor::assignGradings
36 const UList<gradingDescriptors>& ratios
41 switch (ratios.size())
46 expand_ = gradingDescriptors();
61 expand_[0] = ratios[0];
62 expand_[1] = ratios[0];
63 expand_[2] = ratios[0];
64 expand_[3] = ratios[0];
67 expand_[4] = ratios[1];
68 expand_[5] = ratios[1];
69 expand_[6] = ratios[1];
70 expand_[7] = ratios[1];
73 expand_[8] = ratios[2];
74 expand_[9] = ratios[2];
75 expand_[10] = ratios[2];
76 expand_[11] = ratios[2];
95 void Foam::blockDescriptor::check(
const Istream& is)
97 for (
const label pointi : blockShape_)
99 if (pointi < 0 || pointi >= vertices_.size())
102 <<
"Point label (" << pointi
103 <<
") out of range 0.." << vertices_.size() - 1
104 <<
" in block " << *
this 109 const point blockCentre(blockShape_.centre(vertices_));
110 const faceList faces(blockShape_.faces());
113 label outwardFaceCount = 0;
118 point faceCentre(faces[i].centre(vertices_));
119 vector faceNormal(faces[i].areaNormal(vertices_));
121 if (
mag(faceNormal) > SMALL)
123 if (((faceCentre - blockCentre) & faceNormal) > 0)
129 correctFaces[i] =
false;
139 if (outwardFaceCount == 0)
142 <<
"Block " << *
this <<
" is inside-out" 145 else if (outwardFaceCount != faces.
size())
148 <<
"Block " << *
this <<
" has inward-pointing faces" 153 if (!correctFaces[i])
164 void Foam::blockDescriptor::findCurvedFaces(
const label blockIndex)
166 const faceList shapeFaces(blockShape().faces());
168 forAll(shapeFaces, shapeFacei)
170 forAll(blockFaces_, facei)
172 const face&
f = blockFaces_[facei].vertices();
179 &&
f[0] == blockIndex
180 &&
f[1] == shapeFacei
185 curvedFaces_[shapeFacei] = facei;
198 const cellShape& bshape,
203 const UList<gradingDescriptors>&
expand,
218 if (!assignGradings(
expand))
221 <<
"Unknown definition of expansion ratios: " <<
expand 231 const dictionary&
dict,
232 const label blockIndex,
252 blockShape_ = cellShape
255 blockMeshTools::read<label>
258 dict.subOrEmptyDict(
"namedVertices")
268 zoneName_ = t.wordToken();
275 if (t.isPunctuation())
285 <<
"Incorrect token while reading n, expected '(', found " 294 <<
"Encountered old-style specification of mesh divisions" 308 List<gradingDescriptors>
expand(is);
310 if (!assignGradings(
expand))
313 <<
"Unknown definition of expansion ratios: " <<
expand 319 findCurvedFaces(blockIndex);
328 const label ni = sizes().x();
329 const label nj = sizes().y();
330 const label nk = sizes().z();
335 facePoints[0].
setSize((nj + 1)*(nk + 1));
336 facePoints[1].
setSize((nj + 1)*(nk + 1));
338 for (label j=0; j<=nj; j++)
340 for (label
k=0;
k<=nk;
k++)
342 facePoints[0][facePointLabel(0, j,
k)] =
344 facePoints[1][facePointLabel(1, j,
k)] =
349 facePoints[2].
setSize((ni + 1)*(nk + 1));
350 facePoints[3].
setSize((ni + 1)*(nk + 1));
352 for (label i=0; i<=ni; i++)
354 for (label
k=0;
k<=nk;
k++)
356 facePoints[2][facePointLabel(2, i,
k)] =
358 facePoints[3][facePointLabel(3, i,
k)] =
363 facePoints[4].
setSize((ni + 1)*(nj + 1));
364 facePoints[5].
setSize((ni + 1)*(nj + 1));
366 for (label i=0; i<=ni; i++)
368 for (label j=0; j<=nj; j++)
370 facePoints[4][facePointLabel(4, i, j)] =
371 points[pointLabel(i, j, 0)];
372 facePoints[5][facePointLabel(5, i, j)] =
373 points[pointLabel(i, j, nk)];
383 FixedList<pointField, 6>& facePoints
386 forAll(curvedFaces_, blockFacei)
388 if (curvedFaces_[blockFacei] >= 0)
390 blockFaces_[curvedFaces_[blockFacei]].project
394 facePoints[blockFacei]
408 const dictionary* varDictPtr = d.findDict(
"namedBlocks");
424 const cellShape& bshape = bd.blockShape();
427 os << bshape.model().
name() <<
" (";
429 forAll(blockLabels, labeli)
435 os << blockLabels[labeli];
439 if (bd.zoneName().size())
441 os <<
' ' << bd.zoneName();
444 os <<
' ' << bd.density()
448 const List<gradingDescriptors>&
expand = bd.grading();
496 const InfoProxy<blockDescriptor>& iproxy
499 const auto& bd = *iproxy;
501 os <<
"Dimensions:" << bd.density()
502 <<
" nPoints:" << bd.nPoints()
503 <<
" nCells:" << bd.nCells()
504 <<
" nFaces:" << bd.nFaces()
505 <<
" nInternalFaces:" << bd.nInternalFaces()
void size(const label n)
Older name for setAddressableSize.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A 1D vector of objects of type <T> with a fixed length <N>.
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.
PtrList< blockFace > blockFaceList
A PtrList of blockFaces.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Begin list [isseparator].
const Cmpt & y() const noexcept
Access to the vector y component.
label k
Boltzmann constant.
FixedList< pointField, 6 > facePoints(const pointField &points) const
Return the list of face-points for all of the faces of the block.
void setSize(const label n)
Dummy function, to make FixedList consistent with List.
static void write(Ostream &, const label blocki, const dictionary &)
Write block index with dictionary lookup.
#define forAll(list, i)
Loop across all elements in list.
List< face > faceList
List of faces.
pointField vertices(const blockVertexList &bvl)
vectorField pointField
pointField is a vectorField.
blockDescriptor(const blockDescriptor &)=default
Copy construct.
label size() const noexcept
The number of entries in the list.
const labelVector & sizes() const
The (i,j,k) addressing dimensions.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void correctFacePoints(FixedList< pointField, 6 > &) const
Correct the location of the given face-points.
const Cmpt & x() const noexcept
Access to the vector x component.
OBJstream os(runTime.globalPath()/outputName)
virtual const fileName & name() const
Read/write access to the name of the stream.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
const Cmpt & z() const noexcept
Access to the vector z component.
vector point
Point is a vector.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
PtrList< blockEdge > blockEdgeList
A PtrList of blockEdges.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
Vector< label > labelVector
Vector of labels.
List< label > labelList
A List of labels.
static bool sameVertices(const face &a, const face &b)
True if the faces have all the same vertices.
List< bool > boolList
A List of bools.
string expand(const std::string &s, const HashTable< string > &mapping, const char sigil='$')
Expand occurrences of variables according to the mapping and return the expanded string.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...