Loading...
Searching...
No Matches
ensightWriterCaching.H
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-2024 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
26Class
27 Foam::ensightOutput::writerCaching
28
29Description
30 State information for writers with collated times.
31
32 The class maintains an internal list of the known times
33 as well as a file-cached version with the field information.
34 The information is used for restarts.
35
36SourceFiles
37 ensightWriterCaching.C
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef Foam_ensightOutput_writerCaching_H
42#define Foam_ensightOutput_writerCaching_H
43
44#include "bitSet.H"
45#include "dictionary.H"
46#include "scalarList.H"
47#include "DynamicList.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
53namespace ensightOutput
54{
56/*---------------------------------------------------------------------------*\
57 Class writerCaching Declaration
58\*---------------------------------------------------------------------------*/
59
60class writerCaching
61{
62 // Private Data
63
64 //- Cache dictionary file name
65 word dictName_;
66
67 //- The output times
69
70 //- Indices in times_ when geometry (mesh) has been written
71 bitSet geoms_;
72
73 //- Cached information for geometry, times, fields
74 dictionary cache_;
75
76
77 // Private Member Functions
78
79 //- Read time information from dictFileName.
80 // Returns timeIndex corresponding to timeValue
81 label readPreviousTimes
82 (
83 const fileName& dictFile,
84 const scalar timeValue
85 );
86
87 //- Get or create a sub-dictionary for named field
88 dictionary& fieldDict(const word& fieldName);
89
90 //- Remove named field
91 bool remove(const word& fieldName);
92
93
94public:
95
96 // Constructors
97
98 //- Construct with specified cache name
99 explicit writerCaching(const word& cacheFileName);
100
101
102 //- Destructor
103 virtual ~writerCaching() = default;
104
105
106 // Member Functions
107
108 //- The output times for fields
109 const scalarList& times() const noexcept
110 {
111 return times_;
112 }
113
114 //- Indices in times() when geometry (mesh) has been written
115 const bitSet& geometries() const noexcept
116 {
117 return geoms_;
118 }
119
120 //- The most current time index
121 label latestTimeIndex() const;
122
123 //- The most current geometry index
124 label latestGeomIndex() const;
126 //- Expected timeset for the geometry.
127 // Can be any of the following:
128 //
129 // 0: constant/static
130 // 1: moving, with the same frequency as the data
131 // 2: moving, with different frequency as the data
132 int geometryTimeset() const;
134 //- Get or create the 'fields' information dictionary.
135 const dictionary& fieldsDict() const;
136
137 //- Clear all values
138 void clear();
139
140 //- Update time/geometry information and file cache.
141 //- This routine should only be called from the master process
142 //
143 // Note that the ensight field type may contain spaces
144 // (eg, "tensor symm")
145 //
146 // \return True if there is a state change, which is either a
147 // geometry change or a new time interval
148 bool update
149 (
150 const fileName& baseDir,
151 const scalar timeValue,
152 const bool geomChanged,
153 const word& fieldName,
154 const string& fieldType,
155 const word& varName = word::null
156 );
157};
158
159
160// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161
162} // End namespace ensightOutput
163} // End namespace Foam
164
165// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166
167#endif
168
169// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
label latestTimeIndex() const
The most current time index.
writerCaching(const word &cacheFileName)
Construct with specified cache name.
virtual ~writerCaching()=default
Destructor.
const bitSet & geometries() const noexcept
Indices in times() when geometry (mesh) has been written.
const scalarList & times() const noexcept
The output times for fields.
label latestGeomIndex() const
The most current geometry index.
int geometryTimeset() const
Expected timeset for the geometry.
const dictionary & fieldsDict() const
Get or create the 'fields' information dictionary.
A class for handling file names.
Definition fileName.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
static const word null
An empty word.
Definition word.H:84
mesh update()
A collection of functions for writing ensight file content.
Namespace for OpenFOAM.
const direction noexcept
Definition scalarImpl.H:265
List< scalar > scalarList
List of scalar.
Definition scalarList.H:32