Loading...
Searching...
No Matches
viewFactorHottel.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 "viewFactorHottel.H"
30#include "fvMesh.H"
31#include "meshTools.H"
32//#include "addToRunTimeSelectionTable.H"
33
34using namespace Foam::constant;
35
36// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37
38namespace Foam
39{
40namespace VF
41{
43// addToRunTimeSelectionTable(viewFactorModel, viewFactorHottel, mesh);
44}
45}
46
47// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
48
50(
51 const point& p0,
52 const point& p1,
53 const point& p2,
54 const point& p3
55)
56{
57 return 0.5*(mag(p2-p1) + mag(p3-p0) - mag(p2-p0) - mag(p3-p1));
58}
59
60
62(
63 const labelListList& visibleFaceFaces,
64 const pointField& compactCf,
65 const vectorField& compactSf,
66 const UList<List<vector>>& compactFineSf,
67 const UList<List<point>>& compactFineCf,
68 const UList<List<point>>& compactPoints,
69 const UList<label>& compactPatchId
70) const
71{
72 // Fill local view factor matrix
73 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74 scalarListList Fij(visibleFaceFaces.size());
75
76 forAll(visibleFaceFaces, facei)
77 {
78 if (debug > 1)
79 {
80 Pout<< "facei:" << facei << "/" << visibleFaceFaces.size()
81 << endl;
82 }
83
84 const labelList& visibleFaces = visibleFaceFaces[facei];
85
86 Fij[facei].resize_nocopy(visibleFaces.size());
87
88 const point& dCi = compactCf[facei];
89 const vector& Ai = compactSf[facei];
90 const scalar magAi = mag(Ai);
91
92 const vector d1((Ai/magAi) ^ emptyDir_);
93 const vector l1(0.5*magAi/w_*d1);
94 const point p0(dCi + l1);
95 const point p1(dCi - l1);
96
97 forAll(visibleFaces, visibleFacei)
98 {
99 const label sloti = visibleFaces[visibleFacei];
100
101 const point& dCj = compactCf[sloti];
102 const vector& Aj = compactSf[sloti];
103 const scalar magAj = mag(Aj);
104
105 const vector d2((Aj/magAj) ^ emptyDir_);
106 const vector l2(0.5*magAj/w_*d2);
107 const point p2(dCj - l2);
108 const point p3(dCj + l2);
109
110 const scalar FijH = calculateFij(p0, p1, p2, p3);
111
112 Fij[facei][visibleFacei] = FijH/(magAi/w_);
113 }
114 }
115
116
117 return Fij;
118}
119
120
121// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
122
124(
125 const fvMesh& mesh,
126 const dictionary& dict
127)
128:
130 emptyDir_(vector::one),
131 w_(0)
132{
133 if (mesh.nSolutionD() != 2)
134 {
135 FatalErrorInFunction
136 << "Hottel crossed strings method only applicable to 2D cases"
137 << exit(FatalError);
138 }
139
140 meshTools::constrainDirection(mesh, mesh.solutionD(), emptyDir_);
141 emptyDir_ = vector::one - emptyDir_;
142 emptyDir_.normalise();
143
144 // 2D width - assume slab
145 // TODO: warn wedge/axisymmetric?
146 w_ = mesh.bounds().span() & emptyDir_;
147
148 Info<< "\nEmpty direction: " << emptyDir_
149 << "\nWidth: " << w_ << endl;
150}
151
152
153// ************************************************************************* //
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
Definition ListI.H:171
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Computes view factors according to Hottel's crossed strings method.
static scalar calculateFij(const point &p0, const point &p1, const point &p2, const point &p3)
Calculate view factor using the double-area integral.
viewFactorHottel(const fvMesh &mesh, const dictionary &dict)
Constructor.
A base class for viewFactor models.
virtual void calculate()
Calculate the view factors.
static const Form one
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
const volScalarField & p0
Definition EEqn.H:36
dynamicFvMesh & mesh
A namespace for various viewFactor model implementations.
Different types of constants.
void constrainDirection(const polyMesh &mesh, const Vector< label > &dirs, vector &d)
Set the constrained components of directions/velocity to zero.
Definition meshTools.C:680
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
messageStream Info
Information stream (stdout output on master, null elsewhere).
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
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