Go to the documentation of this file.
45 for (
label i = 0; i < 4; i++)
74 const label tetPlaneBasePtI,
85 return movingTetLambda
99 const point& base = pPts[tetPlaneBasePtI];
101 scalar lambdaNumerator = (base - from) &
n;
102 scalar lambdaDenominator = (to - from) &
n;
109 if (
mag(lambdaDenominator) < tol)
111 if (
mag(lambdaNumerator) < tol)
121 if (
mag((to - from)) < tol/
mag(
n))
131 lambdaDenominator =
sign(lambdaDenominator)*SMALL;
136 return lambdaNumerator/lambdaDenominator;
146 const label tetPlaneBasePtI,
148 const label tetFaceI,
154 const pointField& oldPPts = mesh_.oldPoints();
157 const point&
b = pPts[tetPlaneBasePtI];
162 const point& b00 = oldPPts[tetPlaneBasePtI];
166 point b0 = b00 + stepFraction_*(
b - b00);
172 tetIndices tetIs(cellI, tetFaceI, tetPtI, mesh_);
180 point tet0PtA = tet00.
a() + stepFraction_*(tet.
a() - tet00.
a());
181 point tet0PtB = tet00.
b() + stepFraction_*(tet.
b() - tet00.
b());
182 point tet0PtC = tet00.
c() + stepFraction_*(tet.
c() - tet00.
c());
183 point tet0PtD = tet00.
d() + stepFraction_*(tet.
d() - tet00.
d());
186 tetPointRef tet0(tet0PtA, tet0PtB, tet0PtC, tet0PtD);
224 scalar lambdaNumerator = 0;
225 scalar lambdaDenominator = 0;
234 scalar a = (dP - dB) & dN;
235 scalar
b = ((dP - dB) & n0) + (dS & dN);
242 scalar discriminant =
sqr(
b) - 4.0*a*
c;
244 if (discriminant < 0)
278 lambdaNumerator = -
c;
279 lambdaDenominator =
b;
286 lambdaNumerator = -(dS & n0);
287 lambdaDenominator = ((dP - dB) & n0);
290 if (
mag(lambdaDenominator) < tol)
292 if (
mag(lambdaNumerator) < tol)
302 if (
mag((to - from)) < tol/
mag(
n))
311 lambdaDenominator =
sign(lambdaDenominator)*SMALL;
316 return lambdaNumerator/lambdaDenominator;
332 if (tetBasePtI == -1)
335 <<
"No base point for face " <<
tetFaceI_ <<
", " <<
f
336 <<
", produces a valid tet decomposition."
341 label otherFacePtI =
f.fcIndex(facePtI);
448 <<
"Tet tri face index error, can only be 0..3, supplied "
466 const cellList& pCells = mesh_.cells();
477 label fI = thisCell[cFI];
522 label tetBasePtI = mesh_.tetBasePtIs()[fI];
524 if (tetBasePtI == -1)
527 <<
"No base point for face " << fI <<
", " <<
f
528 <<
", produces a decomposition that has a minimum "
529 <<
"volume greater than tolerance."
534 eIndex -= tetBasePtI;
568 label id = particleCount_++;
573 <<
"Particle counter has overflowed. This might cause problems"
574 <<
" when reconstructing particle tracks." <<
endl;
636 return tetIndices(cellI_, tetFaceI_, tetPtI_, mesh_);
642 return currentTetIndices().tet(mesh_);
648 return currentTetIndices().faceTri(mesh_).normal();
654 return currentTetIndices().oldFaceTri(mesh_).normal();
685 <<
"cell, tetFace and tetPt search failure at position "
691 mesh_.findTetFacePt(cellI_, position_, tetFaceI_, tetPtI_);
693 if (tetFaceI_ == -1 || tetPtI_ == -1)
695 label oldCellI = cellI_;
705 if (cellI_ == -1 || tetFaceI_ == -1 || tetPtI_ == -1)
711 if (!mesh_.pointInCellBB(position_, oldCellI, 0.1))
719 <<
"position " << position_ <<
nl
720 <<
" for requested cell " << oldCellI <<
nl
721 <<
" If this is a restart or "
722 "reconstruction/decomposition etc. it is likely that"
723 " the write precision is not sufficient.\n"
724 " Either increase 'writePrecision' or "
725 "set 'writeFormat' to 'binary'"
742 point newPosition = position_;
744 const point& cC = mesh_.cellCentres()[cellI_];
746 label trap(1.0/trackingCorrectionTol + 1);
752 newPosition += trackingCorrectionTol*(cC - position_);
764 }
while (tetFaceI_ < 0 && iterNo <= trap);
769 <<
"cell, tetFace and tetPt search failure at position "
776 <<
"Particle moved from " << position_
777 <<
" to " << newPosition
778 <<
" in cell " << cellI_
779 <<
" tetFace " << tetFaceI_
780 <<
" tetPt " << tetPtI_ <<
nl
781 <<
" (A fraction of "
782 << 1.0 -
mag(cC - newPosition)/
mag(cC - position_)
783 <<
" of the distance to the cell centre)"
784 <<
" because a decomposition tetFace and tetPt "
785 <<
"could not be found."
789 position_ = newPosition;
792 if (debug && cellI_ != oldCellI)
795 <<
"Particle at position " << position_
796 <<
" searched for a cell, tetFace and tetPt." <<
nl
798 <<
" cell " << cellI_
799 <<
" tetFace " << tetFaceI_
800 <<
" tetPt " << tetPtI_ <<
nl
801 <<
" This is a different cell to that which was supplied"
802 <<
" (" << oldCellI <<
")." <<
nl
812 return faceI_ != -1 && faceI_ >= mesh_.nInternalFaces();
818 return stepFraction_;
824 return stepFraction_;
862 + stepFraction_*mesh_.time().deltaTValue();
868 return mesh_.isInternalFace(faceI);
874 return !internalFace(faceI);
880 return mesh_.boundaryMesh().whichPatch(faceI);
890 return mesh_.boundaryMesh()[patchI].whichFace(faceI);
bool boundaryFace(const label faceI) const
Is this global face a boundary face?
tetPointRef tet(const polyMesh &mesh) const
Return the geometry corresponding to this tet from the.
bool onBoundary() const
Is the particle on the boundary/(or outside the domain)?
label & face()
Return current face particle is on otherwise -1.
label origId() const
Return const access to the particle id on originating processor.
#define forAll(list, i)
Loop across all elements in list.
void crossEdgeConnectedFace(const label &cellI, label &tetFaceI, label &tetPtI, const edge &e)
Cross the from the given face across the given edge of the.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
scalar & stepFraction()
Return the fraction of time-step completed.
const labelList & tetBasePtIs() const
Return the tetBasePtIs.
static const label labelMax
label getNewParticleID() const
Get unique particle creation id.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
bool softImpact() const
Return the impact model to be used, soft or hard (default).
void tetNeighbour(label triI)
Modify the tet owner data by crossing triI.
scalar tetLambda(const vector &from, const vector &to, const label triI, const vector &tetArea, const label tetPlaneBasePtI, const label cellI, const label tetFaceI, const label tetPtI, const scalar tol) const
Find the lambda value for the line to-from across the.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tetIndices currentTetIndices() const
Return the indices of the current tet that the.
bool internalFace(const label faceI) const
Is this global face an internal face?
dimensioned< scalar > mag(const dimensioned< Type > &)
label faceInterpolation() const
Return the index of the face to be used in the interpolation.
dimensionedScalar sign(const dimensionedScalar &ds)
Mesh consisting of general polyhedral cells.
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]
label & cell()
Return current cell particle is in.
label & tetFace()
Return current tet face particle is in.
tetPointRef oldTet(const polyMesh &mesh) const
Return the geometry corresponding to this tet from the.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Pre-declare SubField and related Field type.
void append(const T &)
Append an element at the end of the list.
label & tetPt()
Return current tet face particle is in.
virtual const labelList & faceOwner() const
Return face owner.
const polyMesh & mesh() const
Return the mesh database.
scalar movingTetLambda(const vector &from, const vector &to, const label triI, const vector &tetArea, const label tetPlaneBasePtI, const label cellI, const label tetFaceI, const label tetPtI, const scalar tol) const
Find the lambda value for a moving tri face.
errorManip< error > abort(error &err)
const double e
Elementary charge.
label tetPtI_
Index of the point on the face that defines the decomposed.
void findTris(const vector &position, DynamicList< label > &faceList, const tetPointRef &tet, const FixedList< vector, 4 > &tetAreas, const FixedList< label, 4 > &tetPlaneBasePtIs, const scalar tol) const
Find the tet tri faces between position and tet centre.
label cellI_
Index of the cell it is in.
const Point & a() const
Return vertices.
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
virtual const faceList & faces() const
Return raw faces.
void initCellFacePt()
Check the stored cell value (setting if necessary) and.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
dimensionedScalar sqrt(const dimensionedScalar &ds)
label origProc() const
Return const access to the originating processor id.
A 1D vector of objects of type <T> with a fixed size <Size>.
Point centre() const
Return centre (centroid)
void clear()
Clear the list, i.e. set size to zero.
const vector & position() const
Return current particle position.
vector oldNormal() const
Return the normal of the tri on tetFaceI_ for the.
const dimensionedScalar c
Speed of light in a vacuum.
label tetFaceI_
Index of the face that owns the decomposed tet that the.
vector normal() const
Return the normal of the tri on tetFaceI_ for the.
scalar currentTime() const
Return the particle current time.
A face is a list of labels corresponding to mesh vertices.
label patchFace(const label patchI, const label faceI) const
Which face of this patch is this particle on.
label patch(const label faceI) const
Which patch is particle on.
dimensionedScalar neg(const dimensionedScalar &ds)
#define WarningInFunction
Report a warning using Foam::Warning.
A cell is defined as a list of faces with extra functionality.
dimensionedScalar lambda(laminarTransport.lookup("lambda"))
const polyMesh & mesh_
Reference to the polyMesh database.
tetPointRef currentTet() const
Return the geometry of the current tet that the.