derivedFields.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  Copyright : (C) 2011 Symscape
3  Website : www.symscape.com
4 -------------------------------------------------------------------------------
5 License
6  This file is part of OpenFOAM.
7 
8  OpenFOAM is free software: you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
14  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16  for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
20 
21 \*---------------------------------------------------------------------------*/
22 
23 #include "derivedFields.H"
24 #include "machWriter.H"
25 #include "yPlusWriter.H"
26 #include "vorticityWriter.H"
27 #include "wallHeatFluxWriter.H"
28 #include "wallShearStressWriter.H"
29 #include "dictionary.H"
30 #include "Time.H"
31 #include "PtrList.H"
32 #include "fvMesh.H"
33 
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39  defineTypeNameAndDebug(derivedFields, 0);
40 }
41 
42 
43 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 
45 inline
47 {
48  if (0 != writer)
49  {
50  const label id = writers_->size();
51 
52  writers_->setSize(id + 1);
53  writers_->set(id, writer);
54  }
55 }
56 
57 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
58 
60  const objectRegistry& obr,
61  const dictionary& dict,
62  const bool loadFromFiles)
63  : writers_(new PtrList<derivedFieldWriter>),
64  name_(name),
65  obr_(obr)
66 {
67  read(dict);
68 }
69 
70 
72 {
73  delete writers_;
74 }
75 
76 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
77 
78 
80 {
81  writers_->clear();
82 
83  // Check if the available mesh is an fvMesh otherise deactivate
84  if (!isA<fvMesh>(obr_))
85  {
86  WarningIn
87  (
88  "derivedFields::derivedFields(const objectRegistry& obr, const dictionary& dict)"
89  ) << "No fvMesh available, deactivating."
90  << endl;
91  }
92  else
93  {
94  addWriter(derivedFieldWriter::read<machWriter>(dict));
95  addWriter(derivedFieldWriter::read<vorticityWriter>(dict));
96  addWriter(derivedFieldWriter::read<wallHeatFluxWriter>(dict));
97  addWriter(derivedFieldWriter::read<wallShearStressWriter>(dict));
98  addWriter(derivedFieldWriter::read<yPlusWriter>(dict));
99 
100  Switch writeOnStart(dict.lookupOrDefault<Switch>("writeOnStart", false));
101 
102  if (writeOnStart)
103  {
104  write();
105  }
106  }
107 }
108 
109 
111 {
112  forAll(*writers_, i)
113  {
114  (*writers_)[i].write(obr_);
115  }
116 }
117 
118 // ************************************************************************* //
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::dictionary::lookupOrDefault
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Definition: dictionaryTemplates.C:33
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::derivedFields::writers_
PtrList< derivedFieldWriter > *const writers_
Active writers, if any.
Definition: derivedFields.H:112
wallShearStressWriter.H
Foam::derivedFields::derivedFields
derivedFields(const derivedFields &)
Disallow default bitwise copy construct.
vorticityWriter.H
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
yPlusWriter.H
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
machWriter.H
Foam::derivedFieldWriter
Basis for writers used in derivedFields e.g., wallShearStressWriter.
Definition: derivedFieldWriter.H:49
derivedFields.H
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
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::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:78
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::derivedFields::addWriter
void addWriter(derivedFieldWriter *writer)
Add writer to active list.
Definition: derivedFields.C:46
wallHeatFluxWriter.H
dictionary.H
PtrList.H
WarningIn
#define WarningIn(functionName)
Report a warning using Foam::Warning.
Definition: messageStream.H:254
Foam::derivedFields::read
void read(const dictionary &dict)
Read the derivedFields data.
Definition: derivedFields.C:79
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::derivedFields::write
void write()
Calculate the derivedFields and write.
Definition: derivedFields.C:110
write
Tcoeff write()
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::derivedFields::~derivedFields
virtual ~derivedFields()
Definition: derivedFields.C:71