BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / postProcessing / functionObjects / field / fieldValues / fieldValue / fieldValue.C
blob06f18f61c748842107c46f4c180582faab90b885
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "fieldValue.H"
27 #include "fvMesh.H"
28 #include "Time.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace Foam
34     defineTypeNameAndDebug(fieldValue, 0);
38 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
40 void Foam::fieldValue::updateMesh(const mapPolyMesh&)
42     // Do nothing
46 void Foam::fieldValue::movePoints(const Field<point>&)
48     // Do nothing
52 void Foam::fieldValue::makeFile()
54     // Create the output file if not already created
55     if (outputFilePtr_.empty())
56     {
57         if (debug)
58         {
59             Info<< "Creating output file." << endl;
60         }
62         // File update
63         if (Pstream::master())
64         {
65             fileName outputDir;
66             word startTimeName =
67                 obr_.time().timeName(obr_.time().startTime().value());
69             if (Pstream::parRun())
70             {
71                 // Put in undecomposed case (Note: gives problems for
72                 // distributed data running)
73                 outputDir =
74                     obr_.time().path()/".."/name_/startTimeName;
75             }
76             else
77             {
78                 outputDir = obr_.time().path()/name_/startTimeName;
79             }
81             // Create directory if does not exist
82             mkDir(outputDir);
84             // Open new file at start up
85             outputFilePtr_.reset(new OFstream(outputDir/(type() + ".dat")));
87             // Add headers to output data
88             writeFileHeader();
89         }
90     }
94 void Foam::fieldValue::read(const dictionary& dict)
96     if (active_)
97     {
98         log_ = dict.lookupOrDefault<Switch>("log", false);
99         dict.lookup("fields") >> fields_;
100         dict.lookup("valueOutput") >> valueOutput_;
101     }
105 void Foam::fieldValue::write()
107     if (active_)
108     {
109         if (log_)
110         {
111             Info<< type() << " " << name_ << " output:" << nl;
112         }
114         makeFile();
115     }
119 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
121 Foam::fieldValue::fieldValue
123     const word& name,
124     const objectRegistry& obr,
125     const dictionary& dict,
126     const bool loadFromFiles
129     name_(name),
130     obr_(obr),
131     active_(true),
132     log_(false),
133     sourceName_(dict.lookupOrDefault<word>("sourceName", "sampledSurface")),
134     fields_(dict.lookup("fields")),
135     valueOutput_(dict.lookup("valueOutput")),
136     outputFilePtr_(NULL)
138     // Only active if obr is an fvMesh
139     if (isA<fvMesh>(obr_))
140     {
141         read(dict);
142     }
143     else
144     {
145         WarningIn
146         (
147             "fieldValue::fieldValue"
148             "("
149                 "const word&, "
150                 "const objectRegistry&, "
151                 "const dictionary&, "
152                 "const bool"
153             ")"
154         )   << "No fvMesh available, deactivating."
155             << nl << endl;
156         active_ = false;
157     }
161 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
163 Foam::fieldValue::~fieldValue()
167 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
169 void Foam::fieldValue::execute()
171     // Do nothing
175 void Foam::fieldValue::end()
177     // Do nothing
181 // ************************************************************************* //