rawSetWriter.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "rawSetWriter.H"
30 #include "coordSet.H"
31 #include "fileName.H"
32 #include "OFstream.H"
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
36 template<class Type>
38 :
39  writer<Type>()
40 {}
41 
42 
43 template<class Type>
45 :
46  writer<Type>(dict)
47 {}
48 
49 
50 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
51 
52 template<class Type>
54 (
55  const coordSet& points,
56  const wordList& valueSetNames
57 ) const
58 {
59  return this->getBaseName(points, valueSetNames) + ".xy";
60 }
61 
62 
63 template<class Type>
65 (
66  const coordSet& points,
67  const wordList& valueSetNames,
68  const List<const Field<Type>*>& valueSets,
69  Ostream& os
70 ) const
71 {
72  // Collect sets into columns
73  List<const List<Type>*> columns(valueSets.size());
74 
75  forAll(valueSets, i)
76  {
77  columns[i] = valueSets[i];
78  }
79 
80  this->writeTable(points, columns, os);
81 }
82 
83 
84 template<class Type>
86 (
87  const bool writeTracks,
88  const List<scalarField>& times,
89  const PtrList<coordSet>& tracks,
90  const wordList& valueSetNames,
91  const List<List<Field<Type>>>& valueSets,
92  Ostream& os
93 ) const
94 {
95  if (valueSets.size() != valueSetNames.size())
96  {
98  << "Number of variables:" << valueSetNames.size() << endl
99  << "Number of valueSets:" << valueSets.size()
100  << exit(FatalError);
101  }
102 
103  List<const List<Type>*> columns(valueSets.size());
104 
105  forAll(tracks, trackI)
106  {
107  // Collect sets into columns
108  forAll(valueSets, i)
109  {
110  columns[i] = &valueSets[i][trackI];
111  }
112 
113  this->writeTable(tracks[trackI], columns, os);
114  os << nl << nl;
115  }
116 }
117 
118 
119 // ************************************************************************* //
Foam::rawSetWriter::write
virtual void write(const coordSet &, const wordList &, const List< const Field< Type > * > &, Ostream &) const
General entry point for writing.
Definition: rawSetWriter.C:65
rawSetWriter.H
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
coordSet.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::rawSetWriter::getFileName
virtual fileName getFileName(const coordSet &, const wordList &) const
Generate file name with correct extension.
Definition: rawSetWriter.C:54
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
OFstream.H
Foam::Field
Generic templated field type.
Definition: Field.H:63
fileName.H
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:81
Foam::coordSet
Holds list of sampling positions.
Definition: coordSet.H:53
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::List< word >
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::rawSetWriter::rawSetWriter
rawSetWriter()
Default construct.
Definition: rawSetWriter.C:37