47void Foam::faceShading::calculate()
51 const bitSet isOpaqueFace
77 Info<<
"Number of 'potential' direct hits : "
88 bitSet blockingFacesFlips;
124 dict.add(
"mergeDistance", SMALL);
146 const scalar maxBounding =
147 returnReduce(5.0*mesh_.bounds().mag(), maxOp<scalar>());
155 DynamicField<point> start(hitFacesIds.size());
156 DynamicField<point>
end(start.size());
157 DynamicList<label> startIndex(start.size());
159 const pointField& faceCentres = mesh_.faceCentres();
161 const vector d(direction_*maxBounding);
165 const label facei = hitFacesIds[i];
166 const point& fc = faceCentres[facei];
168 start.append(fc - 0.001*d);
169 startIndex.append(facei);
173 List<pointIndexHit> hitInfo(startIndex.size());
183 if (!hitInfo[rayI].hit())
188 rayStartFaces_.setSize(nVisible);
193 if (!hitInfo[rayI].hit())
195 rayStartFaces_[nVisible++] = startIndex[rayI];
204 mesh_.time().path()/
"allVisibleFaces.obj",
224 auto& hitFaces = thitFaces.ref();
229 for (
const label facei : rayStartFaces_)
234 hitFaces[facei] = 1.0;
239 hitFacesBf[
patchID][facei -
pp.start()] = 1.0;
245 Info<<
"Total number of hit faces : "
250Foam::triSurface Foam::faceShading::triangulate
256 if (faceIDs.size() != flipMap.size())
259 <<
"faceIDs:" << faceIDs.size()
260 <<
"flipMap:" << flipMap.size()
264 const auto&
points = mesh_.points();
265 const auto& faces = mesh_.faces();
266 const auto&
bMesh = mesh_.boundaryMesh();
267 const auto& fzs = mesh_.faceZones();
277 for (label patchi = 0; patchi <
bMesh.nNonProcessor(); ++patchi)
279 const auto&
pp =
bMesh[patchi];
296 for (
const auto& fz : fzs)
319 const label facei = faceIDs[i];
320 const bool flip = flipMap[i];
321 const label patchi =
patchID[facei];
322 const face&
f = faces[facei];
327 f.triangles(
points, nTri, triFaces);
329 for (
const face&
f : triFaces)
350 rawSurface.localFaces(),
351 rawSurface.localPoints()
361Foam::bitSet Foam::faceShading::selectOpaqueFaces
368 const auto&
pbm = mesh_.boundaryMesh();
370 bitSet isOpaqueFace(mesh_.nFaces(),
false);
375 const auto&
pp =
pbm[patchi];
381 isOpaqueFace[i +
pp.start()] = (t[i] == 0.0);
386 const auto& fzs = mesh_.faceZones();
388 for (
const label zonei :
zoneIDs)
390 const auto& fz = fzs[zonei];
402 isOpaqueFace[fz[i]] = (t[i] == 0.0);
410void Foam::faceShading::selectFaces
412 const bool useNormal,
413 const bitSet& isCandidateFace,
421 const auto&
pbm = mesh_.boundaryMesh();
423 bitSet isSelected(mesh_.nFaces());
425 bitSet isFaceFlipped(mesh_.nFaces());
430 const auto&
pp =
pbm[patchi];
435 const label meshFacei = i +
pp.start();
438 isCandidateFace[meshFacei]
441 || ((direction_ &
n[i]) > 0)
445 isSelected.set(meshFacei);
446 isFaceFlipped[meshFacei] =
false;
447 dynFaces.append(meshFacei);
454 const auto& fzs = mesh_.faceZones();
456 for (
const label zonei :
zoneIDs)
458 const auto& fz = fzs[zonei];
464 const label meshFacei = fz[i];
468 !isSelected[meshFacei]
469 && isCandidateFace[meshFacei]
472 || ((direction_ &
n[i]) > 0)
476 isSelected.set(meshFacei);
477 dynFaces.append(meshFacei);
478 isFaceFlipped[meshFacei] = fz.flipMap()[i];
482 faceIDs = std::move(dynFaces);
483 flipMap =
bitSet(isFaceFlipped, faceIDs);
487void Foam::faceShading::writeRays
507Foam::faceShading::faceShading
514 patchIDs_(nonCoupledPatches(
mesh)),
523Foam::faceShading::faceShading
545 const auto&
pbm =
mesh.boundaryMesh();
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
Dynamically sized Field. Similar to DynamicList, but inheriting from a Field instead of a List.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
static tmp< GeometricField< scalar, fvsPatchField, surfaceMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvsPatchField< scalar >::calculatedType())
GeometricBoundaryField< scalar, fvsPatchField, surfaceMesh > Boundary
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
label size() const noexcept
The number of elements in the list.
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().
static FOAM_NO_DANGLING_REFERENCE const boundaryRadiationProperties & New(const fvMesh &mesh, Args &&... args)
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
Read/write access to the name of the stream.
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
A non-owning sub-view of a List (allocated or unallocated storage).
const word & constant() const noexcept
Return constant name.
A List with indirect addressing. Like IndirectList but does not store addressing.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
static const Enum< distributionType > distributionTypeNames_
Helper class to calculate visible faces for global, sun-like illumination.
void correct()
Recalculate rayStartFaces using direction vector.
static labelList nonCoupledPatches(const polyMesh &mesh)
Helper: return all uncoupled patches.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
Mesh data needed to do the Finite Volume discretisation.
const Time & time() const
Return the top-level database.
Identifies a surface patch/zone by name and index, with geometric type.
A triFace with additional (region) index.
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
Boundary radiation properties holder.
A class for managing temporary objects.
Triangulated surface description with patch information.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
const labelIOList & zoneIDs
const wordList surface
Standard surface field types (scalar, vector, tensor, etc).
const dimensionSet dimless
Dimensionless.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< face > faceList
List of faces.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
PrimitivePatch< List< face >, const pointField & > primitiveFacePatch
A PrimitivePatch with List storage for the faces, const reference for the point field.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
List< geometricSurfacePatch > geometricSurfacePatchList
List of geometricSurfacePatch.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
PrimitivePatch< List< face >, const pointField > bMesh
Holder of faceList and points. (v.s. e.g. primitivePatch which references points).
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
const triSurface localSurface
List< treeBoundBox > meshBb(1, treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3))
distributedTriSurfaceMesh surfacesMesh(IOobject("wallSurface.stl", runTime.constant(), "triSurface", runTime, IOobject::NO_READ, IOobject::NO_WRITE), localSurface, dict)
std::vector< Triangle > triangles
#define forAll(list, i)
Loop across all elements in list.