Newer
Older
Andrew Heather
committed
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
Andrew Heather
committed
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::functionObjects::fieldSelection
Description
Helper class to manage field selections
The class holds a list of field name filters which are then applied to a
set of field objects (in derived classes) from which the resulting set is
available via the selection() function. This returns a list of
(fieldName, component) objects, e.g. for U.component(0) this is (U, 0).
Andrew Heather
committed
SourceFiles
fieldSelection.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_fieldSelection_H
#define functionObjects_fieldSelection_H
#include "fieldInfo.H"
#include "DynamicList.H"
Andrew Heather
committed
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class dictionary;
class objectRegistry;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class fieldSelection Declaration
\*---------------------------------------------------------------------------*/
class fieldSelection
:
public List<fieldInfo>
Andrew Heather
committed
{
private:
// Private Member Functions
//- No copy construct
Andrew Heather
committed
fieldSelection(const fieldSelection&) = delete;
protected:
// Protected member data
//- Reference to the database
const objectRegistry& obr_;
//- Flag to indicate whether components are allowed
const bool includeComponents_;
Andrew Heather
committed
//- Current field selection
List<fieldInfo> selection_;
Andrew Heather
committed
// Protected Member Functions
//- Add registered objects of a given type
template<class Type>
void addRegistered(DynamicList<fieldInfo>& set) const;
Andrew Heather
committed
public:
//- Construct from object registry
fieldSelection
(
const objectRegistry& obr,
const bool includeComponents = false
);
Andrew Heather
committed
//- Destructor
virtual ~fieldSelection() = default;
Andrew Heather
committed
// Member Functions
//- Return the cuurent filters
inline HashSet<wordRe> filters() const;
inline const List<fieldInfo>& selection() const;
Andrew Heather
committed
//- Return the current field selection
inline wordHashSet selectionNames() const;
Andrew Heather
committed
//- Reset the field filters to the given field names
virtual bool resetFieldFilters(const HashSet<wordRe>& names);
//- Reset the field filters to the given field name
virtual bool resetFieldFilters(const wordRe& name);
Andrew Heather
committed
//- Read the fieldSelection data from dictionary
virtual bool read(const dictionary& dict);
//- Return whether the field names contain a pattern
virtual bool containsPattern() const;
//- Clear the current selection
virtual void clearSelection();
//- Update the selection
Andrew Heather
committed
virtual bool updateSelection();
//- Check that all requested fielda have been found
virtual bool checkSelection();
Andrew Heather
committed
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "fieldSelectionI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Andrew Heather
committed
#ifdef NoRepository
#include "fieldSelectionTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //