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",
236 for (
const label facei : rayStartFaces_)
241 hitFaces[facei] = 1.0;
246 hitFacesBf[
patchID][facei -
pp.start()] = 1.0;
252 Info<<
"Total number of hit faces : " 260 const bitSet& flipMap
263 if (faceIDs.size() != flipMap.size())
266 <<
"faceIDs:" << faceIDs.size()
267 <<
"flipMap:" << flipMap.size()
271 const auto&
points = mesh_.points();
272 const auto& faces = mesh_.faces();
273 const auto&
bMesh = mesh_.boundaryMesh();
274 const auto& fzs = mesh_.faceZones();
284 for (label patchi = 0; patchi <
bMesh.nNonProcessor(); ++patchi)
286 const auto&
pp =
bMesh[patchi];
288 surfPatches[newPatchi] = geometricSurfacePatch
303 for (
const auto& fz : fzs)
305 surfPatches[newPatchi] = geometricSurfacePatch
311 UIndirectList<label>(
patchID, fz) = newPatchi;
319 DynamicList<labelledTri>
triangles(2*faceIDs.size());
326 const label facei = faceIDs[i];
327 const bool flip = flipMap[i];
328 const label patchi =
patchID[facei];
329 const face&
f = faces[facei];
334 f.triangles(
points, nTri, triFaces);
336 for (
const face&
f : triFaces)
340 triangles.append(labelledTri(
f[0],
f[1],
f[2], patchi));
344 triangles.append(labelledTri(
f[0],
f[2],
f[1], patchi));
352 triSurface rawSurface(
triangles, mesh_.points());
357 rawSurface.localFaces(),
358 rawSurface.localPoints()
370 const radiation::boundaryRadiationProperties& boundaryRadiation,
375 const auto&
pbm = mesh_.boundaryMesh();
377 bitSet isOpaqueFace(mesh_.nFaces(),
false);
382 const auto&
pp =
pbm[patchi];
383 tmp<scalarField> tt = boundaryRadiation.transmissivity(patchi);
388 isOpaqueFace[i +
pp.start()] = (t[i] == 0.0);
393 const auto& fzs = mesh_.faceZones();
395 for (
const label zonei :
zoneIDs)
397 const auto& fz = fzs[zonei];
400 tmp<scalarField> tt = boundaryRadiation.zoneTransmissivity
409 isOpaqueFace[fz[i]] = (t[i] == 0.0);
417 void Foam::faceShading::selectFaces
419 const bool useNormal,
420 const bitSet& isCandidateFace,
428 const auto&
pbm = mesh_.boundaryMesh();
430 bitSet isSelected(mesh_.nFaces());
431 DynamicList<label> dynFaces(mesh_.nBoundaryFaces());
432 bitSet isFaceFlipped(mesh_.nFaces());
437 const auto&
pp =
pbm[patchi];
442 const label meshFacei = i +
pp.start();
445 isCandidateFace[meshFacei]
448 || ((direction_ &
n[i]) > 0)
452 isSelected.set(meshFacei);
453 isFaceFlipped[meshFacei] =
false;
454 dynFaces.append(meshFacei);
461 const auto& fzs = mesh_.faceZones();
463 for (
const label zonei :
zoneIDs)
465 const auto& fz = fzs[zonei];
471 const label meshFacei = fz[i];
475 !isSelected[meshFacei]
476 && isCandidateFace[meshFacei]
479 || ((direction_ &
n[i]) > 0)
483 isSelected.set(meshFacei);
484 dynFaces.append(meshFacei);
485 isFaceFlipped[meshFacei] = fz.flipMap()[i];
489 faceIDs = std::move(dynFaces);
490 flipMap = bitSet(isFaceFlipped, faceIDs);
494 void Foam::faceShading::writeRays
496 const fileName& fName,
497 const DynamicField<point>& endCf,
514 Foam::faceShading::faceShading
521 patchIDs_(nonCoupledPatches(
mesh)),
530 Foam::faceShading::faceShading
558 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 a new 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.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
void append(const T &val)
Copy append an element to the end of this list.
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...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
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)
Internal & ref(const bool updateAccessTime=true)
Same as internalFieldRef()
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.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
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)