components.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) 2016 OpenFOAM Foundation
9  Copyright (C) 2019-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::functionObjects::components
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Extracts the components of elements of a field and outputs the result
35  into new fields, where the fields possess the same sizes and dimensions.
36 
37  Depending on the base type of the input field, the number of output fields
38  and output suffixes are as follows (the base type cannot be scalar since
39  scalars have no components):
40 
41  \table
42  Base type | Number of components | Suffixes
43  vector | 3 | (x y z)
44  sphericalTensor | 3 | (x y z)
45  symmTensor | 6 | (xx xy xz yy yz zz)
46  tensor | 9 | (xx xy xz yx yy yz zx zy zz)
47  \endtable
48 
49  Operands:
50  \table
51  Operand | Type | Location
52  input | {vol,surface}<Type>Field (Type != Scalar) <!--
53  --> | $FOAM_CASE/<time>/<inpField>
54  output file | - | -
55  output field | {vol,surface}ScalarField for each component <!--
56  --> | $FOAM_CASE/<time>/<outField><suffix>
57  \endtable
58 
59  where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
60 
61 Usage
62  Minimal example by using \c system/controlDict.functions:
63  \verbatim
64  components1
65  {
66  // Mandatory entries (unmodifiable)
67  type components;
68  libs (fieldFunctionObjects);
69 
70  // Mandatory (inherited) entry (runtime modifiable)
71  field <field>;
72 
73  // Optional (inherited) entries
74  ...
75  }
76  \endverbatim
77 
78  where the entries mean:
79  \table
80  Property | Description | Type | Req'd | Dflt
81  type | Type name: components | word | yes | -
82  libs | Library name: fieldFunctionObjects | word | yes | -
83  field | Name of the operand field | word | yes | -
84  \endtable
85 
86  The inherited entries are elaborated in:
87  - \link functionObject.H \endlink
88  - \link fieldExpression.H \endlink
89 
90  Minimal example by using the \c postProcess utility:
91  \verbatim
92  postProcess -func "components(<field>)"
93  \endverbatim
94 
95 See also
96  - Foam::functionObject
97  - Foam::functionObjects::fvMeshFunctionObject
98  - ExtendedCodeGuide::functionObjects::field::components
99 
100 SourceFiles
101  components.C
102  componentsTemplates.C
103 
104 \*---------------------------------------------------------------------------*/
105 
106 #ifndef functionObjects_components_H
107 #define functionObjects_components_H
108 
109 #include "fieldExpression.H"
110 
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 
113 namespace Foam
114 {
115 namespace functionObjects
116 {
117 
118 /*---------------------------------------------------------------------------*\
119  Class components Declaration
120 \*---------------------------------------------------------------------------*/
121 
122 class components
123 :
124  public fieldExpression
125 {
126  // Private Member Data
127 
128  //- List of the component field names
129  wordList resultNames_;
130 
131 
132  // Private Member Functions
133 
134  //- Calculate the components of the field with the specified type
135  //- and register the result
136  template<class GeoFieldType>
137  bool calcFieldComponents();
138 
139  //- Calculate the components of the field with the specified
140  //- element type and register the result
141  template<class Type>
142  bool calcComponents();
143 
144  //- Calculate the components of the field and return true if successful
145  virtual bool calc();
146 
147 
148 public:
149 
150  //- Runtime type information
151  TypeName("components");
152 
153 
154  // Constructors
155 
156  //- Construct from Time and dictionary
157  components
158  (
159  const word& name,
160  const Time& runTime,
161  const dictionary& dict
162  );
163 
164  //- No copy construct
165  components(const components&) = delete;
166 
167  //- No copy assignment
168  void operator=(const components&) = delete;
169 
170 
171  //- Destructor
172  virtual ~components() = default;
173 
174 
175  // Member Functions
176 
177  //- Write the component fields
178  virtual bool write();
179 
180  //- Clear the component fields from the objectRegistry
181  virtual bool clear();
182 };
183 
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 } // End namespace functionObjects
188 } // End namespace Foam
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 #ifdef NoRepository
193  #include "componentsTemplates.C"
194 #endif
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 #endif
199 
200 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::functionObjects::components::~components
virtual ~components()=default
Destructor.
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::components::clear
virtual bool clear()
Clear the component fields from the objectRegistry.
Definition: components.C:87
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
Foam::functionObjects::components::components
components(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: components.C:62
Foam::functionObjects::components::operator=
void operator=(const components &)=delete
No copy assignment.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::components::write
virtual bool write()
Write the component fields.
Definition: components.C:74
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::fieldExpression
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
Definition: fieldExpression.H:120
Foam::functionObjects::components::TypeName
TypeName("components")
Runtime type information.
Foam::List< word >
fieldExpression.H
componentsTemplates.C
Foam::functionObjects::components
Extracts the components of elements of a field and outputs the result into new fields,...
Definition: components.H:185