Skip to content
Snippets Groups Projects
fieldSelection.H 4.47 KiB
Newer Older
  • Learn to ignore specific revisions
  • /*---------------------------------------------------------------------------*\
      =========                 |
      \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
       \\    /   O peration     |
    
        \\  /    A nd           | Copyright (C) 2017-2019 OpenCFD Ltd.
    
         \\/     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).
    
    
    SourceFiles
        fieldSelection.C
    
    \*---------------------------------------------------------------------------*/
    
    #ifndef functionObjects_fieldSelection_H
    #define functionObjects_fieldSelection_H
    
    
    #include "fieldInfo.H"
    #include "DynamicList.H"
    
    #include "HashSet.H"
    
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    namespace Foam
    {
    
    class dictionary;
    class objectRegistry;
    
    namespace functionObjects
    {
    
    /*---------------------------------------------------------------------------*\
                           Class fieldSelection Declaration
    \*---------------------------------------------------------------------------*/
    
    class fieldSelection
    :
    
            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_;
    
    
            List<fieldInfo> selection_;
    
    
    
        // Protected Member Functions
    
            //- Add registered objects of a given type
            template<class Type>
    
            void addRegistered(DynamicList<fieldInfo>& set) const;
    
        fieldSelection
        (
            const objectRegistry& obr,
            const bool includeComponents = false
        );
    
        virtual ~fieldSelection() = default;
    
            //- Return the cuurent filters
            inline HashSet<wordRe> filters() const;
    
            inline const List<fieldInfo>& selection() const;
    
    
            inline wordHashSet selectionNames() const;
    
            //- 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);
     
    
            //- 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();
    
    
    
            //- Check that all requested fielda have been found
            virtual bool checkSelection();
    
    };
    
    
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    } // End namespace functionObjects
    } // End namespace Foam
    
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    
    #include "fieldSelectionI.H"
    
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    
    #ifdef NoRepository
        #include "fieldSelectionTemplates.C"
    #endif
    
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    #endif
    
    // ************************************************************************* //