PDRarrays.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) 2016 Shell Research Ltd.
9 Copyright (C) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "PDRarrays.H"
30#include "PDRblock.H"
31
32// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
33
34namespace Foam
35{
36
37// Smaller helper to resize matrix and assign to Zero
38template<class T>
39inline void resizeMatrix(SquareMatrix<T>& mat, const label n)
40{
41 mat.setSize(n);
42 mat = Zero;
43}
44
45
46// Smaller helper to resize i-j-k field and assign to uniform value,
47// normally Zero
48template<class T>
49inline void resizeField
50(
51 IjkField<T>& fld,
52 const labelVector& ijk,
53 const T& val = T(Zero)
54)
55{
56 fld.resize(ijk);
57 fld = val;
58}
59
60} // End namespace Foam
61
62
63// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
64
66:
67 pdrBlock_(std::cref<PDRblock>(PDRblock::null()))
68{}
69
70
71Foam::PDRarrays::PDRarrays(const PDRblock& pdrBlock)
72:
73 PDRarrays()
74{
75 reset(pdrBlock);
76}
77
78
79// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
80
81void Foam::PDRarrays::reset(const PDRblock& pdrBlock)
82{
83 pdrBlock_ = std::cref<PDRblock>(pdrBlock);
84
85 // Resize all the major arrays, which are grouped in the structure arrp
86 // All the relevant dimensions are in PDRblock
87
88 // Cell-based addressing
89 const labelVector cellDims = pdrBlock.sizes();
90
91 // Face or point-based addressing
92 const labelVector faceDims(cellDims + labelVector::one);
93
94 // Max addressing dimensions for 2D arrays, with some extra space
95 // These will be used for any combination of x,y,z,
96 // so need to be dimensioned to the maximum size in both directions
97 const label maxDim = cmptMax(pdrBlock.sizes()) + 2;
98
99 resizeField(v_block, cellDims);
100 resizeField(surf, cellDims);
101
102 resizeField(area_block_s, cellDims);
103 resizeField(area_block_r, cellDims);
104 resizeField(dirn_block, cellDims);
105
106 resizeField(face_block, faceDims);
107
108 resizeField(along_block, cellDims);
109
110 resizeField(betai_inv1, cellDims);
111
112 resizeField(obs_count, cellDims);
113 resizeField(sub_count, cellDims);
114 resizeField(grating_count, cellDims);
115
116 resizeField(drag_s, cellDims);
117 resizeField(drag_r, cellDims);
118
119 resizeField(obs_size, cellDims);
120
121 for (auto& list : overlap_1d)
122 {
123 list.resize(maxDim);
124 list = Zero;
125 }
126
127 resizeMatrix(aboverlap, maxDim);
128 resizeMatrix(abperim, maxDim);
129 resizeMatrix(a_lblock, maxDim);
130 resizeMatrix(b_lblock, maxDim);
131 resizeMatrix(ac_lblock, maxDim);
132 resizeMatrix(bc_lblock, maxDim);
133 resizeMatrix(c_count, maxDim);
134 resizeMatrix(c_drag, maxDim);
135
136 resizeField(face_patch, faceDims, labelVector::uniform(-1));
137 resizeField(hole_in_face, faceDims);
138}
139
140
141// ************************************************************************* //
label n
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
IjkField< vector > drag_r
Directional drag from round obstacles.
Definition: PDRarrays.H:116
IjkField< vector > betai_inv1
Definition: PDRarrays.H:99
IjkField< vector > along_block
Definition: PDRarrays.H:97
IjkField< scalar > v_block
Volume blockage.
Definition: PDRarrays.H:74
SquareMatrix< scalar > ac_lblock
Definition: PDRarrays.H:134
IjkField< vector > area_block_r
Summed area blockage (directional) from round obstacles.
Definition: PDRarrays.H:86
Vector< List< scalar > > overlap_1d
Definition: PDRarrays.H:122
SquareMatrix< scalar > b_lblock
Definition: PDRarrays.H:131
IjkField< vector > sub_count
Number of obstacles parallel to specified direction.
Definition: PDRarrays.H:106
IjkField< Vector< bool > > hole_in_face
Face field for (directional) hole in face.
Definition: PDRarrays.H:146
SquareMatrix< symmTensor2D > c_drag
Cell-centred drag.
Definition: PDRarrays.H:140
IjkField< vector > area_block_s
Summed area blockage (directional) from sharp obstacles.
Definition: PDRarrays.H:83
SquareMatrix< scalar > abperim
Definition: PDRarrays.H:128
SquareMatrix< scalar > bc_lblock
Definition: PDRarrays.H:134
IjkField< scalar > obs_size
Obstacle size in cell.
Definition: PDRarrays.H:80
SquareMatrix< scalar > aboverlap
Definition: PDRarrays.H:125
IjkField< Vector< bool > > dirn_block
A total directional blockage in the cell.
Definition: PDRarrays.H:89
IjkField< scalar > obs_count
Number of obstacles in cell.
Definition: PDRarrays.H:103
IjkField< vector > grating_count
Definition: PDRarrays.H:110
IjkField< symmTensor > drag_s
Tensorial drag from sharp obstacles.
Definition: PDRarrays.H:113
PDRarrays()
Construct null.
IjkField< vector > face_block
Definition: PDRarrays.H:93
IjkField< labelVector > face_patch
Face field for (directional) for patch Id.
Definition: PDRarrays.H:143
SquareMatrix< scalar > a_lblock
Definition: PDRarrays.H:131
IjkField< scalar > surf
Surface area in cell.
Definition: PDRarrays.H:77
SquareMatrix< scalar > c_count
Definition: PDRarrays.H:137
void reset()
Reset to defaults.
const volScalarField & T
Namespace for OpenFOAM.
Vector< label > labelVector
Vector of labels.
Definition: labelVector.H:51
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131