sampledSets.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::sampledSets
26 
27 Description
28  Set of sets to sample.
29  Call sampledSets.write() to sample&write files.
30 
31 SourceFiles
32  sampledSets.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef sampledSets_H
37 #define sampledSets_H
38 
39 #include "fvMeshFunctionObject.H"
40 #include "sampledSet.H"
41 #include "volFieldsFwd.H"
42 #include "meshSearch.H"
43 #include "interpolation.H"
44 #include "coordSet.H"
45 #include "setWriter.H"
46 #include "wordReList.H"
47 #include "HashPtrTable.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward declaration of classes
55 class Time;
56 class objectRegistry;
57 class dictionary;
58 class fvMesh;
59 
60 namespace functionObjects
61 {
62 
63 /*---------------------------------------------------------------------------*\
64  Class sampledSets Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class sampledSets
68 :
69  public fvMeshFunctionObject,
70  public PtrList<sampledSet>
71 {
72  // Static Data Members
73 
74  //- Output verbosity
75  static bool verbose_;
76 
77 
78  // Private Data
79 
80  //- Keep the dictionary to recreate sets for moving mesh cases
81  dictionary dict_;
82 
83  //- Output path
84  fileName outputPath_;
85 
86  //- Mesh search engine
87  meshSearch searchEngine_;
88 
89 
90  // Read from dictionary
91 
92  //- Names of fields to sample
93  wordList fields_;
94 
95  //- Interpolation scheme to use
96  word interpolationScheme_;
97 
98 
99  // Merging structures
100 
101  //- Global sets gathered on the master
102  PtrList<coordSet> masterSets_;
103 
104  //- Mapping from local to global sets
105  labelListList masterSetOrders_;
106 
107 
108  // Calculated
109 
110  //- Set formatter
111  autoPtr<setWriter> formatter_;
112 
113 
114  // Private Member Functions
115 
116  //- Combine sets on all processors. Sort by curveDist and produce
117  // index list. Valid result only on master processor.
118  void combineSampledSets();
119 
120  //- Sample all fields of a type on a given set
121  template<class Type>
122  PtrList<Field<Type>> sampleLocalType
123  (
124  const label seti,
125  const wordList& fieldNames,
126  HashPtrTable<interpolation<Type>>& interpolations
127  );
128 
129  //- Sample all fields of a type on a given set and combine on the
130  // master for writing
131  template<class Type>
132  PtrList<Field<Type>> sampleType
133  (
134  const label seti,
135  const wordList& fieldNames,
136  HashPtrTable<interpolation<Type>>& interpolations
137  );
138 
139 
140 public:
141 
142  //- Runtime type information
143  TypeName("sets");
144 
145 
146  // Constructors
147 
148  //- Construct from Time and dictionary
150  (
151  const word& name,
152  const Time& time,
153  const dictionary& dict
154  );
155 
156  //- Disallow default bitwise copy construction
157  sampledSets(const sampledSets&) = delete;
158 
159 
160  //- Destructor
161  virtual ~sampledSets();
162 
163 
164  // Member Functions
165 
166  //- Set verbosity level
167  void verbose(const bool verbosity = true);
168 
169  //- Read the sampledSets
170  virtual bool read(const dictionary&);
171 
172  //- Return the list of fields required
173  virtual wordList fields() const;
174 
175  //- Execute, currently does nothing
176  virtual bool execute();
177 
178  //- Sample and write
179  virtual bool write();
180 
181  //- Correct for mesh changes
182  void correct();
183 
184  //- Update for mesh point-motion
185  virtual void movePoints(const polyMesh&);
186 
187  //- Update topology using the given map
188  virtual void topoChange(const polyTopoChangeMap&);
189 
190  //- Update from another mesh using the given map
191  virtual void mapMesh(const polyMeshMap&);
192 
193  //- Update topology using the given map due to readUpdate
194  virtual void readUpdate(const polyMesh::readUpdateState state);
195 
196 
197  // Member Operators
198 
199  //- Disallow default bitwise assignment
200  void operator=(const sampledSets&) = delete;
201 };
202 
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 } // End namespace functionObjects
207 } // End namespace Foam
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 #ifdef NoRepository
212  #include "sampledSetsTemplates.C"
213 #endif
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 #endif
218 
219 // ************************************************************************* //
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search...
Definition: meshSearch.H:57
dictionary dict
A class for handling file names.
Definition: fileName.H:79
const word & name() const
Return the name of this functionObject.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
sampledSets(const word &name, const Time &time, const dictionary &dict)
Construct from Time and dictionary.
Definition: sampledSets.C:88
virtual bool execute()
Execute, currently does nothing.
Definition: sampledSets.C:133
TypeName("sets")
Runtime type information.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: sampledSets.C:297
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:50
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
static List< word > fieldNames
Definition: globalFoam.H:46
virtual bool write()
Sample and write.
Definition: sampledSets.C:139
A class for handling words, derived from string.
Definition: word.H:59
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
virtual void readUpdate(const polyMesh::readUpdateState state)
Update topology using the given map due to readUpdate.
Definition: sampledSets.C:315
virtual ~sampledSets()
Destructor.
Definition: sampledSets.C:115
virtual bool read(const dictionary &)
Read the sampledSets.
Definition: sampledSets.C:229
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
Definition: sampledSets.C:286
Writes run time, CPU time and clock time and optionally the CPU and clock times per time step...
void operator=(const sampledSets &)=delete
Disallow default bitwise assignment.
void correct()
Correct for mesh changes.
Definition: sampledSets.C:268
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
Abstract base class for interpolation.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
void verbose(const bool verbosity=true)
Set verbosity level.
Definition: sampledSets.C:121
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:90
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:50
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: sampledSets.C:308
virtual wordList fields() const
Return the list of fields required.
Definition: sampledSets.C:127
Namespace for OpenFOAM.