Skip to content
Snippets Groups Projects
multiFieldValue.H 6.33 KiB
Newer Older
  • Learn to ignore specific revisions
  • /*---------------------------------------------------------------------------*\
      =========                 |
      \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
       \\    /   O peration     |
    
    OpenFOAM bot's avatar
    OpenFOAM bot committed
        \\  /    A nd           | www.openfoam.com
    
         \\/     M anipulation  |
    -------------------------------------------------------------------------------
    
        Copyright (C) 2021 OpenCFD Ltd.
    
    -------------------------------------------------------------------------------
    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::fieldValues::multiFieldValue
    
        Computes a selected operation between multiple \c fieldValue function
        objects.
    
        The operation is applied to all results of each \c fieldValue object.
    
    
    Note
        Each object must generate the same number and type of results.
    
        Minimal example by using \c system/controlDict.functions:
    
        multiFieldValue1
    
            // Mandatory entries (unmodifiable)
    
            type    multiFieldValue;
            libs    (fieldFunctionObjects);
    
            // Mandatory entries (runtime modifiable)
    
            operation   average;
    
            // List of fieldValue function objects as dictionaries
            functions
    
    
            // Optional (inherited) entries
            ...
    
        where the entries mean:
    
          Property     | Description                         | Type | Req'd | Dflt
          type         | Type name: multiFieldValue          | word |  yes  | -
          libs         | Library name: fieldFunctionObjects  | word |  yes  | -
          operation    | Operation type to apply to values   | word |  yes  | -
          functions    | List of fieldValue function objects | dict |  yes  | -
    
        Options for the \c operation entry:
    
        \plaintable
           add           | add
           subtract      | subtract
           min           | minimum
           max           | maximum
           average       | average
        \endplaintable
    
        The inherited entries are elaborated in:
         - \link fieldValue.H \endlink
    
        Usage by the \c postProcess utility is not available.
    
    
        - Foam::functionObject
        - Foam::functionObjects::fieldValue
    
        - ExtendedCodeGuide::functionObjects::field::multiFieldValue
    
        multiFieldValue.C
        multiFieldValueTemplates.C
    
    
    \*---------------------------------------------------------------------------*/
    
    
    #ifndef functionObjects_multiFieldValue_H
    #define functionObjects_multiFieldValue_H
    
    #include "stateFunctionObject.H"
    #include "writeFile.H"
    
    
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    namespace Foam
    {
    
    namespace fieldValues
    {
    
    /*---------------------------------------------------------------------------*\
    
                           Class multiFieldValue Declaration
    
    \*---------------------------------------------------------------------------*/
    
    
    class multiFieldValue
    
        public functionObjects::stateFunctionObject,
        public functionObjects::writeFile
    
            //- Operation type enumeration
            enum operationType
            {
    
                opSum,              //!< Sum of values
                opAdd,              //!< Add values (same as sum)
                opSubtract,         //!< Subtract values from first entry
                opMin,              //!< Minimum value
                opMax,              //!< Maximum value
                opAverage           //!< Average value
    
            static const Enum<operationType> operationTypeNames_;
    
            //- Operation to apply to values
            operationType operation_;
    
    
            //- List of fieldValue function objects
            PtrList<fieldValue> functions_;
    
            //- Templated function to apply the operation.
            //  \return true if Type and resultType are correct
    
            bool applyOperation
    
                const wordList& names,
                const wordList& entryNames
    
    
            //- Output file header information
    
            virtual void writeFileHeader(Ostream& os) const;
    
        TypeName("multiFieldValue");
    
            //- Construct from Time and dictionary
    
            multiFieldValue
    
                const Time& runTime,
                const dictionary& dict
    
            //- No copy construct
    
            multiFieldValue(const multiFieldValue&) = delete;
    
            void operator=(const multiFieldValue&) = delete;
    
        virtual ~multiFieldValue() = default;
    
            virtual bool read(const dictionary& dict);
    
    };
    
    
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    } // End namespace fieldValues
    
    } // End namespace Foam
    
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    #ifdef NoRepository
    
        #include "multiFieldValueTemplates.C"
    
    #endif
    
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    #endif
    
    // ************************************************************************* //