Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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 "viewFactor2AI.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 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 UList<List<vector>>& compactFineSf,
82 const UList<List<point>>& compactFineCf,
83 const UList<List<point>>& compactPoints,
84 const UList<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:
135{}
136
137
138// ************************************************************************* //
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
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Computes view factors according to the double area integral (2AI) method.
viewFactor2AI(const fvMesh &mesh, const dictionary &dict)
Constructor.
static scalar calculateFij(const point &xi, const point &xj, const vector &dAi, const vector &dAj)
Calculate view factor using the double-area integral.
A base class for viewFactor models.
virtual void calculate()
Calculate the view factors.
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.
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
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
dimensionedSymmTensor sqr(const dimensionedVector &dv)
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
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299