All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  // Private Data
73 
74  //- Keep the dictionary to recreate sets for moving mesh cases
75  dictionary dict_;
76 
77  //- Output path
78  fileName outputPath_;
79 
80  //- Mesh search engine
81  meshSearch searchEngine_;
82 
83 
84  // Read from dictionary
85 
86  //- Names of fields to sample
87  wordList fields_;
88 
89  //- Interpolation scheme to use
90  word interpolationScheme_;
91 
92 
93  // Merging structures
94 
95  //- Global sets gathered on the master
96  PtrList<coordSet> masterSets_;
97 
98  //- Mapping from local to global sets
99  labelListList masterSetOrders_;
100 
101 
102  // Calculated
103 
104  //- Set formatter
105  autoPtr<setWriter> formatter_;
106 
107 
108  // Private Member Functions
109 
110  //- Combine sets on all processors. Sort by curveDist and produce
111  // index list. Valid result only on master processor.
112  void combineSampledSets();
113 
114  //- Correct for mesh changes
115  void correct();
116 
117  //- Sample all fields of a type on a given set
118  template<class Type>
119  PtrList<Field<Type>> sampleLocalType
120  (
121  const label seti,
122  const wordList& fieldNames,
123  HashPtrTable<interpolation<Type>>& interpolations
124  );
125 
126  //- Sample all fields of a type on a given set and combine on the
127  // master for writing
128  template<class Type>
129  PtrList<Field<Type>> sampleType
130  (
131  const label seti,
132  const wordList& fieldNames,
133  HashPtrTable<interpolation<Type>>& interpolations
134  );
135 
136 
137 public:
138 
139  //- Runtime type information
140  TypeName("sets");
141 
142 
143  // Constructors
144 
145  //- Construct from Time and dictionary
147  (
148  const word& name,
149  const Time& time,
150  const dictionary& dict
151  );
152 
153  //- Disallow default bitwise copy construction
154  sampledSets(const sampledSets&) = delete;
155 
156 
157  //- Destructor
158  virtual ~sampledSets();
159 
160 
161  // Member Functions
162 
163  //- Read the sampledSets
164  virtual bool read(const dictionary&);
165 
166  //- Return the list of fields required
167  virtual wordList fields() const;
168 
169  //- Execute, currently does nothing
170  virtual bool execute();
171 
172  //- Sample and write
173  virtual bool write();
174 
175  //- Update for mesh point-motion
176  virtual void movePoints(const polyMesh&);
177 
178  //- Update topology using the given map
179  virtual void topoChange(const polyTopoChangeMap&);
180 
181  //- Update from another mesh using the given map
182  virtual void mapMesh(const polyMeshMap&);
183 
184  //- Redistribute or update using the given distribution map
185  virtual void distribute(const polyDistributionMap&);
186 
187 
188  // Member Operators
189 
190  //- Disallow default bitwise assignment
191  void operator=(const sampledSets&) = delete;
192 };
193 
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 } // End namespace functionObjects
198 } // End namespace Foam
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #ifdef NoRepository
203  #include "sampledSetsTemplates.C"
204 #endif
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 #endif
209 
210 // ************************************************************************* //
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:67
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A class for handling file names.
Definition: fileName.H:82
const word & name() const
Return the name of this functionObject.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
void operator=(const sampledSets &)=delete
Disallow default bitwise assignment.
sampledSets(const word &name, const Time &time, const dictionary &dict)
Construct from Time and dictionary.
Definition: sampledSets.C:106
virtual wordList fields() const
Return the list of fields required.
Definition: sampledSets.C:176
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: sampledSets.C:289
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: sampledSets.C:310
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: sampledSets.C:300
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
Definition: sampledSets.C:278
virtual ~sampledSets()
Destructor.
Definition: sampledSets.C:131
virtual bool execute()
Execute, currently does nothing.
Definition: sampledSets.C:182
virtual bool write()
Sample and write.
Definition: sampledSets.C:188
TypeName("sets")
Runtime type information.
virtual bool read(const dictionary &)
Read the sampledSets.
Definition: sampledSets.C:137
Writes run time, CPU time and clock time and optionally the CPU and clock times per time step.
Abstract base class for interpolation.
Definition: interpolation.H:55
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Definition: meshSearch.H:58
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:62
static List< word > fieldNames
Definition: globalFoam.H:46
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
dictionary dict