componentsTemplates.C
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 \*---------------------------------------------------------------------------*/
28 
29 #include "volFields.H"
30 #include "surfaceFields.H"
31 
32 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
33 
34 template<class GeoFieldType>
35 bool Foam::functionObjects::components::calcFieldComponents()
36 {
37  typedef typename GeoFieldType::value_type Type;
38 
39  const GeoFieldType& field = lookupObject<GeoFieldType>(fieldName_);
40 
41  resultNames_.setSize(Type::nComponents);
42 
43  bool stored = true;
44 
45  for (direction i = 0; i < Type::nComponents; ++i)
46  {
47  resultName_ = fieldName_ + word(Type::componentNames[i]);
48  resultNames_[i] = resultName_;
49 
50  stored = stored && store(resultName_, field.component(i));
51  }
52 
53  return stored;
54 }
55 
56 
57 template<class Type>
58 bool Foam::functionObjects::components::calcComponents()
59 {
60  typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
61  typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
62 
63  if (foundObject<VolFieldType>(fieldName_, false))
64  {
65  return calcFieldComponents<VolFieldType>();
66  }
67  else if (foundObject<SurfaceFieldType>(fieldName_, false))
68  {
69  return calcFieldComponents<SurfaceFieldType>();
70  }
71 
72  return false;
73 }
74 
75 
76 // ************************************************************************* //
volFields.H
surfaceFields.H
Foam::surfaceFields.
Foam::functionObjects::regionFunctionObject::store
bool store(word &fieldName, const tmp< ObjectType > &tfield, bool cacheable=false)
Store the field in the (sub) objectRegistry under the given name.
Definition: regionFunctionObjectTemplates.C:107
Foam::List::setSize
void setSize(const label n)
Alias for resize()
Definition: List.H:222
field
rDeltaTY field()
Foam::functionObjects::fieldExpression::fieldName_
word fieldName_
Name of field to process.
Definition: fieldExpression.H:129
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::functionObjects::fieldExpression::resultName_
word resultName_
Name of result field.
Definition: fieldExpression.H:132