Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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"
31
32using namespace Foam::constant;
33
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36namespace Foam
37{
38namespace VF
39{
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 UList<List<vector>>& compactFineSf,
88 const UList<List<point>>& compactFineCf,
89 const UList<List<point>>& compactPoints,
90 const UList<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:
137 alpha_(dict.getOrDefault("alpha", 0.21))
138{}
139
140
141// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
void resize(const label len)
Adjust allocated size of list.
Definition ListI.H:153
const T & rcValue(const label i) const
Return reverse circular value (ie, previous value in the list).
Definition UListI.H:127
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Computes view factors according to the double line integral (2LI) method.
static scalar calculateFij(const List< point > &lPoints, const List< point > &rPoints, const scalar alpha)
Calculate view factor using the double-area integral.
viewFactor2LI(const fvMesh &mesh, const dictionary &dict)
Constructor.
A base class for viewFactor models.
virtual void calculate()
Calculate the view factors.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
A namespace for various viewFactor model implementations.
Different types of constants.
Namespace for OpenFOAM.
List< scalarList > scalarListList
List of scalarList.
Definition scalarList.H:35
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
dimensionedScalar log(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
Definition point.H:37
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
volScalarField & alpha
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299