41 if ((faceNormals[faceLabels[i]] &
n) < small)
65 octantNormal /=
mag(octantNormal);
80 pn[pointi] = pointNormals[pointi];
85 <<
"Average point normal not visible for point:"
110 else if (
n.x() < -small)
126 else if (
n.y() < -small)
141 else if (
n.z() < -small)
154 for (
label octant = 0; octant < 8; octant++)
156 if (visOctant & mask)
170 pn[pointi] = octantNormal[visI];
177 <<
"No visible octant for point:" << pp.
meshPoints()[pointi]
179 <<
"Normal set to " << pn[pointi] <<
endl;
208 os <<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
234 os <<
"v" <<
' ' << p1.
x() <<
' ' << p1.
y() <<
' ' << p1.
z() <<
endl;
235 os <<
"v" <<
' ' << p2.
x() <<
' ' << p2.
y() <<
' ' << p2.
z() <<
endl;
250 os <<
"v" <<
' ' << p1.
x() <<
' ' << p1.
y() <<
' ' << p1.
z() <<
endl;
253 <<
' ' << p2.
x() - p1.
x()
254 <<
' ' << p2.
y() - p1.
y()
255 <<
' ' << p2.
z() - p1.
z() <<
endl;
272 const cell& cFaces =
cells[cellLabels[i]];
276 usedFaces.
insert(cFaces[j]);
346 label edgeI = candidates[i];
348 const edge&
e = edges[edgeI];
350 if ((
e[0] == v0 &&
e[1] == v1) || (
e[0] == v1 &&
e[1] == v0))
372 label edgeI = v0Edges[i];
374 const edge&
e = edges[edgeI];
376 if ((
e.start() == v1) || (
e.end() == v1))
397 label edge0 = f0Edges[f0EdgeI];
401 label edge1 = f1Edges[f1EdgeI];
410 <<
"Faces " << f0 <<
" and " << f1 <<
" do not share an edge"
425 const cell& cFaces = mesh.
cells()[cell0I];
429 label facei = cFaces[cFacei];
446 <<
"No common face for"
447 <<
" cell0I:" << cell0I <<
" faces:" << cFaces
448 <<
" cell1I:" << cell1I <<
" faces:"
449 << mesh.
cells()[cell1I]
473 label facei = eFaces[eFacei];
490 if ((face0 == -1) || (face1 == -1))
493 <<
"Can not find faces using edge " << mesh.
edges()[edgeI]
504 const label thisEdgeI,
505 const label thisVertI
508 forAll(edgeLabels, edgeLabelI)
510 label edgeI = edgeLabels[edgeLabelI];
512 if (edgeI != thisEdgeI)
516 if ((
e.start() == thisVertI) || (
e.end() == thisVertI))
524 <<
"Can not find edge in "
526 <<
" connected to edge "
527 << thisEdgeI <<
" with vertices " << mesh.
edges()[thisEdgeI]
563 const label otherCelli,
570 <<
"Face " << facei <<
" is not internal"
576 if (newCelli == otherCelli)
590 const label startEdgeI,
591 const label startVertI,
597 label edgeI = startEdgeI;
599 label vertI = startVertI;
601 for (
label iter = 0; iter < nEdges; iter++)
603 edgeI =
otherEdge(mesh, fEdges, edgeI, vertI);
605 vertI = mesh.
edges()[edgeI].otherVertex(vertI);
623 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
625 if (dirs[cmpt] == -1)
627 pt[cmpt] = 0.5*(
min[cmpt] +
max[cmpt]);
644 bool isConstrained =
false;
645 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
647 if (dirs[cmpt] == -1)
649 isConstrained =
true;
658 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
660 if (dirs[cmpt] == -1)
662 pts[i][cmpt] = 0.5*(
min[cmpt] +
max[cmpt]);
677 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
679 if (dirs[cmpt] == -1)
694 bool isConstrained =
false;
695 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
697 if (dirs[cmpt] == -1)
699 isConstrained =
true;
708 for (
direction cmpt=0; cmpt<vector::nComponents; cmpt++)
710 if (dirs[cmpt] == -1)
750 const label startEdgeI
762 label edgeI = startEdgeI;
766 for (
label i = 0; i < 3; i++)
773 if ((eVec & avgVec) > 0)
787 avgVec /=
mag(avgVec) + vSmall;
811 scalar maxCos = -great;
814 for (
label i = 0; i < 4; i++)
818 label e0 = cEdges[cEdgeI];
820 if (!doneEdges.
found(e0))
824 scalar cosAngle =
mag(avgDir & cutDir);
826 if (cosAngle > maxCos)
846 if (!doneEdges.
found(cEdges[cEdgeI]))
849 <<
"Cell:" << celli <<
" edges:" << cEdges <<
endl
850 <<
"Edge:" << cEdges[cEdgeI] <<
" not yet handled"
858 <<
"Problem : did not find edge aligned with " << cutDir
#define forAll(list, i)
Loop across all elements in list.
bool insert(const Key &key)
Insert a new entry.
List< Key > toc() const
Return the table of contents.
bool found(const Key &) const
Return true if hashedEntry is found in table.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
label nPoints() const
Return number of points supporting patch faces.
const Field< PointType > & pointNormals() const
Return point normals for patch.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
const Field< PointType > & points() const
Return reference to global points.
const labelListList & pointFaces() const
Return point-face addressing.
const Field< PointType > & faceNormals() const
Return face normals for patch.
A List with indirect addressing.
iterator end()
Return an iterator to end traversing the UList.
const point & min() const
Minimum point defining the bounding box.
const point & max() const
Maximum point defining the bounding box.
A cell is defined as a list of faces with extra functionality.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A cellMatcher for hex cells.
Mesh consisting of general polyhedral cells.
const boundBox & bounds() const
Return mesh bounding box.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
Cell-face mesh analysis engine.
const labelListList & pointEdges() const
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const labelListList & cellEdges() const
virtual const labelList & faceOwner() const =0
Face face-owner addressing.
virtual const labelList & faceNeighbour() const =0
Face face-neighbour addressing.
virtual const pointField & points() const =0
Return mesh points.
const labelListList & edgeFaces() const
const labelListList & faceEdges() const
const labelListList & edgeCells() const
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
const cellList & cells() const
Representation of a 3D Cartesian coordinate system as a Vector of vectors.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionedScalar e
Elementary charge.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Vector< scalar > vector
A scalar version of the templated Vector.
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
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, &mergedCyclicPolyPatch::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]