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 -------------------------------------------------------------------------------
11 License
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 
34 namespace Foam
35 {
36 
37 // Smaller helper to resize matrix and assign to Zero
38 template<class T>
39 inline 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
48 template<class T>
49 inline 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 
71 Foam::PDRarrays::PDRarrays(const PDRblock& pdrBlock)
72 :
73  PDRarrays()
74 {
75  reset(pdrBlock);
76 }
77 
78 
79 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
80 
81 void 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 // ************************************************************************* //
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
PDRarrays()
Construct null.
static Vector< label > uniform(const label &s)
Return a VectorSpace with all elements = s.
Definition: VectorSpaceI.H:157
label n
Vector< label > labelVector
Vector of labels.
Definition: labelVector.H:47
void reset(const PDRblock &pdrBlock)
Reset PDRblock reference, resize and zero arrays.
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:157