binModelTemplates.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) 2021-2022 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 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  List<List<Type>>& data,
34  const label bini,
35  const Type& v,
36  const vector& n
37 ) const
38 {
39  return decomposePatchValues_;
40 }
41 
42 
43 template<class Type>
45 {
47  {
48  return stem;
49  }
50 
51  string result = "";
52  for (label cmpt = 0; cmpt < pTraits<Type>::nComponents; ++cmpt)
53  {
54  if (cmpt) result += " ";
55  result += stem + "_" + word(pTraits<Type>::componentNames[cmpt]);
56  }
57  return result;
58 };
59 
60 
61 template<class Type>
63 (
64  List<List<Type>>& data,
65  Ostream& os
66 ) const
67 {
68  if (cumulative_)
69  {
70  for (auto& datai : data)
71  {
72  for (label bini = 1; bini < nBin_; ++bini)
73  {
74  datai[bini] += datai[bini-1];
75  }
76  }
77  }
78 
79  writeCurrentTime(os);
80 
81  for (label bini = 0; bini < nBin_; ++bini)
82  {
83  Type total = Zero;
84 
85  for (label i = 0; i < data.size(); ++i)
86  {
87  total += data[i][bini];
88  }
89 
90  writeValue(os, total);
91 
92  for (label i = 0; i < data.size(); ++i)
93  {
94  writeValue(os, data[i][bini]);
95  }
96  }
97 
98  os << endl;
99 }
100 
101 
102 // ************************************************************************* //
void writeBinnedData(List< List< Type >> &data, Ostream &os) const
Write binned data to stream.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
A traits class, which is primarily used for primitives and vector-space.
Definition: pTraits.H:75
bool decomposePatchValues_
Decompose patch values into normal and tangential components.
Definition: binModel.H:73
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
Definition: exprTraits.C:40
A class for handling words, derived from Foam::string.
Definition: word.H:63
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
string writeComponents(const word &stem) const
Helper function to construct a string description for a given type.
OBJstream os(runTime.globalPath()/outputName)
bool decomposePatchValues(List< List< Type >> &data, const label bini, const Type &v, const vector &n) const
Helper function to decompose patch values into normal and tangential components.
label n
A class for handling character strings derived from std::string.
Definition: string.H:72
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127