62 return voxel.
x()+voxel.
y()*nDivs.
x()+voxel.
z()*nDivs.
x()*nDivs.
y();
72 const label nxy = nDivs.
x()*nDivs.
y();
75 voxel.
z() = voxeli/nxy;
76 voxeli = voxeli % nxy;
77 voxel.
y() = voxeli/nDivs.
x();
78 voxel.
x() = voxeli%nDivs.
x();
95 floor((pt.x()-bb.
min().x())/
s.x()),
96 floor((pt.y()-bb.
min().y())/
s.y()),
97 floor((pt.z()-bb.
min().z())/
s.z())
116 floor((pt.x()-bb.
min().x())/
s.x()),
117 floor((pt.y()-bb.
min().y())/
s.y()),
118 floor((pt.z()-bb.
min().z())/
s.z())
123 v[0] =
max(0,
min(
g[0]-1, v[0]));
124 v[1] =
max(0,
min(
g[1]-1, v[1]));
125 v[2] =
max(0,
min(
g[2]-1, v[2]));
153 return bb.min()+0.5*
s+
point(voxel[0]*
s[0], voxel[1]*
s[1], voxel[2]*
s[2]);
166 for (label i = 1; i <
g[0]; i++)
168 for (label j = 0; j <
g[1]; j++)
170 for (label
k = 0;
k <
g[2];
k++)
178 for (label i = 0; i <
g[0]; i++)
180 for (label j = 1; j <
g[1]; j++)
182 for (label
k = 0;
k <
g[2];
k++)
190 for (label i = 0; i <
g[0]; i++)
192 for (label j = 0; j <
g[1]; j++)
194 for (label
k = 1;
k <
g[2];
k++)
205 Foam::label Foam::voxelMeshSearch::searchProcPatch
208 const point& searchPoint
211 const pointField& cellCentres = mesh_.cellCentres();
212 const polyBoundaryMesh& bMeshes = mesh_.boundaryMesh();
214 const label patchi = bMeshes.
patchID(faceID);
215 const polyPatch& bMeshPatch = bMeshes[patchi];
217 if (!isA<processorPolyPatch>(bMeshPatch))
225 const labelUList& faceCells = bMeshPatch.faceCells();
226 scalar minProximity = GREAT;
228 label nearestCellI = -1;
231 const point& cc = cellCentres[faceCells[i]];
232 scalar proximity =
magSqr(cc-searchPoint);
233 if (proximity < minProximity)
235 minProximity = proximity;
236 nearestCellI = faceCells[i];
244 Foam::label Foam::voxelMeshSearch::findIntersectedFace
253 const faceList& faces = mesh_.faces();
254 const pointField& faceCentres = mesh_.faceCentres();
257 const point& cc = mesh_.cellCentres()[cellI];
258 const labelList& cFaces = mesh_.cells()[cellI];
264 label facei = cFaces[cFacei];
266 pointHit hitInfo = faces[facei].intersection
275 if (hitInfo.hit() && (hitInfo.distance() < 1))
324 localBb_ = boundBox(mesh_.
points(),
false);
326 const point eps(1
e-10, 1
e-10, 1
e-10);
328 localBb_.
min() = localBb_.
min()-eps;
329 localBb_.
max() = localBb_.
max()+eps;
333 Pout<<
"voxelMeshSearch : mesh:" << mesh_.
name()
334 <<
" nDivs:" << nDivs_ <<
endl;
346 const polyMesh&
mesh,
347 const boundBox& localBb,
379 const labelList& cPoints = cellPoints[celli];
382 boundBox bb(
points, cPoints,
false);
384 fill(seedCell_, localBb_, nDivs_, bb, celli);
390 Pout<<
"voxelMeshSearch : mesh:" << mesh_.
name()
391 <<
" nDivs:" << nDivs_
392 <<
" localBb:" << localBb_ <<
endl;
412 if (!localBb_.contains(
p))
419 label voxeli = index(localBb_, nDivs_,
p,
false);
429 label celli = seedCell_[voxeli];
445 if (track_.size() < 5)
447 track_.append(celli);
451 label facei = findIntersectedFace(celli,
p);
458 const label startOfTrack(
max(0, track_.size()-5));
461 if (mesh_.isInternalFace(facei))
463 label own = mesh_.faceOwner()[facei];
464 label nei = mesh_.faceNeighbour()[facei];
465 nextCell = (own == celli ? nei : own);
467 if (track_.found(nextCell, startOfTrack))
474 nextCell = searchProcPatch(facei,
p);
476 if (nextCell == -1 || nextCell == celli)
480 else if (track_.found(nextCell, startOfTrack))
522 faceList faces(
b.boundaryPatches()[patchi].size());
525 faces[facei] = face(
b.boundaryPatches()[patchi][facei]);
545 patchDict.add(
"type", emptyPolyPatch::typeName);
567 emptyPolyPatch::typeName,
static labelVector offset(const labelVector &nDivs)
Change in combined voxel index for change in components.
static word defaultName(const label n=-1)
Default patch name: "patch" or "patchN".
List< faceList > faceListList
List of faceList.
void size(const label n)
Older name for setAddressableSize.
Cmpt cmptProduct(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
const word & name() const noexcept
Return the object name.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
PtrList< blockFace > blockFaceList
A PtrList of blockFaces.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const labelList & patchID() const
Per boundary face label the patch index.
static void writeGrid(OBJstream &, const boundBox &, const labelVector &)
Debug: write all edges.
List< cellShape > cellShapeList
List of cellShape.
void clip(Field< Type > &result, const UList< Type > &f1, const MinMax< Type > &s2)
A bounding box defined in terms of min/max extrema points.
const Cmpt & y() const noexcept
Access to the vector y component.
label k
Boltzmann constant.
const point & min() const noexcept
Minimum describing the bounding box.
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
List< labelList > labelListList
List of labelList.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
UList< label > labelUList
A UList of labels.
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
bool update()
Update lookup tables for geometry changes.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
const labelVector & nDivs() const
Number of voxels for local mesh.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
List< face > faceList
List of faces.
const point & max() const noexcept
Maximum describing the bounding box.
static label index(const labelVector &nDivs, const labelVector &voxel)
Find cells. Returns number of cells found.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
voxelMeshSearch(const polyMesh &, const bool doUpdate=true)
Construct from mesh; voxels estimated from local number of cells.
dimensionedScalar cbrt(const dimensionedScalar &ds)
wordList patchNames(nPatches)
const objectRegistry & db() const noexcept
Return the local objectRegistry.
static labelVector index3(const labelVector &nDivs, const label voxeli)
Combined voxel index to individual indices.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
const uniformDimensionedVectorField & g
Ostream & writeLine(const point &p0, const point &p1)
Write line joining two points.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files...
const Cmpt & x() const noexcept
Access to the vector x component.
static point centre(const boundBox &bb, const labelVector &nDivs, const labelVector &voxel)
Voxel index to voxel centre.
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
Info<< "Creating cells"<< endl;cellShapes=b.shapes();Info<< "Creating boundary faces"<< endl;boundary.setSize(b.boundaryPatches().size());forAll(boundary, patchi) { faceList faces(b.boundaryPatches()[patchi].size());forAll(faces, facei) { faces[facei]=face(b.boundaryPatches()[patchi][facei]);} boundary[patchi].transfer(faces);} points.transfer(const_cast< pointField & >b.points()));}Info<< "Creating patch dictionaries"<< endl;wordList patchNames(boundary.size());forAll(patchNames, patchi){ patchNames[patchi]=polyPatch::defaultName(patchi);}PtrList< dictionary > boundaryDicts(boundary.size())
List< word > wordList
List of word.
const Cmpt & z() const noexcept
Access to the vector z component.
vector point
Point is a vector.
label nCells() const noexcept
Number of mesh cells.
PtrList< blockEdge > blockEdgeList
A PtrList of blockEdges.
static const UList< T > & null() noexcept
Return a null UList (reference to a nullObject). Behaves like an empty UList.
vector span() const
The bounding box span (from minimum to maximum)
Fast, non-parallel searching in mesh without use of octree.
Vector< label > labelVector
Vector of labels.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
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))
autoPtr< fvMesh > makeMesh(const IOobject &) const
Debug: construct fvMesh. Note: writes a dummy mesh to.
label findCell(const point &) const
Find a cell.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
PointHit< point > pointHit
A PointHit with a 3D point.