48 <<
"cannot both be on a mesh edge and a face-diagonal edge."
63 if (faceBasePti == -1)
77 return edge(
f[faceBasePti],
f[diagPti]);
97 for (
const label facei : thisCell)
102 if (tetFacei == facei)
109 const auto edDir =
otherFace.edgeDirection(
e);
147 if (tetBasePtI == -1)
160 eIndex -= tetBasePtI;
193 crossEdgeConnectedFace(
cell(), tetFace(), tetPt(), meshEdge);
199 const Foam::face&
f =
mesh().
faces()[tetFace()];
200 label fp =
f.
find(meshEdge[0]);
202 if (
f.nextLabel(fp) == meshEdge[1])
210 if (
f[fpMin1] == meshEdge[1])
212 meshEdgeStart_ = fpMin1;
220 <<
"face:" << tetFace()
222 <<
" meshEdge:" << meshEdge
230 const edge eNew(
f[meshEdgeStart_],
f.nextLabel(meshEdgeStart_));
231 if (eNew != meshEdge)
248 if (meshEdgeStart_ != -1)
256 const Foam::face&
f =
mesh().
faces()[tetFace()];
260 if (tetPt() == diagEdge_)
266 label nextTetPt =
f.
fcIndex(tetPt());
267 if (diagEdge_ == nextTetPt)
276 <<
"tetPt:" << tetPt()
288 const vector& endPosition,
293 const triFace tri(currentTetIndices().faceTriIs(
mesh(),
false));
300 edge currentE(-1, -1);
301 if (meshEdgeStart_ != -1 || diagEdge_ != -1)
303 currentE = currentEdge();
309 label j = tri.fcIndex(i);
314 if (
edge(tri[i], tri[j]) == currentE)
321 vector edgeNormal = (pt1 - pt0)^
n;
322 edgeNormal.normalise();
325 scalar sEnd = (endPosition - pt0)&edgeNormal;
330 scalar sStart = (localPosition_ - pt0)&edgeNormal;
331 if (
mag(sEnd - sStart) > VSMALL)
333 scalar
s = sStart/(sStart - sEnd);
335 if (
s >= 0 &&
s < minS)
346 localPosition_ += minS*(endPosition - localPosition_);
352 localPosition_ = endPosition;
367 const point& endPosition
370 const triFace triVerts(currentTetIndices().faceTriIs(
mesh(),
false));
371 const edge currentE = currentEdge();
375 currentE[0] == currentE[1]
376 || !triVerts.
found(currentE[0])
377 || !triVerts.
found(currentE[1])
381 <<
"Edge " << currentE <<
" not on triangle " << triVerts
387 const vector dir = endPosition - localPosition_;
395 if (edge(triVerts[i], triVerts[j]) == currentE)
397 vector edgeNormal = (pt1-pt0)^
n;
398 return (dir&edgeNormal) < 0;
414 const point& position,
416 const label tetFacei,
418 const label meshEdgeStart,
464 localPosition_(
p.localPosition_),
465 meshEdgeStart_(
p.meshEdgeStart_),
466 diagEdge_(
p.diagEdge_)
475 const wallBoundedParticle&
p
490 reinterpret_cast<const char*
>(&
p.localPosition_),
499Foam::Ostream& Foam::operator<<
505 const auto&
p = *iproxy;
const Mesh & mesh() const noexcept
Return const reference to mesh.
bool found(const T &val, label pos=0) const
Same as contains().
label fcIndex(const label i) const noexcept
Return the forward circular index, i.e. next index which returns to the first at the end of the list.
streamFormat format() const noexcept
Get the current stream format.
@ ASCII
"ascii" (normal default)
virtual bool check(const char *operation) const
Check IOstream status for given operation.
bool fatalCheckNativeSizes(const char *operation) const
Assert that the label/scalar byte-size associated with the stream are the native label/scalar sizes.
A helper class for outputting values to Ostream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
virtual Istream & read(token &)=0
Return next token from stream.
virtual Ostream & write(const char c) override
Write character.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
iterator end() noexcept
Return an iterator to end traversing the UList.
label rcIndex(const label i) const noexcept
The reverse circular index. The previous index in the list which returns to the last at the beginning...
label find(const T &val) const
Find index of the first occurrence of the value.
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
Vector< Cmpt > & normalise(const scalar tol=ROOTVSMALL)
Inplace normalise the vector by its magnitude.
A cell is defined as a list of faces with extra functionality.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
A face is a list of labels corresponding to mesh vertices.
tetIndices currentTetIndices() const noexcept
Return indices of the current tet that the particle occupies.
vector position() const
Return current particle position.
label face() const noexcept
Return current face particle is on otherwise -1.
label tetPt() const noexcept
Return current tet face particle is in.
const polyMesh & mesh() const noexcept
Return the mesh database.
label tetFace() const noexcept
Return current tet face particle is in.
label cell() const noexcept
Return current cell particle is in.
particle(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPti)
Construct from components.
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
virtual const pointField & points() const
Return raw points.
const cellList & cells() const
const Point & b() const noexcept
Return vertex b.
const Point & c() const noexcept
Return vertex c.
const Point & a() const noexcept
Return vertex a.
const Point & d() const noexcept
Return vertex d.
A triangular face using a FixedList of labels corresponding to mesh vertices.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Particle class that tracks on triangles of boundary faces. Use trackToEdge similar to trackToFace on ...
label meshEdgeStart_
Particle is on mesh edge:
bool isTriAlongTrack(const vector &n, const point &endPosition) const
Is current triangle in the track direction.
wallBoundedParticle(const polyMesh &c, const point &position, const label celli, const label tetFacei, const label tetPti, const label meshEdgeStart, const label diagEdge)
Construct from components.
InfoProxy< wallBoundedParticle > info() const noexcept
Return info proxy, used to print particle information to a stream.
label meshEdgeStart() const noexcept
The mesh edge label or -1.
edge currentEdge() const
Construct current edge.
static const std::size_t sizeofFields_
Size in bytes of the fields.
label diagEdge_
Particle is on diagonal edge:
scalar trackFaceTri(const vector &n, const vector &endPosition, label &)
Track through single triangle.
void crossEdgeConnectedFace(const label &celli, label &tetFacei, label &tetPti, const edge &e)
Replacement for particle::crossEdgeConnectedFace that avoids bombing.
label diagEdge() const noexcept
The diagonal edge label or -1.
point localPosition_
Particle position is updated locally as opposed to via track.
void crossDiagonalEdge()
Cross diagonal edge into different triangle on same face,cell.
static void readFields(CloudType &)
Read.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const NameMatchPredicate &selectedFields, DynamicList< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type and store on the objectRegistry.
List< face > faceList
List of faces.
tetrahedron< point, const point & > tetPointRef
A tetrahedron using referred points.
List< cell > cellList
List of cell.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
vector point
Point is a vector.
dimensionedScalar neg(const dimensionedScalar &ds)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
constexpr char nl
The newline '\n' character (0x0a).
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::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].reset(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];} pointMap[start]=pointMap[end]=Foam::min(start, end);} } 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};constexpr 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< DynamicList< face > > pFaces[nBCs]
#define forAll(list, i)
Loop across all elements in list.