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 functionObjects_fieldSelection_H
43#define functionObjects_fieldSelection_H
44
45#include "fieldInfo.H"
46#include "DynamicList.H"
47#include "HashSet.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
53
54class dictionary;
55class objectRegistry;
56
57namespace functionObjects
58{
59
60/*---------------------------------------------------------------------------*\
61 Class fieldSelection Declaration
62\*---------------------------------------------------------------------------*/
65:
66 public List<fieldInfo>
67{
68private:
69
70 // Private Member Functions
71
72 //- No copy construct
73 fieldSelection(const fieldSelection&) = delete;
74
75
76protected:
77
78 // Protected member data
79
80 //- Reference to the database
81 const objectRegistry& obr_;
82
83 //- Flag to indicate whether components are allowed
84 const bool includeComponents_;
85
86 //- Current field selection
88
89
90 // Protected Member Functions
91
92 //- Add registered objects of a given type
93 template<class Type>
95
96
97public:
98
99 //- Construct from object registry
101 (
102 const objectRegistry& obr,
103 const bool includeComponents = false
104 );
105
106
107 //- Destructor
108 virtual ~fieldSelection() = default;
109
110
111 // Member Functions
112
113 //- Return the cuurent filters
114 inline HashSet<wordRe> filters() const;
115
116 inline const List<fieldInfo>& selection() const;
117
118 //- Return the current field selection
119 inline wordHashSet selectionNames() const;
120
121 //- Reset the field filters to the given field names
122 virtual bool resetFieldFilters(const HashSet<wordRe>& names);
123
124 //- Reset the field filters to the given field name
125 virtual bool resetFieldFilters(const wordRe& name);
126
127 //- Read the fieldSelection data from dictionary
128 virtual bool read(const dictionary& dict);
129
130 //- Return whether the field names contain a pattern
131 virtual bool containsPattern() const;
132
133 //- Clear the current selection
134 virtual void clearSelection();
135
136 //- Update the selection
137 virtual bool updateSelection();
138
139 //- Check that all requested fielda have been found
140 virtual bool checkSelection();
141};
142
143
144// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145
146} // End namespace functionObjects
147} // End namespace Foam
148
149// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150
151#include "fieldSelectionI.H"
152
153// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154
155#ifdef NoRepository
157#endif
158
159// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160
161#endif
162
163// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
A HashTable with keys but without contents that is similar to std::unordered_set.
Definition: HashSet.H:96
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
Definition: List.H:330
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Helper class to manage field selections.
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.
const List< fieldInfo > & selection() const
virtual bool read(const dictionary &dict)
Read the fieldSelection data from dictionary.
wordHashSet selectionNames() const
Return the current field selection.
virtual bool resetFieldFilters(const HashSet< wordRe > &names)
Reset the field filters to the given field names.
HashSet< wordRe > filters() const
Return the cuurent 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.
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:83
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
dictionary dict