46void Foam::faceShading::writeRays
48 const fileName& fName,
49 const DynamicField<point>& endCf,
50 const pointField& myFc
67 const List<labelHashSet>& includeAllFacesPerPatch
70 const polyBoundaryMesh&
bMesh = mesh_.boundaryMesh();
73 DynamicList<labelledTri> triangles(mesh_.nBoundaryFaces());
77 for (
const label patchI : includePatches)
84 if (includeAllFacesPerPatch[patchI].size())
86 for (
const label patchFaceI : includeAllFacesPerPatch[patchI])
88 const face&
f =
patch[patchFaceI];
94 f.triangles(
points, nTri, triFaces);
96 for (
const face&
f : triFaces)
100 labelledTri(
f[0],
f[1],
f[2], newPatchI)
112 triSurface rawSurface(triangles, mesh_.points());
117 rawSurface.localFaces(),
118 rawSurface.localPoints()
126 for (
const label patchI : includePatches)
130 if (includeAllFacesPerPatch[patchI].size())
133 surface.patches()[newPatchI].geometricType() =
patch.type();
143void Foam::faceShading::calculate()
145 const radiation::boundaryRadiationProperties& boundaryRadiation =
150 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
152 DynamicList<point> dynCf(
nFaces);
153 DynamicList<label> dynFacesI;
157 const polyPatch& pp =
patches[patchI];
160 if (!pp.coupled() && !isA<cyclicAMIPolyPatch>(pp))
162 const tmp<scalarField> tt =
163 boundaryRadiation.transmissivity(patchI);
170 if (((direction_ & nf) > 0) && (t[faceI] == 0.0))
172 dynFacesI.append(faceI + pp.start());
173 dynCf.append(cf[faceI]);
180 label numberPotentialHits =
nFaces;
182 reduce(numberPotentialHits, sumOp<label>());
184 Info<<
"Number of 'potential' direct hits : "
185 << numberPotentialHits <<
endl;
188 hitFacesIds.transfer(dynFacesI);
203 boundBox(mesh_.points(),
false)
218 dict.
add(
"mergeDistance", SMALL);
221 List<labelHashSet> includeAllFacesPerPatch(
patches.
size());
225 const polyPatch& pp =
patches[patchI];
226 if (!pp.coupled() && !isA<cyclicAMIPolyPatch>(pp))
228 includePatches.insert(patchI);
230 const tmp<scalarField> tt =
231 boundaryRadiation.transmissivity(patchI);
236 if (tau[faceI] == 0.0)
238 includeAllFacesPerPatch[patchI].insert(faceI);
247 includeAllFacesPerPatch
255 mesh_.time().constant(),
270 scalar maxBounding = 5.0*
mag(mesh_.bounds().max() - mesh_.bounds().min());
272 reduce(maxBounding, maxOp<scalar>());
281 DynamicField<point> start(
nFaces);
282 DynamicField<point>
end(start.size());
283 DynamicList<label> startIndex(start.size());
288 for (; i < Cfs.size(); i++)
290 const point& fc = Cfs[i];
292 const label myFaceId = hitFacesIds[i];
294 const vector d(direction_*maxBounding);
296 start.append(fc - 0.001*d);
298 startIndex.append(myFaceId);
306 List<pointIndexHit> hitInfo(startIndex.size());
314 if (!hitInfo[rayI].hit())
316 rayStartFace.append(startIndex[rayI]);
325 mesh_.time().path()/
"allVisibleFaces.obj",
336 rayStartFaces_.transfer(rayStartFace);
340 tmp<volScalarField> thitFaces
347 mesh_.time().timeName(),
361 for (
const label faceI : rayStartFaces_)
365 hitFacesBf[
patchID][faceI - pp.start()] = 1.0;
370 label totalHitFaces = rayStartFaces_.size();
372 reduce(totalHitFaces, sumOp<label>());
374 Info<<
"Total number of hit faces : " << totalHitFaces <<
endl;
389 rayStartFaces_(hitFaceList)
SubField< vector > subField
Declare type of subField.
Internal & ref(const bool updateAccessTime=true)
Return a reference to the dimensioned internal field.
GeometricBoundaryField< scalar, fvPatchField, volMesh > Boundary
Type of boundary fields.
void setSize(const label n)
Alias for resize()
void append(const T &val)
Append an element at the end of the list.
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
virtual Ostream & write(const char c)
Write character.
virtual const fileName & name() const
Read/write access to the name of the stream.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
label size() const noexcept
The number of elements in the list.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
static const Enum< distributionType > distributionTypeNames_
faceShading uses the transmissivity value in the boundaryRadiationProperties in order to evaluate whi...
void correct()
Recalculate rayStartFaces using direction vector.
Mesh data needed to do the Finite Volume discretisation.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
virtual bool write(const bool valid=true) const
Write using setting from DB.
Triangulated surface description with patch information.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
OBJstream os(runTime.globalPath()/outputName)
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
const std::string patch
OpenFOAM patch number as a std::string.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const dimensionSet dimless
Dimensionless.
List< label > labelList
A List of labels.
line< point, const point & > linePointRef
A line using referred points.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Field< vector > vectorField
Specialisation of Field<T> for vector.
PrimitivePatch< List< face >, const pointField > bMesh
Holder of faceList and points. (v.s. e.g. primitivePatch which references points)
static constexpr const zero Zero
Global zero (0)
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
List< face > faceList
A List of faces.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
List< treeBoundBox > meshBb(1, treeBoundBox(boundBox(coarseMesh.points(), false)).extend(rndGen, 1e-3))
const triSurface localSurface
distributedTriSurfaceMesh surfacesMesh(IOobject("wallSurface.stl", runTime.constant(), "triSurface", runTime, IOobject::NO_READ, IOobject::NO_WRITE), localSurface, dict)
#define forAll(list, i)
Loop across all elements in list.