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-2025 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 "interpolation.H"
43 #include "coordSet.H"
44 #include "setWriter.H"
45 #include "wordReList.H"
46 #include "HashPtrTable.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declaration of classes
54 class Time;
55 class objectRegistry;
56 class dictionary;
57 class fvMesh;
58 
59 namespace functionObjects
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class sampledSets Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class sampledSets
67 :
68  public fvMeshFunctionObject,
69  public PtrList<sampledSet>
70 {
71  // Private Data
72 
73  //- Output path
74  fileName outputPath_;
75 
76  // Read from dictionary
77 
78  //- Names of fields to sample
79  wordList fields_;
80 
81  //- Interpolation scheme to use
82  word interpolationScheme_;
83 
84 
85  // Merging structures
86 
87  //- Global sets gathered on the master
88  PtrList<coordSet> masterSets_;
89 
90  //- Mapping from local to global sets
91  labelListList masterSetOrders_;
92 
93 
94  // Calculated
95 
96  //- Set formatter
97  autoPtr<setWriter> formatter_;
98 
99 
100  // Private Member Functions
101 
102  //- Combine sets on all processors. Sort by curveDist and produce
103  // index list. Valid result only on master processor.
104  void updateMasterSets();
105 
106  //- Sample all fields of a type on a given set
107  template<class Type>
108  PtrList<Field<Type>> sampleLocalType
109  (
110  const label seti,
111  const wordList& fieldNames,
112  HashPtrTable<interpolation<Type>>& interpolations
113  );
114 
115  //- Sample all fields of a type on a given set and combine on the
116  // master for writing
117  template<class Type>
118  PtrList<Field<Type>> sampleType
119  (
120  const label seti,
121  const wordList& fieldNames,
122  HashPtrTable<interpolation<Type>>& interpolations
123  );
124 
125 
126 public:
127 
128  //- Runtime type information
129  TypeName("sets");
130 
131 
132  // Constructors
133 
134  //- Construct from Time and dictionary
136  (
137  const word& name,
138  const Time& time,
139  const dictionary& dict
140  );
141 
142  //- Disallow default bitwise copy construction
143  sampledSets(const sampledSets&) = delete;
144 
145 
146  //- Destructor
147  virtual ~sampledSets();
148 
149 
150  // Member Functions
151 
152  //- Read the sampledSets
153  virtual bool read(const dictionary&);
154 
155  //- Return the list of fields required
156  virtual wordList fields() const;
157 
158  //- Execute, currently does nothing
159  virtual bool execute();
160 
161  //- Sample and write
162  virtual bool write();
163 
164  //- Update for mesh point-motion
165  virtual void movePoints(const polyMesh&);
166 
167  //- Update topology using the given map
168  virtual void topoChange(const polyTopoChangeMap&);
169 
170  //- Update from another mesh using the given map
171  virtual void mapMesh(const polyMeshMap&);
172 
173  //- Redistribute or update using the given distribution map
174  virtual void distribute(const polyDistributionMap&);
175 
176 
177  // Member Operators
178 
179  //- Disallow default bitwise assignment
180  void operator=(const sampledSets&) = delete;
181 };
182 
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 } // End namespace functionObjects
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #ifdef NoRepository
192  #include "sampledSetsTemplates.C"
193 #endif
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #endif
198 
199 // ************************************************************************* //
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:68
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:175
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: sampledSets.C:295
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: sampledSets.C:328
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: sampledSets.C:312
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
Definition: sampledSets.C:279
virtual ~sampledSets()
Destructor.
Definition: sampledSets.C:112
virtual bool execute()
Execute, currently does nothing.
Definition: sampledSets.C:181
virtual bool write()
Sample and write.
Definition: sampledSets.C:187
TypeName("sets")
Runtime type information.
virtual bool read(const dictionary &)
Read the sampledSets.
Definition: sampledSets.C:118
Writes run time, CPU time and clock time and optionally the CPU and clock times per time step.
Abstract base class for interpolation.
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:78
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:63
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