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 | Copyright (C) 2011-2016 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 
26 #include "rawSetWriter.H"
27 #include "coordSet.H"
28 #include "fileName.H"
29 #include "OFstream.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 :
36  writer<Type>()
37 {}
38 
39 
40 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
41 
42 template<class Type>
44 {}
45 
46 
47 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
48 
49 template<class Type>
51 (
52  const coordSet& points,
53  const wordList& valueSetNames
54 ) const
55 {
56  return this->getBaseName(points, valueSetNames) + ".xy";
57 }
58 
59 
60 template<class Type>
62 (
63  const coordSet& points,
64  const wordList& valueSetNames,
65  const List<const Field<Type>*>& valueSets,
66  Ostream& os
67 ) const
68 {
69  // Collect sets into columns
70  List<const List<Type>*> columns(valueSets.size());
71 
72  forAll(valueSets, i)
73  {
74  columns[i] = valueSets[i];
75  }
76 
77  this->writeTable(points, columns, os);
78 }
79 
80 
81 template<class Type>
83 (
84  const bool writeTracks,
85  const PtrList<coordSet>& points,
86  const wordList& valueSetNames,
87  const List<List<Field<Type>>>& valueSets,
88  Ostream& os
89 ) const
90 {
91  if (valueSets.size() != valueSetNames.size())
92  {
94  << "Number of variables:" << valueSetNames.size() << endl
95  << "Number of valueSets:" << valueSets.size()
96  << exit(FatalError);
97  }
98 
99  List<const List<Type>*> columns(valueSets.size());
100 
101  forAll(points, trackI)
102  {
103  // Collect sets into columns
104  forAll(valueSets, i)
105  {
106  columns[i] = &valueSets[i][trackI];
107  }
108 
109  this->writeTable(points[trackI], columns, os);
110  os << nl << nl;
111  }
112 }
113 
114 
115 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
A class for handling file names.
Definition: fileName.H:69
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
Base class for graphics format writing. Entry points are.
Definition: writer.H:78
Holds list of sampling positions.
Definition: coordSet.H:49
Pre-declare SubField and related Field type.
Definition: Field.H:57
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const char nl
Definition: Ostream.H:262
rawSetWriter()
Construct null.
Definition: rawSetWriter.C:34
void writeTable(const coordSet &, const List< Type > &, Ostream &) const
Writes single-column ascii write. Column 1 is coordSet coordinate,.
Definition: writer.C:97
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:62
virtual fileName getFileName(const coordSet &, const wordList &) const
Generate file name with correct extension.
Definition: rawSetWriter.C:51
fileName getBaseName(const coordSet &, const wordList &) const
Generates filename from coordSet and sampled fields.
Definition: writer.C:60
virtual void write(const coordSet &, const wordList &, const List< const Field< Type > * > &, Ostream &) const
General entry point for writing.
Definition: rawSetWriter.C:62
virtual ~rawSetWriter()
Destructor.
Definition: rawSetWriter.C:43