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-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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  log_(true)
53 {
54  // Check if the available mesh is an fvMesh otherise deactivate
55  if (isA<fvMesh>(obr_))
56  {
57  read(dict);
58 
59  if (log_) Info
60  << type() << " " << name_ << ":" << nl
61  << " Applying transformation from global Cartesian to local "
62  << coordSys_ << nl << endl;
63  }
64  else
65  {
66  active_ = false;
68  << "No fvMesh available, deactivating " << name_
69  << endl;
70  }
71 }
72 
73 
74 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
75 
77 {}
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
83 {
84  if (active_)
85  {
86  log_.readIfPresent("log", dict);
87  dict.lookup("fields") >> fieldSet_;
88  }
89 }
90 
91 
93 {
94  if (active_)
95  {
96  if (log_) Info<< type() << " " << name_ << " output:" << nl;
97 
98  forAll(fieldSet_, fieldI)
99  {
100  // If necessary load field
101  transform<scalar>(fieldSet_[fieldI]);
102  transform<vector>(fieldSet_[fieldI]);
103  transform<sphericalTensor>(fieldSet_[fieldI]);
104  transform<symmTensor>(fieldSet_[fieldI]);
105  transform<tensor>(fieldSet_[fieldI]);
106  }
107  }
108 }
109 
110 
112 {
113  // Do nothing
114 }
115 
116 
118 {
119  // Do nothing
120 }
121 
122 
124 {
125  if (active_)
126  {
127  if (log_) Info<< type() << " " << name_ << " output:" << nl;
128 
129  forAll(fieldSet_, fieldI)
130  {
131  const word fieldName = fieldSet_[fieldI] + ":Transformed";
132 
133  const regIOobject& field =
134  obr_.lookupObject<regIOobject>(fieldName);
135 
136  if (log_) Info << " writing field " << field.name() << nl;
137 
138  field.write();
139  }
140 
141  if (log_) Info<< endl;
142  }
143 }
144 
145 
146 // ************************************************************************* //
fieldCoordinateSystemTransform.H
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fieldCoordinateSystemTransform::fieldCoordinateSystemTransform
fieldCoordinateSystemTransform(const fieldCoordinateSystemTransform &)
Disallow default bitwise copy construct.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::regIOobject::write
virtual bool write() const
Write using setting from DB.
Definition: regIOobjectWrite.C:126
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::fieldCoordinateSystemTransform::write
virtual void write()
Write.
Definition: fieldCoordinateSystemTransform.C:123
Foam::fieldCoordinateSystemTransform::read
virtual void read(const dictionary &)
Read the input data.
Definition: fieldCoordinateSystemTransform.C:82
Foam::fieldCoordinateSystemTransform::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: fieldCoordinateSystemTransform.C:111
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobject.H:273
Foam::fieldCoordinateSystemTransform::~fieldCoordinateSystemTransform
virtual ~fieldCoordinateSystemTransform()
Destructor.
Definition: fieldCoordinateSystemTransform.C:76
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
dictionary.H
Foam::fieldCoordinateSystemTransform::execute
virtual void execute()
Execute, currently does nothing.
Definition: fieldCoordinateSystemTransform.C:92
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::fieldCoordinateSystemTransform::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: fieldCoordinateSystemTransform.C:117