42 if ((faceNormals[faceLabels[i]] & n) < SMALL)
66 octantNormal /=
mag(octantNormal);
79 if (
visNormal(pointNormals[pointI], faceNormals, pFaces))
81 pn[pointI] = pointNormals[pointI];
87 "Foam::meshTools::calcBoxPointNormals(const primitivePatch& pp)" 88 ) <<
"Average point normal not visible for point:" 103 const vector& n = faceNormals[pFaces[i]];
113 else if (n.
x() < -SMALL)
129 else if (n.
y() < -SMALL)
144 else if (n.
z() < -SMALL)
157 for (
label octant = 0; octant < 8; octant++)
159 if (visOctant & mask)
173 pn[pointI] = octantNormal[visI];
177 pn[pointI] = vector::zero;
181 "Foam::meshTools::calcBoxPointNormals" 182 "(const primitivePatch& pp)" 183 ) <<
"No visible octant for point:" << pp.
meshPoints()[pointI]
185 <<
"Normal set to " << pn[pointI] <<
endl;
214 os <<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
240 os <<
"v" <<
' ' << p1.
x() <<
' ' << p1.
y() <<
' ' << p1.
z() <<
endl;
241 os <<
"v" <<
' ' << p2.
x() <<
' ' << p2.
y() <<
' ' << p2.
z() <<
endl;
243 os <<
"l" <<
" " << (count + 1) <<
" " << (count + 2) <<
endl;
256 os <<
"v" <<
' ' << p1.
x() <<
' ' << p1.
y() <<
' ' << p1.
z() <<
endl;
259 <<
' ' << p2.
x() - p1.
x()
260 <<
' ' << p2.
y() - p1.
y()
261 <<
' ' << p2.
z() - p1.
z() <<
endl;
278 const cell& cFaces = cells[cellLabels[i]];
282 usedFaces.insert(cFaces[j]);
286 writeOBJ(os, faces, points, usedFaces.toc());
352 label edgeI = candidates[i];
354 const edge&
e = edges[edgeI];
356 if ((e[0] == v0 && e[1] == v1) || (e[0] == v1 && e[1] == v0))
378 label edgeI = v0Edges[i];
380 const edge&
e = edges[edgeI];
382 if ((e.
start() == v1) || (e.
end() == v1))
403 label edge0 = f0Edges[f0EdgeI];
407 label edge1 = f1Edges[f1EdgeI];
417 "meshTools::getSharedEdge(const primitiveMesh&, const label" 419 ) <<
"Faces " << f0 <<
" and " << f1 <<
" do not share an edge" 434 const cell& cFaces = mesh.
cells()[cell0I];
438 label faceI = cFaces[cFaceI];
456 "meshTools::getSharedFace(const primitiveMesh&, const label" 458 ) <<
"No common face for" 459 <<
" cell0I:" << cell0I <<
" faces:" << cFaces
460 <<
" cell1I:" << cell1I <<
" faces:" 461 << mesh.
cells()[cell1I]
485 label faceI = eFaces[eFaceI];
502 if ((face0 == -1) || (face1 == -1))
506 "meshTools::getEdgeFaces(const primitiveMesh&, const label" 507 ", const label, label&, label&" 508 ) <<
"Can not find faces using edge " << mesh.
edges()[edgeI]
519 const label thisEdgeI,
520 const label thisVertI
523 forAll(edgeLabels, edgeLabelI)
525 label edgeI = edgeLabels[edgeLabelI];
527 if (edgeI != thisEdgeI)
531 if ((e.
start() == thisVertI) || (e.
end() == thisVertI))
540 "meshTools::otherEdge(const primitiveMesh&, const labelList&" 541 ", const label, const label)" 542 ) <<
"Can not find edge in " 544 <<
" connected to edge " 545 << thisEdgeI <<
" with vertices " << mesh.
edges()[thisEdgeI]
581 const label otherCellI,
589 "meshTools::otherCell(const primitiveMesh&, const label" 591 ) <<
"Face " << faceI <<
" is not internal" 597 if (newCellI == otherCellI)
611 const label startEdgeI,
612 const label startVertI,
618 label edgeI = startEdgeI;
620 label vertI = startVertI;
622 for (
label iter = 0; iter < nEdges; iter++)
624 edgeI =
otherEdge(mesh, fEdges, edgeI, vertI);
626 vertI = mesh.
edges()[edgeI].otherVertex(vertI);
644 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
646 if (dirs[cmpt] == -1)
648 pt[cmpt] = 0.5*(min[cmpt] + max[cmpt]);
665 bool isConstrained =
false;
666 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
668 if (dirs[cmpt] == -1)
670 isConstrained =
true;
679 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
681 if (dirs[cmpt] == -1)
683 pts[i][cmpt] = 0.5*(min[cmpt] + max[cmpt]);
699 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
701 if (dirs[cmpt] == -1)
716 bool isConstrained =
false;
717 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
719 if (dirs[cmpt] == -1)
721 isConstrained =
true;
730 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
732 if (dirs[cmpt] == -1)
772 const label startEdgeI
779 "Foam::meshTools::getCutDir(const label, const label)" 786 label edgeI = startEdgeI;
790 for (
label i = 0; i < 3; i++)
797 if ((eVec & avgVec) > 0)
811 avgVec /=
mag(avgVec) + VSMALL;
829 "Foam::meshTools::getCutDir(const label, const vector&)" 837 scalar maxCos = -GREAT;
840 for (
label i = 0; i < 4; i++)
844 label e0 = cEdges[cEdgeI];
846 if (!doneEdges.found(e0))
850 scalar cosAngle =
mag(avgDir & cutDir);
852 if (cosAngle > maxCos)
862 doneEdges.insert(e0);
863 doneEdges.insert(e1);
864 doneEdges.insert(e2);
865 doneEdges.insert(e3);
872 if (!doneEdges.found(cEdges[cEdgeI]))
876 "meshTools::cutDirToEdge(const label, const vector&)" 877 ) <<
"Cell:" << cellI <<
" edges:" << cEdges <<
endl 878 <<
"Edge:" << cEdges[cEdgeI] <<
" not yet handled" 887 "meshTools::cutDirToEdge(const label, const vector&)" 888 ) <<
"Problem : did not find edge aligned with " << cutDir
iterator end()
Return an iterator to end traversing the UList.
static const label mXmYmZ
const point & min() const
Minimum describing the bounding box.
virtual const pointField & points() const =0
Return mesh points.
const Field< PointType > & pointNormals() const
Return point normals for patch.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
label getSharedEdge(const primitiveMesh &, const label f0, const label f1)
Return edge shared by two faces. Throws error if no edge found.
vector normEdgeVec(const primitiveMesh &, const label edgeI)
Normalized edge vector.
dimensioned< scalar > mag(const dimensioned< Type > &)
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
A cell is defined as a list of faces with extra functionality.
const labelListList & pointEdges() const
label getSharedFace(const primitiveMesh &, const label cell0, const label cell1)
Return face shared by two cells. Throws error if none found.
static const label mXpYpZ
void getEdgeFaces(const primitiveMesh &, const label cellI, const label edgeI, label &face0, label &face1)
Get faces on cell using edgeI. Throws error if no two found.
const labelListList & pointFaces() const
Return point-face addressing.
vectorField calcBoxPointNormals(const primitivePatch &pp)
Calculate point normals on a 'box' mesh (all edges aligned with.
label cutDirToEdge(const primitiveMesh &, const label cellI, const vector &cutDir)
Reverse of edgeToCutDir: given direction find edge bundle and.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
const cellList & cells() const
static const label mXmYpZMask
bool faceOnCell(const primitiveMesh &, const label cellI, const label faceI)
Is face used by cell.
static const label mXmYmZMask
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
const labelListList & faceEdges() const
label nPoints() const
Return number of points supporting patch faces.
static const label pXmYpZMask
const labelListList & cellEdges() const
vector edgeToCutDir(const primitiveMesh &, const label cellI, const label edgeI)
Given edge on hex find all 'parallel' (i.e. non-connected)
static const label mXmYpZ
bool edgeOnCell(const primitiveMesh &, const label cellI, const label edgeI)
Is edge used by cell.
Cell-face mesh analysis engine.
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define WarningIn(functionName)
Report a warning using Foam::Warning.
void constrainDirection(const polyMesh &mesh, const Vector< label > &dirs, vector &d)
Set the constrained components of directions/velocity to zero.
A List with indirect addressing.
const dimensionedScalar e
Elementary charge.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
void getParallelEdges(const primitiveMesh &, const label cellI, const label e0, label &, label &, label &)
Given edge on hex find other 'parallel', non-connected edges.
Representation of a 3D Cartesian coordinate system as a Vector of vectors.
static const label pXpYmZMask
const point & max() const
Maximum describing the bounding box.
A cellMatcher for hex cells.
errorManip< error > abort(error &err)
const Field< PointType > & faceNormals() const
Return face normals for patch.
label otherFace(const primitiveMesh &, const label cellI, const label faceI, const label edgeI)
Return face on cell using edgeI but not faceI. Throws error.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
static const label pXpYmZ
A list of faces which address into the list of points.
label otherEdge(const primitiveMesh &, const labelList &edgeLabels, const label edgeI, const label vertI)
Return label of other edge (out of candidates edgeLabels)
static const label mXpYmZ
Mesh consisting of general polyhedral cells.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
const labelListList & edgeFaces() const
const boundBox & bounds() const
Return mesh bounding box.
static const label pXpYpZ
label end() const
Return end vertex label.
static const label pXpYpZMask
void constrainToMeshCentre(const polyMesh &mesh, point &pt)
Set the constrained components of position to mesh centre.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Vector< scalar > vector
A scalar version of the templated Vector.
label walkFace(const primitiveMesh &, const label faceI, const label startEdgeI, const label startVertI, const label nEdges)
Returns label of edge nEdges away from startEdge (in the direction.
label otherCell(const primitiveMesh &, const label cellI, const label faceI)
Return cell on other side of face. Throws error.
label start() const
Return start vertex label.
const labelListList & edgeCells() const
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints,-1);const cellModel &hex=*(cellModeller::lookup("hex"));labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){pointMap[i]=i;}for(label i=0;i< nPoints;i++){if(f[i] > 0.0){hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells]=cellShape(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei){if(edges[ei].mag(points)< SMALL){label start=pointMap[edges[ei].start()];while(start!=pointMap[start]){start=pointMap[start];}label end=pointMap[edges[ei].end()];while(end!=pointMap[end]){end=pointMap[end];}label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;}}cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){cellShape &cs=cellShapes[celli];forAll(cs, i){cs[i]=pointMap[cs[i]];}cs.collapse();}label bcIDs[11]={-1, 0, 2, 4,-1, 5,-1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={&wallPolyPatch::typeName,&wallPolyPatch::typeName,&wallPolyPatch::typeName,&wallPolyPatch::typeName,&symmetryPolyPatch::typeName,&wedgePolyPatch::typeName,&polyPatch::typeName,&polyPatch::typeName,&polyPatch::typeName,&polyPatch::typeName,&symmetryPolyPatch::typeName,&oldCyclicPolyPatch::typeName};enum patchTypeNames{PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={"piston","valve","liner","cylinderHead","axis","wedge","inflow","outflow","presin","presout","symmetryPlane","cyclic"};List< SLList< face > > pFaces[nBCs]
bool edgeOnFace(const primitiveMesh &, const label faceI, const label edgeI)
Is edge used by face.
static const label mXpYmZMask
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
label findEdge(const edgeList &edges, const labelList &candidates, const label v0, const label v1)
Return edge among candidates that uses the two vertices.
void writeOBJ(Ostream &os, const point &pt)
Write obj representation of point.
static const label pXmYmZMask
virtual const labelList & faceOwner() const =0
Face face-owner addresing.
static const label mXpYpZMask
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
virtual const labelList & faceNeighbour() const =0
Face face-neighbour addressing.
static const label pXmYpZ
const Field< PointType > & points() const
Return reference to global points.
static const label pXmYmZ
bool visNormal(const vector &n, const vectorField &faceNormals, const labelList &faceLabels)
Check if n is in same direction as normals of all faceLabels.
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.