ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / sampling / sampledSet / writers / raw / rawSetWriter.C
blobe259c78eaae1794e5919e6bac66478a0ec30f7e2
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 "rawSetWriter.H"
27 #include "coordSet.H"
28 #include "fileName.H"
29 #include "OFstream.H"
31 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
33 template<class Type>
34 Foam::rawSetWriter<Type>::rawSetWriter()
36     writer<Type>()
40 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
42 template<class Type>
43 Foam::rawSetWriter<Type>::~rawSetWriter()
47 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
49 template<class Type>
50 Foam::fileName Foam::rawSetWriter<Type>::getFileName
52     const coordSet& points,
53     const wordList& valueSetNames
54 ) const
56     return this->getBaseName(points, valueSetNames) + ".xy";
60 template<class Type>
61 void Foam::rawSetWriter<Type>::write
63     const coordSet& points,
64     const wordList& valueSetNames,
65     const List<const Field<Type>*>& valueSets,
66     Ostream& os
67 ) const
69     // Collect sets into columns
70     List<const List<Type>*> columns(valueSets.size());
72     forAll(valueSets, i)
73     {
74         columns[i] = valueSets[i];
75     }
77     this->writeTable(points, columns, os);
81 template<class Type>
82 void Foam::rawSetWriter<Type>::write
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
91     if (valueSets.size() != valueSetNames.size())
92     {
93         FatalErrorIn("rawSetWriter<Type>::write(..)")
94             << "Number of variables:" << valueSetNames.size() << endl
95             << "Number of valueSets:" << valueSets.size()
96             << exit(FatalError);
97     }
99     List<const List<Type>*> columns(valueSets.size());
101     forAll(points, trackI)
102     {
103         // Collect sets into columns
104         forAll(valueSets, i)
105         {
106             columns[i] = &valueSets[i][trackI];
107         }
109         this->writeTable(points[trackI], columns, os);
110         os  << nl << nl;
111     }
115 // ************************************************************************* //