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-2024 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  //- Output path
75  fileName outputPath_;
76 
77  //- Mesh search engine
78  meshSearch searchEngine_;
79 
80 
81  // Read from dictionary
82 
83  //- Names of fields to sample
84  wordList fields_;
85 
86  //- Interpolation scheme to use
87  word interpolationScheme_;
88 
89 
90  // Merging structures
91 
92  //- Global sets gathered on the master
93  PtrList<coordSet> masterSets_;
94 
95  //- Mapping from local to global sets
96  labelListList masterSetOrders_;
97 
98 
99  // Calculated
100 
101  //- Set formatter
102  autoPtr<setWriter> formatter_;
103 
104 
105  // Private Member Functions
106 
107  //- Combine sets on all processors. Sort by curveDist and produce
108  // index list. Valid result only on master processor.
109  void combineSampledSets();
110 
111  //- Sample all fields of a type on a given set
112  template<class Type>
113  PtrList<Field<Type>> sampleLocalType
114  (
115  const label seti,
116  const wordList& fieldNames,
117  HashPtrTable<interpolation<Type>>& interpolations
118  );
119 
120  //- Sample all fields of a type on a given set and combine on the
121  // master for writing
122  template<class Type>
123  PtrList<Field<Type>> sampleType
124  (
125  const label seti,
126  const wordList& fieldNames,
127  HashPtrTable<interpolation<Type>>& interpolations
128  );
129 
130 
131 public:
132 
133  //- Runtime type information
134  TypeName("sets");
135 
136 
137  // Constructors
138 
139  //- Construct from Time and dictionary
141  (
142  const word& name,
143  const Time& time,
144  const dictionary& dict
145  );
146 
147  //- Disallow default bitwise copy construction
148  sampledSets(const sampledSets&) = delete;
149 
150 
151  //- Destructor
152  virtual ~sampledSets();
153 
154 
155  // Member Functions
156 
157  //- Read the sampledSets
158  virtual bool read(const dictionary&);
159 
160  //- Return the list of fields required
161  virtual wordList fields() const;
162 
163  //- Execute, currently does nothing
164  virtual bool execute();
165 
166  //- Sample and write
167  virtual bool write();
168 
169  //- Update for mesh point-motion
170  virtual void movePoints(const polyMesh&);
171 
172  //- Update topology using the given map
173  virtual void topoChange(const polyTopoChangeMap&);
174 
175  //- Update from another mesh using the given map
176  virtual void mapMesh(const polyMeshMap&);
177 
178  //- Redistribute or update using the given distribution map
179  virtual void distribute(const polyDistributionMap&);
180 
181 
182  // Member Operators
183 
184  //- Disallow default bitwise assignment
185  void operator=(const sampledSets&) = delete;
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace functionObjects
192 } // End namespace Foam
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 #ifdef NoRepository
197  #include "sampledSetsTemplates.C"
198 #endif
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #endif
203 
204 // ************************************************************************* //
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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:88
virtual wordList fields() const
Return the list of fields required.
Definition: sampledSets.C:183
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: sampledSets.C:308
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: sampledSets.C:355
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: sampledSets.C:332
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
Definition: sampledSets.C:285
virtual ~sampledSets()
Destructor.
Definition: sampledSets.C:113
virtual bool execute()
Execute, currently does nothing.
Definition: sampledSets.C:189
virtual bool write()
Sample and write.
Definition: sampledSets.C:195
TypeName("sets")
Runtime type information.
virtual bool read(const dictionary &)
Read the sampledSets.
Definition: sampledSets.C:119
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