Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "writer.H"
00027 #include <sampling/coordSet.H>
00028 #include <OpenFOAM/OFstream.H>
00029 #include <OpenFOAM/OSspecific.H>
00030
00031
00032
00033 template<class Type>
00034 Foam::autoPtr<Foam::writer<Type> > Foam::writer<Type>::New
00035 (
00036 const word& writeType
00037 )
00038 {
00039 typename wordConstructorTable::iterator cstrIter =
00040 wordConstructorTablePtr_
00041 ->find(writeType);
00042
00043 if (cstrIter == wordConstructorTablePtr_->end())
00044 {
00045 FatalErrorIn
00046 (
00047 "writer::New(const word&)"
00048 ) << "Unknown write type " << writeType
00049 << nl << nl
00050 << "Valid write types : " << nl
00051 << wordConstructorTablePtr_->sortedToc()
00052 << exit(FatalError);
00053 }
00054
00055 return autoPtr<writer<Type> >(cstrIter()());
00056 }
00057
00058
00059
00060
00061 template<class Type>
00062 Foam::fileName Foam::writer<Type>::getBaseName
00063 (
00064 const coordSet& points,
00065 const wordList& valueSets
00066 ) const
00067 {
00068 fileName fName(points.name());
00069
00070 forAll(valueSets, i)
00071 {
00072 fName += '_' + valueSets[i];
00073 }
00074
00075 return fName;
00076 }
00077
00078
00079 template<class Type>
00080 void Foam::writer<Type>::writeCoord
00081 (
00082 const coordSet& points,
00083 const label pointI,
00084 Ostream& os
00085 ) const
00086 {
00087 if (points.hasVectorAxis())
00088 {
00089 write(points.vectorCoord(pointI), os);
00090 }
00091 else
00092 {
00093 write(points.scalarCoord(pointI), os);
00094 }
00095 }
00096
00097
00098 template<class Type>
00099 void Foam::writer<Type>::writeTable
00100 (
00101 const coordSet& points,
00102 const List<Type>& values,
00103 Ostream& os
00104 ) const
00105 {
00106 forAll(points, pointI)
00107 {
00108 writeCoord(points, pointI, os);
00109 writeSeparator(os);
00110 write(values[pointI], os);
00111 os << nl;
00112 }
00113 }
00114
00115
00116 template<class Type>
00117 void Foam::writer<Type>::writeTable
00118 (
00119 const coordSet& points,
00120 const List<const List<Type>*>& valuesPtrList,
00121 Ostream& os
00122 ) const
00123 {
00124 forAll(points, pointI)
00125 {
00126 writeCoord(points, pointI, os);
00127
00128 forAll(valuesPtrList, i)
00129 {
00130 writeSeparator(os);
00131
00132 const List<Type>& values = *valuesPtrList[i];
00133 write(values[pointI], os);
00134 }
00135 os << nl;
00136 }
00137 }
00138
00139
00140
00141
00142 template<class Type>
00143 Foam::writer<Type>::writer()
00144 {}
00145
00146
00147
00148
00149 template<class Type>
00150 Foam::writer<Type>::~writer()
00151 {}
00152
00153
00154
00155
00156 template<class Type>
00157 Foam::Ostream& Foam::writer<Type>::write
00158 (
00159 const scalar value,
00160 Ostream& os
00161 ) const
00162 {
00163 return os << value;
00164 }
00165
00166
00167 template<class Type>
00168 template<class VSType>
00169 Foam::Ostream& Foam::writer<Type>::writeVS
00170 (
00171 const VSType& value,
00172 Ostream& os
00173 ) const
00174 {
00175 for (direction d=0; d<VSType::nComponents; d++)
00176 {
00177 if (d > 0)
00178 {
00179 writeSeparator(os);
00180 }
00181
00182 os << value.component(d);
00183 }
00184 return os;
00185 }
00186
00187
00188 template<class Type>
00189 void Foam::writer<Type>::writeSeparator
00190 (
00191 Ostream& os
00192 ) const
00193 {
00194 os << token::SPACE << token::TAB;
00195 }
00196
00197
00198 template<class Type>
00199 Foam::Ostream& Foam::writer<Type>::write
00200 (
00201 const vector& value,
00202 Ostream& os
00203 ) const
00204 {
00205 return writeVS(value, os);
00206 }
00207
00208
00209 template<class Type>
00210 Foam::Ostream& Foam::writer<Type>::write
00211 (
00212 const sphericalTensor& value,
00213 Ostream& os
00214 ) const
00215 {
00216 return writeVS(value, os);
00217 }
00218
00219
00220 template<class Type>
00221 Foam::Ostream& Foam::writer<Type>::write
00222 (
00223 const symmTensor& value,
00224 Ostream& os
00225 ) const
00226 {
00227 return writeVS(value, os);
00228 }
00229
00230
00231 template<class Type>
00232 Foam::Ostream& Foam::writer<Type>::write
00233 (
00234 const tensor& value,
00235 Ostream& os
00236 ) const
00237 {
00238 return writeVS(value, os);
00239 }
00240
00241
00242