pointFieldDecomposerCache.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#include "fieldsDistributor.H"
30#include "pointFields.H"
31#include "IOobjectList.H"
32#include "PtrListOps.H"
33
34// * * * * * * * * * * * * * * * * Declarations * * * * * * * * * * * * * * //
35
36namespace Foam
37{
38
39// All point field types
41{
42public:
43
44 #undef declareField
45 #define declareField(Type) \
46 PtrList<GeometricField<Type, pointPatchField, pointMesh>> Type##Fields_;
47
48 declareField(scalar);
53 #undef declareField
54
55 label size() const noexcept
56 {
57 label count = 0;
58
59 #undef doLocalCode
60 #define doLocalCode(Type) \
61 { \
62 count += Type##Fields_.size(); \
63 }
64
65 doLocalCode(scalar);
70 #undef doLocalCode
71
72 return count;
73 }
74
75 bool empty() const noexcept { return !size(); }
76
77 void readAll(const pointMesh& mesh, const IOobjectList& objects)
78 {
79 #undef doLocalCode
80 #define doLocalCode(Type) \
81 { \
82 fieldsDistributor::readFields \
83 ( \
84 mesh, \
85 objects, \
86 Type##Fields_, \
87 false /* readOldTime = false */ \
88 ); \
89 }
90
91 doLocalCode(scalar);
96
97 #undef doLocalCode
98 }
99
100 template<class GeoField>
101 static void decompose
102 (
103 const pointFieldDecomposer& decomposer,
105 bool report
106 )
107 {
108 if (!fields.empty())
109 {
110 if (report)
111 {
112 Info<< " "
114 << "s: "
116 }
117
118 decomposer.decomposeFields(fields);
119 }
120 }
121
123 (
124 const pointFieldDecomposer& decomposer,
125 bool report
126 ) const
127 {
128 #undef doLocalCode
129 #define doLocalCode(Type) \
130 { \
131 decompose(decomposer, Type##Fields_, report); \
132 }
133
134 doLocalCode(scalar);
139
140 #undef doLocalCode
141 }
142};
143
144} // End namespace Foam
145
146
147// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
148
150:
151 cache_(new privateCache)
152{}
153
154
155// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
156
157// Destructor not in header (used incomplete type)
159{}
160
161
162// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
163
165{
166 return (!cache_ || cache_->empty());
167}
168
169
171{
172 return (cache_ ? cache_->size() : label(0));
173}
174
175
177{
178 cache_.reset(new privateCache);
179}
180
181
183(
184 const pointMesh& mesh,
185 const IOobjectList& objects
186)
187{
188 if (cache_)
189 {
190 cache_->readAll(mesh, objects);
191 }
192}
193
194
196(
197 const pointFieldDecomposer& decomposer,
198 bool report
199) const
200{
201 if (cache_)
202 {
203 cache_->decomposeAll(decomposer, report);
204 }
205}
206
207
208// ************************************************************************* //
Functions to operate on Pointer Lists.
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:59
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
A traits class, which is primarily used for primitives.
Definition: pTraits.H:59
static void decompose(const pointFieldDecomposer &decomposer, const PtrList< GeoField > &fields, bool report)
void decomposeAll(const pointFieldDecomposer &decomposer, bool report) const
void readAll(const pointMesh &mesh, const IOobjectList &objects)
void readAllFields(const pointMesh &mesh, const IOobjectList &objects)
Read all fields given mesh and objects.
label size() const
Total number of fields.
void decomposeAllFields(const pointFieldDecomposer &decomposer, bool report=false) const
Decompose and write all fields.
Point field decomposer.
void decomposeFields(const PtrList< GeoField > &fields) const
Decompose list of fields.
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:55
dynamicFvMesh & mesh
#define declareField(Type)
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:215
const direction noexcept
Definition: Scalar.H:223
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97
#define doLocalCode(GeoField)