FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

rawSetWriter.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "rawSetWriter.H"
00027 #include <sampling/coordSet.H>
00028 #include <OpenFOAM/fileName.H>
00029 #include <OpenFOAM/OFstream.H>
00030 
00031 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00032 
00033 template<class Type>
00034 Foam::rawSetWriter<Type>::rawSetWriter()
00035 :
00036     writer<Type>()
00037 {}
00038 
00039 
00040 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00041 
00042 template<class Type>
00043 Foam::rawSetWriter<Type>::~rawSetWriter()
00044 {}
00045 
00046 
00047 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00048 
00049 template<class Type>
00050 Foam::fileName Foam::rawSetWriter<Type>::getFileName
00051 (
00052     const coordSet& points,
00053     const wordList& valueSetNames
00054 ) const
00055 {
00056     return this->getBaseName(points, valueSetNames) + ".xy";
00057 }
00058 
00059 
00060 template<class Type>
00061 void Foam::rawSetWriter<Type>::write
00062 (
00063     const coordSet& points,
00064     const wordList& valueSetNames,
00065     const List<const Field<Type>*>& valueSets,
00066     Ostream& os
00067 ) const
00068 {
00069     // Collect sets into columns
00070     List<const List<Type>*> columns(valueSets.size());
00071 
00072     forAll(valueSets, i)
00073     {
00074         columns[i] = valueSets[i];
00075     }
00076 
00077     this->writeTable(points, columns, os);
00078 }
00079 
00080 
00081 template<class Type>
00082 void Foam::rawSetWriter<Type>::write
00083 (
00084     const bool writeTracks,
00085     const PtrList<coordSet>& points,
00086     const wordList& valueSetNames,
00087     const List<List<Field<Type> > >& valueSets,
00088     Ostream& os
00089 ) const
00090 {
00091     if (valueSets.size() != valueSetNames.size())
00092     {
00093         FatalErrorIn("rawSetWriter<Type>::write(..)")
00094             << "Number of variables:" << valueSetNames.size() << endl
00095             << "Number of valueSets:" << valueSets.size()
00096             << exit(FatalError);
00097     }
00098 
00099     List<const List<Type>*> columns(valueSets.size());
00100 
00101     forAll(points, trackI)
00102     {
00103         // Collect sets into columns
00104         forAll(valueSets, i)
00105         {
00106             columns[i] = &valueSets[i][trackI];
00107         }
00108 
00109         this->writeTable(points[trackI], columns, os);
00110         os  << nl << nl;
00111     }
00112 }
00113 
00114 
00115 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines