binModel.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-------------------------------------------------------------------------------
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 "binModel.H"
29#include "fvMesh.H"
30#include "cartesianCS.H"
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace Foam
35{
38}
39
40
41// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
42
43template<>
45(
47 const label bini,
48 const vector& v,
49 const vector& n
50) const
51{
53 {
54 return false;
55 }
56
57 #ifdef FULLDEBUG
58 if (data.size() != 3)
59 {
61 << "Inconsistent data list size - expect size 3"
62 << abort(FatalError);
63 }
64 #endif
65
66 data[1][bini] += n*(v & n);
67 data[2][bini] += v - n*(v & n);
68
69 return true;
70}
71
72
74(
75 const dictionary& dict,
76 const word& e3Name,
77 const word& e1Name
78)
79{
80 coordSysPtr_.clear();
81
82 if (dict.found(coordinateSystem::typeName_()))
83 {
84 coordSysPtr_ =
86 (
87 mesh_,
88 dict,
89 coordinateSystem::typeName_()
90 );
91
92 Info<< "Setting co-ordinate system:" << nl
93 << " - type : " << coordSysPtr_->name() << nl
94 << " - origin : " << coordSysPtr_->origin() << nl
95 << " - e3 : " << coordSysPtr_->e3() << nl
96 << " - e1 : " << coordSysPtr_->e1() << endl;
97 }
98 else if (dict.found("CofR"))
99 {
100 const vector origin(dict.get<point>("CofR"));
101
102 const vector e3
103 (
104 e3Name == word::null
105 ? vector(0, 0, 1)
106 : dict.get<vector>(e3Name)
107 );
108
109 const vector e1
110 (
111 e1Name == word::null
112 ? vector(1, 0, 0)
113 : dict.get<vector>(e1Name)
114 );
115
116 coordSysPtr_.reset(new coordSystem::cartesian(origin, e3, e1));
117 }
118 else
119 {
120 coordSysPtr_.reset(new coordSystem::cartesian(dict));
121 }
122}
123
124
125// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
126
128(
129 const dictionary& dict,
130 const fvMesh& mesh,
131 const word& outputPrefix
132)
133:
134 writeFile(mesh, outputPrefix),
135 mesh_(mesh),
136 decomposePatchValues_(false),
137 cumulative_(false),
138 coordSysPtr_(),
139 nBin_(1),
140 patchSet_(),
141 fieldNames_(),
142 cellZoneIDs_(),
143 filePtrs_()
144{}
145
146
147// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
148
150{
151 patchSet_ = mesh_.boundaryMesh().patchSet(dict.get<wordRes>("patches"));
152 fieldNames_ = dict.get<wordHashSet>("fields").sortedToc();
153
154 if (dict.found("cellZones"))
155 {
157 DynamicList<wordRe> czUnmatched;
158 for (const auto& cz : dict.get<wordRes>("cellZones"))
159 {
160 const labelList czi(mesh_.cellZones().indices(cz));
161
162 if (czi.empty())
163 {
164 czUnmatched.append(cz);
165 }
166 else
167 {
168 zoneIDs.append(czi);
169 }
170 }
171
172 if (czUnmatched.size())
173 {
175 << "Unable to find zone(s): " << czUnmatched << nl
176 << "Valid cellZones are : " << mesh_.cellZones().sortedNames()
177 << endl;
178 }
179
180 cellZoneIDs_.transfer(zoneIDs);
181 }
182
183 decomposePatchValues_ = dict.get<bool>("decomposePatchValues");
184
185 filePtrs_.setSize(fieldNames_.size());
186 forAll(filePtrs_, i)
187 {
188 filePtrs_.set(i, createFile(fieldNames_[i] + "Bin"));
189 }
190
191 setCoordinateSystem(dict);
192
193 return true;
194}
195
196
198{}
199
200
202{}
203
204
205// ************************************************************************* //
label n
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
void append(const T &val)
Copy append an element to the end of this list.
Definition: DynamicListI.H:503
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
void append(const T &val)
Append an element at the end of the list.
Definition: ListI.H:175
virtual bool read()
Re-read model coefficients if they have changed.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
Definition: UListI.H:427
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Base class for bin models to handle general bin characteristics.
Definition: binModel.H:64
bool decomposePatchValues(List< List< Type > > &data, const label bini, const Type &v, const vector &n) const
bool decomposePatchValues_
Decompose patch values into normal and tangential components.
Definition: binModel.H:73
void setCoordinateSystem(const dictionary &dict, const word &e3Name=word::null, const word &e1Name=word::null)
Set the co-ordinate system from dictionary and axes names.
Definition: binModel.C:74
A Cartesian coordinate system.
Definition: cartesianCS.H:72
Database for solution data, solver performance and other reduced data.
Definition: data.H:58
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionaryI.H:87
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
void movePoints()
Update for new mesh geometry.
void updateMesh()
Update for new mesh topology.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
const labelIOList & zoneIDs
Definition: correctPhi.H:59
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
Vector< scalar > vector
Definition: vector.H:61
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333