/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | foam-extend: Open Source CFD \\ / O peration | Version: 4.0 \\ / A nd | Web: http://www.foam-extend.org \\/ M anipulation | For copyright notice see file Copyright ------------------------------------------------------------------------------- License This file is part of foam-extend. foam-extend is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. foam-extend is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with foam-extend. If not, see . Application viewFactorGenerator Description View factors are calculated based on a face agglomeration array (finalAgglom generated by faceAgglomerate utility). Each view factor between the agglomerated faces i and j (Fij) is calculated using a double integral of the sub-areas composing the agglomaration. The patches involved in the view factor calculation are taken from the Qr volScalarField (radiative flux) when is greyDiffusiveRadiationViewFactor otherwise they are not included. \*---------------------------------------------------------------------------*/ #include "argList.H" #include "foamTime.H" #include "fvMesh.H" #include "volFields.H" #include "surfaceFields.H" #include "distributedTriSurfaceMesh.H" #include "triSurfaceTools.H" #include "mapDistribute.H" #include "OFstream.H" #include "meshTools.H" #include "plane.H" #include "uindirectPrimitivePatch.H" #include "DynamicField.H" #include "IFstream.H" #include "unitConversion.H" #include "mathematicalConstants.H" #include "scalarMatrices.H" #include "CompactListList.H" #include "labelIOList.H" #include "labelIOList.H" #include "scalarIOList.H" #include "singleCellFvMesh.H" #include "IOdictionary.H" #include "fixedValueFvPatchFields.H" using namespace Foam; void writeRays ( const fileName& fName, const pointField& compactCf, const pointField& myFc, const labelListList& visibleFaceFaces ) { OFstream str(fName); label vertI = 0; Pout<< "Dumping rays to " << str.name() << endl; forAll(myFc, faceI) { const labelList visFaces = visibleFaceFaces[faceI]; forAll(visFaces, faceRemote) { label compactI = visFaces[faceRemote]; const point& remoteFc = compactCf[compactI]; meshTools::writeOBJ(str, myFc[faceI]); vertI++; meshTools::writeOBJ(str, remoteFc); vertI++; str << "l " << vertI-1 << ' ' << vertI << nl; } } string cmd("objToVTK " + fName + " " + fName.lessExt() + ".vtk"); Pout<< "cmd:" << cmd << endl; system(cmd); } scalar calculateViewFactorFij ( const vector& i, const vector& j, const vector& dAi, const vector& dAj ) { vector r = i - j; scalar rMag = mag(r); scalar dAiMag = mag(dAi); scalar dAjMag = mag(dAj); vector ni = dAi/dAiMag; vector nj = dAj/dAjMag; scalar cosThetaJ = mag(nj & r)/rMag; scalar cosThetaI = mag(ni & r)/rMag; return ( (cosThetaI*cosThetaJ*dAjMag*dAiMag) /(sqr(rMag)*mathematicalConstant::pi) ); } void insertMatrixElements ( const globalIndex& globalNumbering, const label fromProcI, const labelListList& globalFaceFaces, const scalarListList& viewFactors, scalarSquareMatrix& matrix ) { forAll(viewFactors, faceI) { const scalarList& vf = viewFactors[faceI]; const labelList& globalFaces = globalFaceFaces[faceI]; label globalI = globalNumbering.toGlobal(fromProcI, faceI); forAll(globalFaces, i) { matrix[globalI][globalFaces[i]] = vf[i]; } } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { #include "addRegionOption.H" #include "setRootCase.H" #include "createTime.H" #include "createNamedMesh.H" // Read view factor dictionary IOdictionary viewFactorDict ( IOobject ( "viewFactorsDict", runTime.constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ) ); const bool writeViewFactors = viewFactorDict.lookupOrDefault("writeViewFactorMatrix", false); const bool dumpRays = viewFactorDict.lookupOrDefault("dumpRays", false); const label debug = viewFactorDict.lookupOrDefault