fieldCoordinateSystemTransform.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace functionObjects
34 {
35  defineTypeNameAndDebug(fieldCoordinateSystemTransform, 0);
36 
38  (
39  functionObject,
40  fieldCoordinateSystemTransform,
41  dictionary
42  );
43 }
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
51 (
52  const word& name,
53  const Time& runTime,
54  const dictionary& dict
55 )
56 :
57  fvMeshFunctionObject(name, runTime, dict),
58  fieldSet_(),
59  coordSys_(coordinateSystem::New(mesh_, dict.subDict("coordinateSystem"))())
60 {
61  read(dict);
62 
63  Log << type() << " " << name << ":" << nl
64  << " Applying transformation from global Cartesian to local "
65  << coordSys_ << nl << endl;
66 }
67 
68 
69 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
70 
73 {}
74 
75 
76 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
77 
80 (
81  const word& fieldName
82 ) const
83 {
84  return fieldName + ":Transformed";
85 }
86 
87 
89 (
90  const dictionary& dict
91 )
92 {
94 
95  dict.lookup("fields") >> fieldSet_;
96 
97  return true;
98 }
99 
100 
102 {
103  forAll(fieldSet_, fieldi)
104  {
105  transform<scalar>(fieldSet_[fieldi]);
106  transform<vector>(fieldSet_[fieldi]);
107  transform<sphericalTensor>(fieldSet_[fieldi]);
108  transform<symmTensor>(fieldSet_[fieldi]);
109  transform<tensor>(fieldSet_[fieldi]);
110  }
111 
112  return true;
113 }
114 
115 
117 {
118  forAll(fieldSet_, fieldi)
119  {
120  writeObject(transformFieldName(fieldSet_[fieldi]));
121  }
122 
123  return true;
124 }
125 
126 
127 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
addToRunTimeSelectionTable(functionObject, Qdot, dictionary)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Macros for easy insertion into run-time selection tables.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:982
virtual bool read(const dictionary &)
Read optional controls.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
A class for handling words, derived from string.
Definition: word.H:59
virtual bool read(const dictionary &)
Read the input data.
static const char nl
Definition: Ostream.H:260
defineTypeNameAndDebug(Qdot, 0)
static autoPtr< coordinateSystem > New(const objectRegistry &obr, const dictionary &dict)
Select constructed from dictionary and objectRegistry.
word transformFieldName(const word &fieldName) const
Return the name of the transformed field.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
#define Log
Report write to Foam::Info if the local log switch is true.
virtual bool execute()
Calculate the transformed fields.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
fieldCoordinateSystemTransform(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844