MeshedSurfaceProxy.C
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
00027 #include "MeshedSurfaceProxy.H"
00028
00029 #include "Time.H"
00030 #include "surfMesh.H"
00031 #include "OFstream.H"
00032 #include "ListOps.H"
00033
00034
00035
00036 template<class Face>
00037 Foam::wordHashSet Foam::MeshedSurfaceProxy<Face>::writeTypes()
00038 {
00039 return wordHashSet(*writefileExtensionMemberFunctionTablePtr_);
00040 }
00041
00042
00043 template<class Face>
00044 bool Foam::MeshedSurfaceProxy<Face>::canWriteType
00045 (
00046 const word& ext,
00047 const bool verbose
00048 )
00049 {
00050 return checkSupport(writeTypes(), ext, verbose, "writing");
00051 }
00052
00053
00054 template<class Face>
00055 void Foam::MeshedSurfaceProxy<Face>::write
00056 (
00057 const fileName& name,
00058 const MeshedSurfaceProxy& surf
00059 )
00060 {
00061 if (debug)
00062 {
00063 Info<< "MeshedSurfaceProxy::write"
00064 "(const fileName&, const MeshedSurfaceProxy&) : "
00065 "writing to " << name
00066 << endl;
00067 }
00068
00069 word ext = name.ext();
00070
00071 typename writefileExtensionMemberFunctionTable::iterator mfIter =
00072 writefileExtensionMemberFunctionTablePtr_->find(ext);
00073
00074 if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
00075 {
00076 FatalErrorIn
00077 (
00078 "MeshedSurfaceProxy::write(const fileName&)"
00079 ) << "Unknown file extension " << ext << nl << nl
00080 << "Valid types are :" << endl
00081 << writeTypes()
00082 << exit(FatalError);
00083 }
00084
00085 mfIter()(name, surf);
00086 }
00087
00088
00089 template<class Face>
00090 void Foam::MeshedSurfaceProxy<Face>::write
00091 (
00092 const Time& t,
00093 const word& surfName
00094 ) const
00095 {
00096
00097 word name(surfName.size() ? surfName : surfaceRegistry::defaultName);
00098
00099 if (debug)
00100 {
00101 Info<< "MeshedSurfaceProxy::write"
00102 "(const Time&, const word&) : "
00103 "writing to " << name
00104 << endl;
00105 }
00106
00107
00108
00109 const fileName objectDir
00110 (
00111 t.timePath()/surfaceRegistry::prefix/name/surfMesh::meshSubDir
00112 );
00113
00114 if (!isDir(objectDir))
00115 {
00116 mkDir(objectDir);
00117 }
00118
00119
00120
00121 {
00122 pointIOField io
00123 (
00124 IOobject
00125 (
00126 "points",
00127 t.timeName(),
00128 surfMesh::meshSubDir,
00129 t,
00130 IOobject::NO_READ,
00131 IOobject::NO_WRITE,
00132 false
00133 )
00134 );
00135
00136 OFstream os
00137 (
00138 objectDir/io.name(),
00139 t.writeFormat(),
00140 IOstream::currentVersion,
00141 t.writeCompression()
00142 );
00143
00144 io.writeHeader(os);
00145
00146 os << this->points();
00147
00148 io.writeEndDivider(os);
00149 }
00150
00151
00152
00153 {
00154 faceIOList io
00155 (
00156 IOobject
00157 (
00158 "faces",
00159 t.timeName(),
00160 surfMesh::meshSubDir,
00161 t,
00162 IOobject::NO_READ,
00163 IOobject::NO_WRITE,
00164 false
00165 )
00166 );
00167
00168 OFstream os
00169 (
00170 objectDir/io.name(),
00171 t.writeFormat(),
00172 IOstream::currentVersion,
00173 t.writeCompression()
00174 );
00175 io.writeHeader(os);
00176
00177 if (this->useFaceMap())
00178 {
00179
00180 os << reorder(this->faceMap(), this->faces());
00181 }
00182 else
00183 {
00184 os << this->faces();
00185 }
00186
00187 io.writeEndDivider(os);
00188 }
00189
00190
00191
00192 {
00193 surfZoneIOList io
00194 (
00195 IOobject
00196 (
00197 "surfZones",
00198 t.timeName(),
00199 surfMesh::meshSubDir,
00200 t,
00201 IOobject::NO_READ,
00202 IOobject::NO_WRITE,
00203 false
00204 )
00205 );
00206
00207
00208 OFstream os(objectDir/io.name());
00209 io.writeHeader(os);
00210
00211 os << this->surfZones();
00212
00213 io.writeEndDivider(os);
00214 }
00215
00216 }
00217
00218
00219
00220
00221 template<class Face>
00222 Foam::MeshedSurfaceProxy<Face>::MeshedSurfaceProxy
00223 (
00224 const pointField& pointLst,
00225 const List<Face>& faceLst,
00226 const List<surfZone>& zoneLst,
00227 const List<label>& faceMap
00228 )
00229 :
00230 points_(pointLst),
00231 faces_(faceLst),
00232 zones_(zoneLst),
00233 faceMap_(faceMap)
00234 {}
00235
00236
00237
00238
00239 template<class Face>
00240 Foam::MeshedSurfaceProxy<Face>::~MeshedSurfaceProxy()
00241 {}
00242
00243
00244
Copyright © 2000-2009 OpenCFD Ltd