lagrangianFieldDecomposerCache.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) 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
29
30#include "labelIOField.H"
31#include "labelFieldIOField.H"
32#include "scalarIOField.H"
33#include "scalarFieldIOField.H"
34#include "vectorIOField.H"
35#include "vectorFieldIOField.H"
38#include "symmTensorIOField.H"
40#include "tensorIOField.H"
41#include "tensorFieldIOField.H"
42
43// * * * * * * * * * * * * * * * * Declarations * * * * * * * * * * * * * * //
44
45namespace Foam
46{
47
48// All lagrangian field/field-field types
50{
51public:
52
53 #undef declareField
54 #define declareField(Type) \
55 PtrList<PtrList<IOField<Type>>> Type##Fields_; \
56 PtrList<PtrList<CompactIOField<Field<Type>, Type>>> Type##FieldFields_;
57
59 declareField(scalar);
64 #undef declareField
65
66 bool empty() const noexcept { return labelFields_.empty(); }
67
68 label size() const noexcept { return labelFields_.size(); }
69
70 void resize(const label len)
71 {
72 #undef doLocalCode
73 #define doLocalCode(Type) \
74 { \
75 Type##Fields_.resize(len); \
76 Type##FieldFields_.resize(len); \
77 }
78
79 doLocalCode(label);
80 doLocalCode(scalar);
85
86 #undef doLocalCode
87 }
88
89 void readAll(const label cloudi, const IOobjectList& lagrangianObjects)
90 {
91 #undef doLocalCode
92 #define doLocalCode(Type) \
93 { \
94 lagrangianFieldDecomposer::readFields \
95 ( \
96 cloudi, \
97 lagrangianObjects, \
98 Type##Fields_ \
99 ); \
100 lagrangianFieldDecomposer::readFieldFields \
101 ( \
102 cloudi, \
103 lagrangianObjects, \
104 Type##FieldFields_ \
105 ); \
106 }
107
108 doLocalCode(label);
109 doLocalCode(scalar);
114
115 #undef doLocalCode
116 }
117
119 (
120 const label cloudi,
121 const fileName& cloudDir,
122 const lagrangianFieldDecomposer& decomposer,
123 bool report /* unused */
124 ) const
125 {
126 #undef doLocalCode
127 #define doLocalCode(Type) \
128 { \
129 decomposer.decomposeFields \
130 ( \
131 cloudDir, \
132 Type##Fields_[cloudi] \
133 ); \
134 decomposer.decomposeFieldFields \
135 ( \
136 cloudDir, \
137 Type##FieldFields_[cloudi] \
138 ); \
139 }
140
141 doLocalCode(label);
142 doLocalCode(scalar);
147
148 #undef doLocalCode
149 }
150};
151
152} // End namespace Foam
153
154
155// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
156
158:
159 cache_(new privateCache)
160{}
161
162
164(
165 const label nClouds
166)
167:
168 cache_(new privateCache)
169{
170 cache_->resize(nClouds);
171}
172
173
174// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
175
176// Destructor not in header (used incomplete type)
178{}
179
180
181// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
182
184{
185 return (!cache_ || cache_->empty());
186}
187
188
190{
191 return (cache_ ? cache_->size() : label(0));
192}
193
194
196{
197 cache_.reset(new privateCache);
198}
199
200
202(
203 const label nClouds
204)
205{
206 if (cache_)
207 {
208 cache_->resize(nClouds);
209 }
210}
211
212
214(
215 const label cloudi,
216 const IOobjectList& lagrangianObjects
217)
218{
219 if (cache_)
220 {
221 cache_->readAll(cloudi, lagrangianObjects);
222 }
223}
224
225
227(
228 const label cloudi,
229 const fileName& cloudDir,
230 const lagrangianFieldDecomposer& decomposer,
231 bool report
232) const
233{
234 if (cache_)
235 {
236 cache_->decomposeAll(cloudi, cloudDir, decomposer, report);
237 }
238}
239
240
241// ************************************************************************* //
virtual bool resize()
Resize the ODE solver.
Definition: Euler.C:53
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:59
A class for handling file names.
Definition: fileName.H:76
void readAll(const label cloudi, const IOobjectList &lagrangianObjects)
void decomposeAll(const label cloudi, const fileName &cloudDir, const lagrangianFieldDecomposer &decomposer, bool report) const
void readAllFields(const label cloudi, const IOobjectList &lagrangianObjects)
Read all fields and field-fields for given cloud and objects.
void decomposeAllFields(const label cloudi, const fileName &cloudDir, const lagrangianFieldDecomposer &decomposer, bool report=false) const
Decompose and write all fields and field-fields for given cloud.
#define declareField(Type)
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223
#define doLocalCode(GeoField)