Loading...
Searching...
No Matches
fieldSelection.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) 2017-2019 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::functionObjects::fieldSelection
28
29Description
30 Helper class to manage field selections
31
32 The class holds a list of field name filters which are then applied to a
33 set of field objects (in derived classes) from which the resulting set is
34 available via the selection() function. This returns a list of
35 (fieldName, component) objects, e.g. for U.component(0) this is (U, 0).
36
37SourceFiles
38 fieldSelection.C
39
40\*---------------------------------------------------------------------------*/
41
42#ifndef Foam_functionObjects_fieldSelection_H
43#define Foam_functionObjects_fieldSelection_H
44
45#include "fieldInfo.H"
46#include "DynamicList.H"
47#include "HashSet.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
53
54// Forward Declarations
55class dictionary;
56class objectRegistry;
57
58namespace functionObjects
59{
61/*---------------------------------------------------------------------------*\
62 Class fieldSelection Declaration
63\*---------------------------------------------------------------------------*/
64
65class fieldSelection
66:
67 public List<fieldInfo>
68{
69 // Private Member Functions
70
71 //- Reset the field filters to the given field names
72 template<class Container>
73 bool resetFieldFiltersImpl(const Container& names);
74
75 //- No copy construct
76 fieldSelection(const fieldSelection&) = delete;
77
78
79protected:
80
81 // Protected Member Data
82
83 //- Reference to the database
84 const objectRegistry& obr_;
86 //- Flag to indicate whether components are allowed
87 const bool includeComponents_;
88
89 //- Current field selection
90 List<fieldInfo> selection_;
91
92
93 // Protected Member Functions
94
95 //- Add registered objects of a given type
96 template<class Type>
98
99
100public:
101
102 //- Construct from object registry
103 explicit fieldSelection
104 (
105 const objectRegistry& obr,
106 const bool includeComponents = false
107 );
108
109
110 //- Destructor
111 virtual ~fieldSelection() = default;
112
113
114 // Member Functions
115
116 //- The current field selection
117 const List<fieldInfo>& selection() const noexcept
118 {
119 return selection_;
120 }
121
122 //- Return the current filters
123 inline HashSet<wordRe> filters() const;
124
125 //- Return the current field selection, in sorted order
126 inline wordList selectionNames() const;
127
128 //- Reset the field filters to the given field names
129 virtual bool resetFieldFilters(const HashSet<wordRe>& names);
131 //- Reset the field filters to the given field name
132 virtual bool resetFieldFilters(const wordRe& name);
133
134 //- Read the fieldSelection data from dictionary
135 virtual bool read(const dictionary& dict);
136
137 //- Return whether the field names contain a pattern
138 virtual bool containsPattern() const;
139
140 //- Clear the current selection
141 virtual void clearSelection();
142
143 //- Update the selection
144 virtual bool updateSelection();
145
146 //- Check that all requested fielda have been found
147 virtual bool checkSelection();
148};
149
150
151// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152
153} // End namespace functionObjects
154} // End namespace Foam
155
156// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157
158#include "fieldSelectionI.H"
159
160// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161
162#ifdef NoRepository
164#endif
165
166// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167
168#endif
169
170// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
A HashTable with keys but without contents that is similar to std::unordered_set.
Definition HashSet.H:96
bool set(const label i, bool val=true)
Definition List.H:469
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const List< fieldInfo > & selection() const noexcept
The current field selection.
virtual bool updateSelection()
Update the selection.
virtual bool containsPattern() const
Return whether the field names contain a pattern.
virtual bool checkSelection()
Check that all requested fielda have been found.
const objectRegistry & obr_
Reference to the database.
const bool includeComponents_
Flag to indicate whether components are allowed.
virtual bool read(const dictionary &dict)
Read the fieldSelection data from dictionary.
virtual bool resetFieldFilters(const HashSet< wordRe > &names)
Reset the field filters to the given field names.
HashSet< wordRe > filters() const
Return the current filters.
virtual ~fieldSelection()=default
Destructor.
virtual void clearSelection()
Clear the current selection.
void addRegistered(DynamicList< fieldInfo > &set) const
Add registered objects of a given type.
wordList selectionNames() const
Return the current field selection, in sorted order.
List< fieldInfo > selection_
Current field selection.
Registry of regIOobjects.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition wordRe.H:81
auto & names
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
const direction noexcept
Definition scalarImpl.H:265
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
dictionary dict