72 const label nxy = nDivs.
x()*nDivs.
y();
75 voxel.
z() = voxeli/nxy;
76 voxeli = voxeli % nxy;
78 voxel.
x() = voxeli%
nDivs.x();
95 floor((pt.
x()-bb.
min().
x())/
s.x()),
96 floor((pt.
y()-bb.
min().
y())/
s.y()),
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++)
174 os.writeLine(p1, p2);
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++)
205Foam::label Foam::voxelMeshSearch::searchProcPatch
208 const point& searchPoint
211 const pointField& cellCentres = mesh_.cellCentres();
214 const label patchi = bMeshes.
patchID(faceID);
215 const polyPatch& bMeshPatch = bMeshes[patchi];
226 scalar minProximity = GREAT;
228 label nearestCellI = -1;
232 scalar proximity =
magSqr(cc-searchPoint);
233 if (proximity < minProximity)
235 minProximity = proximity;
244Foam::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))
288 const polyMesh&
mesh,
305 else if (mesh_.nGeometricD() == 2)
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))
525 faces[facei] =
face(
b.boundaryPatches()[patchi][facei]);
545 patchDict.
add(
"type", emptyPolyPatch::typeName);
567 emptyPolyPatch::typeName,
const uniformDimensionedVectorField & g
readOption readOpt() const noexcept
Get the read option.
@ NO_READ
Nothing to be read.
@ MUST_READ
Reading required.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
void setSize(label n)
Alias for resize().
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files.
Ostream & writeLine(const point &p0, const point &p1)
Write line joining two points.
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name).
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
static const UList< T > & null() noexcept
Return a null UList (reference to a nullObject). Behaves like an empty UList.
void size(const label n)
Older name for setAddressableSize.
const Cmpt & x() const noexcept
Access to the vector x component.
const Cmpt & z() const noexcept
Access to the vector z component.
const Cmpt & y() const noexcept
Access to the vector y component.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
A bounding box defined in terms of min/max extrema points.
const point & min() const noexcept
Minimum describing the bounding box.
vector span() const
The bounding box span (from minimum to maximum).
An analytical geometric cellShape.
pointField points(const UList< point > &meshPoints) const
The points corresponding to this shape.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Smooth ATC in cells next to a set of patches supplied by type.
A face is a list of labels corresponding to mesh vertices.
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
static word defaultName(const label n=-1)
Default patch name: "patch" or "patchN".
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
const labelList & patchID() const
Per boundary face label the patch index.
Mesh consisting of general polyhedral cells.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
A patch is a list of labels that address the faces in the global face list.
const labelUList & faceCells() const
Return face-cell addressing.
label nCells() const noexcept
Number of mesh cells.
Fast, non-parallel searching in mesh without use of octree.
static labelVector index3(const labelVector &nDivs, const label voxeli)
Combined voxel index to individual indices.
static label index(const labelVector &nDivs, const labelVector &voxel)
Find cells. Returns number of cells found.
static void fill(Container &elems, const boundBox &bb, const labelVector &nDivs, const boundBox &subBb, const Type val)
Fill voxels indicated by bounding box.
label findCell(const point &) const
Find a cell.
static labelVector offset(const labelVector &nDivs)
Change in combined voxel index for change in components.
bool update()
Update lookup tables for geometry changes.
voxelMeshSearch(const polyMesh &, const bool doUpdate=true)
Construct from mesh; voxels estimated from local number of cells.
const labelVector & nDivs() const
Number of voxels for local mesh.
static void writeGrid(OBJstream &, const boundBox &, const labelVector &)
Debug: write all edges.
autoPtr< fvMesh > makeMesh(const IOobject &) const
Debug: construct fvMesh. Note: writes a dummy mesh to.
static point centre(const boundBox &bb, const labelVector &nDivs, const labelVector &voxel)
Voxel index to voxel centre.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
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())
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))
Namespace for handling debugging switches.
List< word > wordList
List of word.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< labelList > labelListList
List of labelList.
T clip(const T &val, const MinMax< T > &range)
Return the value after clamping by the min/max limiter.
PointHit< point > pointHit
A PointHit with a 3D point.
List< label > labelList
A List of labels.
Vector< label > labelVector
Vector of labels.
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
List< face > faceList
List of faces.
Cmpt cmptProduct(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
List< faceList > faceListList
List of faceList.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
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...
vector point
Point is a vector.
PtrList< blockFace > blockFaceList
A PtrList of blockFaces.
dimensionedScalar cbrt(const dimensionedScalar &ds)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
PtrList< blockEdge > blockEdgeList
A PtrList of blockEdges.
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
List< cellShape > cellShapeList
List of cellShape.
wordList patchNames(nPatches)
#define forAll(list, i)
Loop across all elements in list.