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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "rawSetWriter.H"
29 #include "coordSet.H"
30 #include "fileName.H"
31 #include "OFstream.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template<class Type>
37 :
38  writer<Type>()
39 {}
40 
41 
42 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
43 
44 template<class Type>
46 {}
47 
48 
49 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
50 
51 template<class Type>
53 (
54  const coordSet& points,
55  const wordList& valueSetNames
56 ) const
57 {
58  return this->getBaseName(points, valueSetNames) + ".xy";
59 }
60 
61 
62 template<class Type>
64 (
65  const coordSet& points,
66  const wordList& valueSetNames,
67  const List<const Field<Type>*>& valueSets,
68  Ostream& os
69 ) const
70 {
71  // Collect sets into columns
72  List<const List<Type>*> columns(valueSets.size());
73 
74  forAll(valueSets, i)
75  {
76  columns[i] = valueSets[i];
77  }
78 
79  this->writeTable(points, columns, os);
80 }
81 
82 
83 template<class Type>
85 (
86  const bool writeTracks,
88  const wordList& valueSetNames,
89  const List<List<Field<Type>>>& valueSets,
90  Ostream& os
91 ) const
92 {
93  if (valueSets.size() != valueSetNames.size())
94  {
96  << "Number of variables:" << valueSetNames.size() << endl
97  << "Number of valueSets:" << valueSets.size()
98  << exit(FatalError);
99  }
100 
101  List<const List<Type>*> columns(valueSets.size());
102 
103  forAll(points, trackI)
104  {
105  // Collect sets into columns
106  forAll(valueSets, i)
107  {
108  columns[i] = &valueSets[i][trackI];
109  }
110 
111  this->writeTable(points[trackI], columns, os);
112  os << nl << nl;
113  }
114 }
115 
116 
117 // ************************************************************************* //
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:64
rawSetWriter.H
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
coordSet.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::rawSetWriter::getFileName
virtual fileName getFileName(const coordSet &, const wordList &) const
Generate file name with correct extension.
Definition: rawSetWriter.C:53
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:62
Foam::FatalError
error FatalError
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:80
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:381
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::rawSetWriter::~rawSetWriter
virtual ~rawSetWriter()
Destructor.
Definition: rawSetWriter.C:45
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()
Construct null.
Definition: rawSetWriter.C:36