viewFactor2LI.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 "viewFactor2LI.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(viewFactor2LI, 0);
41  addToRunTimeSelectionTable(viewFactorModel, viewFactor2LI, mesh);
42 }
43 }
44 
45 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
46 
48 (
49  const List<point>& lPoints,
50  const List<point>& rPoints,
51  const scalar alpha
52 )
53 {
54  scalar Fij = 0;
55 
56  forAll(lPoints, i)
57  {
58  // Edge vector and centroid of edge i
59  const vector si(lPoints[i] - lPoints.rcValue(i));
60  const point ci(0.5*(lPoints[i] + lPoints.rcValue(i)));
61 
62  forAll(rPoints, j)
63  {
64  // Edge vector and centroid of edge j
65  const vector sj(rPoints[j] - rPoints.rcValue(j));
66  const point cj(0.5*(rPoints[j] + rPoints.rcValue(j)));
67 
68  vector r(ci - cj);
69  if (mag(r) < SMALL)
70  {
71  r = alpha*si;
72  }
73 
74  Fij += (si & sj)*Foam::log(r & r);
75  }
76  }
77 
78  return max(0, 0.25*Fij/mathematical::pi);
79 }
80 
81 
83 (
84  const labelListList& visibleFaceFaces,
85  const pointField& compactCf,
86  const vectorField& compactSf,
87  const List<List<vector>>& compactFineSf,
88  const List<List<point>>& compactFineCf,
89  const DynamicList<List<point>>& compactPoints,
90  const DynamicList<label>& compactPatchId
91 ) const
92 {
93  // Fill local view factor matrix
94  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95  scalarListList Fij(visibleFaceFaces.size());
96 
97  forAll(visibleFaceFaces, facei)
98  {
99  if (debug > 1)
100  {
101  Pout<< "facei:" << facei << "/" << visibleFaceFaces.size()
102  << endl;
103  }
104 
105  const labelList& visibleFaces = visibleFaceFaces[facei];
106 
107  Fij[facei].resize(visibleFaces.size(), Zero);
108 
109  const vector& Ai = compactSf[facei];
110  const scalar magAi = mag(Ai);
111 
112  forAll(visibleFaces, visibleFacei)
113  {
114  const label sloti = visibleFaces[visibleFacei];
115  const List<point>& lPoints = compactPoints[facei];
116  const List<point>& rPoints = compactPoints[sloti];
117 
118  const scalar Fij2LI = calculateFij(lPoints, rPoints, alpha_);
119 
120  Fij[facei][visibleFacei] = Fij2LI/magAi;
121  }
122  }
123 
124  return Fij;
125 }
126 
127 
128 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
129 
131 (
132  const fvMesh& mesh,
133  const dictionary& dict
134 )
135 :
136  viewFactorModel(mesh, dict),
137  alpha_(dict.getOrDefault("alpha", 0.21))
138 {}
139 
140 
141 // ************************************************************************* //
Different types of constants.
dictionary dict
dimensionedScalar log(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:153
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
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)
viewFactor2LI(const fvMesh &mesh, const dictionary &dict)
Constructor.
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
static scalar calculateFij(const List< point > &lPoints, const List< point > &rPoints, const scalar alpha)
Calculate view factor using the double-area integral.
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< label > labelList
A List of labels.
Definition: List.H:62
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
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