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 -------------------------------------------------------------------------------
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 "viewFactorHottel.H"
29 #include "mathematicalConstants.H"
30 #include "fvMesh.H"
31 #include "meshTools.H"
32 //#include "addToRunTimeSelectionTable.H"
33 
34 using namespace Foam::constant;
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 namespace VF
41 {
42  defineTypeNameAndDebug(viewFactorHottel, 0);
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 List<List<vector>>& compactFineSf,
67  const List<List<point>>& compactFineCf,
68  const DynamicList<List<point>>& compactPoints,
69  const DynamicList<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 :
129  viewFactorModel(mesh, dict),
130  emptyDir_(vector::one),
131  w_(0)
132 {
133  if (mesh.nSolutionD() != 2)
134  {
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 // ************************************************************************* //
Different types of constants.
dictionary dict
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:608
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
Definition: ListI.H:168
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
#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
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
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< vector > vectorField
Specialisation of Field<T> for vector.
static scalar calculateFij(const point &p0, const point &p1, const point &p2, const point &p3)
Calculate view factor using the double-area integral.
void constrainDirection(const polyMesh &mesh, const Vector< label > &dirs, vector &d)
Set the constrained components of directions/velocity to zero.
Definition: meshTools.C:680
List< label > labelList
A List of labels.
Definition: List.H:62
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const volScalarField & p0
Definition: EEqn.H:36
Namespace for OpenFOAM.
viewFactorHottel(const fvMesh &mesh, const dictionary &dict)
Constructor.