viewFactor2AI.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2023-2024 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "viewFactor2AI.H"
29 #include "mathematicalConstants.H"
31 
32 using namespace Foam::constant;
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace VF
39 {
40  defineTypeNameAndDebug(viewFactor2AI, 0);
41  addToRunTimeSelectionTable(viewFactorModel, viewFactor2AI, mesh);
42 }
43 }
44 
45 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
46 
48 (
49  const point& xi,
50  const point& xj,
51  const vector& dAi,
52  const vector& dAj
53 )
54 {
55  const vector r(xj - xi);
56  const scalar rMag = mag(r);
57  const scalar dAiMag(mag(dAi));
58  const scalar dAjMag(mag(dAj));
59 
60  if (rMag > SMALL && dAiMag > SMALL && dAjMag > SMALL)
61  {
62  const vector nr(r/rMag);
63  const vector ni(dAi/dAiMag);
64  const vector nj(dAj/dAjMag);
65 
66  const scalar Fij =
67  -(nr & ni)*(nr & nj)/sqr(rMag)*dAjMag*dAiMag/mathematical::pi;
68 
69  if (Fij > 0) return Fij;
70  }
71 
72  return 0;
73 }
74 
75 
77 (
78  const labelListList& visibleFaceFaces,
79  const pointField& compactCf,
80  const vectorField& compactSf,
81  const List<List<vector>>& compactFineSf,
82  const List<List<point>>& compactFineCf,
83  const DynamicList<List<point>>& compactPoints,
84  const DynamicList<label>& compactPatchId
85 ) const
86 {
87  // Fill local view factor matrix
88  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
89  scalarListList Fij(visibleFaceFaces.size());
90 
91  forAll(visibleFaceFaces, facei)
92  {
93  if (debug > 1)
94  {
95  Pout<< "facei:" << facei << "/" << visibleFaceFaces.size()
96  << endl;
97  }
98 
99  const labelList& visibleFaces = visibleFaceFaces[facei];
100 
101  Fij[facei].resize(visibleFaces.size(), Zero);
102 
103  const point& dCi = compactCf[facei];
104  const vector& Ai = compactSf[facei];
105  const scalar magAi = mag(Ai);
106 
107  if (magAi < SMALL) continue;
108 
109  forAll(visibleFaces, visibleFacei)
110  {
111  const label sloti = visibleFaces[visibleFacei];
112  const point& dCj = compactCf[sloti];
113  const vector& Aj = compactSf[sloti];
114 
115  const scalar Fij2AI = calculateFij(dCi, dCj, Ai, Aj);
116 
117  Fij[facei][visibleFacei] = Fij2AI/magAi;
118  }
119  }
120 
121 
122  return Fij;
123 }
124 
125 
126 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
127 
129 (
130  const fvMesh& mesh,
131  const dictionary& dict
132 )
133 :
134  viewFactorModel(mesh, dict)
135 {}
136 
137 
138 // ************************************************************************* //
Different types of constants.
dictionary dict
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:153
viewFactor2AI(const fvMesh &mesh, const dictionary &dict)
Constructor.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
dynamicFvMesh & mesh
virtual void calculate()
Calculate the view factors.
List< scalarList > scalarListList
List of scalarList.
Definition: scalarList.H:35
constexpr scalar pi(M_PI)
Vector< scalar > vector
Definition: vector.H:57
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
vector point
Point is a vector.
Definition: point.H:37
Field< vector > vectorField
Specialisation of Field<T> for vector.
static scalar calculateFij(const point &xi, const point &xj, const vector &dAi, const vector &dAj)
Calculate view factor using the double-area integral.
List< label > labelList
A List of labels.
Definition: List.H:62
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127