47 void 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 =
155 DynamicField<point> start(hitFacesIds.size());
156 DynamicField<point>
end(start.size());
157 DynamicList<label> startIndex(start.size());
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 : " 253 const bitSet& flipMap
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];
281 surfPatches[newPatchi] = geometricSurfacePatch
296 for (
const auto& fz : fzs)
298 surfPatches[newPatchi] = geometricSurfacePatch
304 UIndirectList<label>(
patchID, fz) = newPatchi;
312 DynamicList<labelledTri>
triangles(2*faceIDs.size());
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)
333 triangles.append(labelledTri(
f[0],
f[1],
f[2], patchi));
337 triangles.append(labelledTri(
f[0],
f[2],
f[1], patchi));
345 triSurface rawSurface(
triangles, mesh_.points());
350 rawSurface.localFaces(),
351 rawSurface.localPoints()
363 const radiation::boundaryRadiationProperties& boundaryRadiation,
368 const auto&
pbm = mesh_.boundaryMesh();
370 bitSet isOpaqueFace(mesh_.nFaces(),
false);
375 const auto&
pp =
pbm[patchi];
376 tmp<scalarField> tt = boundaryRadiation.transmissivity(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];
393 tmp<scalarField> tt = boundaryRadiation.zoneTransmissivity
402 isOpaqueFace[fz[i]] = (t[i] == 0.0);
410 void Foam::faceShading::selectFaces
412 const bool useNormal,
413 const bitSet& isCandidateFace,
421 const auto&
pbm = mesh_.boundaryMesh();
423 bitSet isSelected(mesh_.nFaces());
424 DynamicList<label> dynFaces(mesh_.nBoundaryFaces());
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);
487 void Foam::faceShading::writeRays
489 const fileName& fName,
490 const DynamicField<point>& endCf,
507 Foam::faceShading::faceShading
514 patchIDs_(nonCoupledPatches(
mesh)),
523 Foam::faceShading::faceShading
551 if (!
pp.coupled() && !isA<cyclicAMIPolyPatch>(
pp))
static const Enum< distributionType > distributionTypeNames_
const labelList patchIDs(pbm.indices(polyPatchNames, true))
const polyBoundaryMesh & pbm
const triSurface localSurface
const labelIOList & zoneIDs
fileName path() const
Return path = rootPath/caseName. Same as TimePaths::path()
void correct()
Recalculate rayStartFaces using direction vector.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const fileName & name() const override
Read/write access to the name of the stream.
static const boundaryRadiationProperties & New(const fvMesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
Ostream & endl(Ostream &os)
Add newline and flush stream.
distributedTriSurfaceMesh surfacesMesh(IOobject("wallSurface.stl", runTime.constant(), "triSurface", runTime, IOobject::NO_READ, IOobject::NO_WRITE), localSurface, dict)
std::vector< Triangle > triangles
GeometricBoundaryField< scalar, fvsPatchField, surfaceMesh > Boundary
Type of boundary fields.
Ignore writing from objectRegistry::writeObject()
const dimensionSet dimless
Dimensionless.
const Time & time() const
Return the top-level database.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
UList< label > labelUList
A UList of labels.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
List< face > faceList
List of faces.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
scalar mag() const
The magnitude/length of the bounding box diagonal.
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())
Return tmp field (NO_READ, NO_WRITE) from name, mesh, dimensions and patch type. [Takes current timeN...
static labelList nonCoupledPatches(const polyMesh &mesh)
Helper: return all uncoupled patches.
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
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...
const word & constant() const noexcept
Return constant name.
int debug
Static debugging option.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
OBJstream os(runTime.globalPath()/outputName)
List< geometricSurfacePatch > geometricSurfacePatchList
List of geometricSurfacePatch.
defineTypeNameAndDebug(combustionModel, 0)
PrimitivePatch< List< face >, const pointField & > primitiveFacePatch
A PrimitivePatch with List storage for the faces, const reference for the point field.
const vectorField & faceCentres() const
vector point
Point is a vector.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Mesh data needed to do the Finite Volume discretisation.
messageStream Info
Information stream (stdout output on master, null elsewhere)
const boundBox & bounds() const noexcept
Return mesh bounding box.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
A patch is a list of labels that address the faces in the global face list.
Triangulated surface description with patch information.
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.
Do not request registration (bool: false)
List< treeBoundBox > meshBb(1, treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static constexpr const zero Zero
Global zero (0)