fieldCoordinateSystemTransform.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 | Copyright (C) 2011-2014 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 
27 #include "dictionary.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 defineTypeNameAndDebug(fieldCoordinateSystemTransform, 0);
34 }
35 
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
40 (
41  const word& name,
42  const objectRegistry& obr,
43  const dictionary& dict,
44  const bool loadFromFiles
45 )
46 :
47  name_(name),
48  obr_(obr),
49  active_(true),
50  fieldSet_(),
51  coordSys_(obr, dict)
52 {
53  // Check if the available mesh is an fvMesh otherise deactivate
54  if (isA<fvMesh>(obr_))
55  {
56  read(dict);
57 
58  Info<< type() << " " << name_ << ":" << nl
59  << " Applying transformation from global Cartesian to local "
60  << coordSys_ << nl << endl;
61  }
62  else
63  {
64  active_ = false;
65  WarningIn
66  (
67  "fieldCoordinateSystemTransform::fieldCoordinateSystemTransform"
68  "("
69  "const word&, "
70  "const objectRegistry&, "
71  "const dictionary&, "
72  "const bool"
73  ")"
74  ) << "No fvMesh available, deactivating " << name_
75  << endl;
76  }
77 }
78 
79 
80 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
81 
83 {}
84 
85 
86 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87 
89 {
90  if (active_)
91  {
92  dict.lookup("fields") >> fieldSet_;
93  }
94 }
95 
96 
98 {
99  if (active_)
100  {
101  Info<< type() << " " << name_ << " output:" << nl;
102 
103  forAll(fieldSet_, fieldI)
104  {
105  // If necessary load field
106  transform<scalar>(fieldSet_[fieldI]);
107  transform<vector>(fieldSet_[fieldI]);
108  transform<sphericalTensor>(fieldSet_[fieldI]);
109  transform<symmTensor>(fieldSet_[fieldI]);
110  transform<tensor>(fieldSet_[fieldI]);
111  }
112  }
113 }
114 
115 
117 {
118  if (active_)
119  {
120  execute();
121  }
122 }
123 
124 
126 {
127  // Do nothing
128 }
129 
130 
132 {
133  if (active_)
134  {
135  Info<< type() << " " << name_ << " output:" << nl;
136 
137  forAll(fieldSet_, fieldI)
138  {
139  const word fieldName = fieldSet_[fieldI] + ":Transformed";
140 
141  const regIOobject& field =
142  obr_.lookupObject<regIOobject>(fieldName);
143 
144  Info<< " writing field " << field.name() << nl;
145 
146  field.write();
147  }
148 
149  Info<< endl;
150  }
151 }
152 
153 
154 // ************************************************************************* //
fieldCoordinateSystemTransform(const fieldCoordinateSystemTransform &)
Disallow default bitwise copy construct.
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
virtual void read(const dictionary &)
Read the input data.
A class for handling words, derived from string.
Definition: word.H:59
messageStream Info
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
virtual bool write() const
Write using setting from DB.
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
#define WarningIn(functionName)
Report a warning using Foam::Warning.
#define forAll(list, i)
Definition: UList.H:421
const word & name() const
Return name.
Definition: IOobject.H:260
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:589
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
Registry of regIOobjects.
virtual void end()
Execute at the final time-loop, currently does nothing.
bool read(const char *, int32_t &)
Definition: int32IO.C:87
virtual void execute()
Execute, currently does nothing.
defineTypeNameAndDebug(combustionModel, 0)