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 "meshReader.H"
00027 #include <OpenFOAM/IOMap.H>
00028 #include <OpenFOAM/OFstream.H>
00029
00030
00031
00032
00033 void Foam::meshReader::warnDuplicates
00034 (
00035 const word& context,
00036 const wordList& list
00037 )
00038 {
00039 HashTable<label> hashed(list.size());
00040 bool duplicates = false;
00041
00042 forAll(list, listI)
00043 {
00044
00045 HashTable<label>::iterator iter = hashed.find(list[listI]);
00046 if (iter != hashed.end())
00047 {
00048 (*iter)++;
00049 duplicates = true;
00050 }
00051 else
00052 {
00053 hashed.insert(list[listI], 1);
00054 }
00055 }
00056
00057
00058 if (duplicates)
00059 {
00060 Info << nl << "WARNING: " << context << " with identical names:";
00061 forAllConstIter(HashTable<label>, hashed, iter)
00062 {
00063 if (*iter > 1)
00064 {
00065 Info << " " << iter.key();
00066 }
00067 }
00068 Info << nl << endl;
00069 }
00070 }
00071
00072
00073
00074
00075 void Foam::meshReader::writeInterfaces(const objectRegistry& registry) const
00076 {
00077
00078 IOList<labelList> ioObj
00079 (
00080 IOobject
00081 (
00082 "interfaces",
00083 "constant",
00084 polyMesh::meshSubDir,
00085 registry,
00086 IOobject::NO_READ,
00087 IOobject::NO_WRITE,
00088 false
00089 )
00090 );
00091
00092 ioObj.note() = "as yet unsupported interfaces (baffles)";
00093
00094 Info<< "Writing " << ioObj.name() << " to " << ioObj.objectPath() << endl;
00095
00096 OFstream os(ioObj.objectPath());
00097 ioObj.writeHeader(os);
00098
00099 os << interfaces_;
00100 ioObj.writeEndDivider(os);
00101 }
00102
00103
00104 void Foam::meshReader::writeMeshLabelList
00105 (
00106 const objectRegistry& registry,
00107 const word& propertyName,
00108 const labelList& list,
00109 IOstream::streamFormat fmt
00110 ) const
00111 {
00112
00113 IOList<label> ioObj
00114 (
00115 IOobject
00116 (
00117 propertyName,
00118 "constant",
00119 polyMesh::meshSubDir,
00120 registry,
00121 IOobject::NO_READ,
00122 IOobject::AUTO_WRITE,
00123 false
00124 ),
00125 list
00126 );
00127
00128
00129 ioObj.note() = "persistent data for star-cd <-> foam translation";
00130 Info<< "Writing " << ioObj.name() << " to " << ioObj.objectPath() << endl;
00131
00132
00133
00134
00135
00136 ioObj.writeObject
00137 (
00138 fmt,
00139 IOstream::currentVersion,
00140 IOstream::UNCOMPRESSED
00141 );
00142 }
00143
00144
00145
00146
00147 void Foam::meshReader::writeAux(const objectRegistry& registry) const
00148 {
00149 cellTable_.writeDict(registry);
00150 writeInterfaces(registry);
00151
00152
00153 writeMeshLabelList
00154 (
00155 registry,
00156 "origCellId",
00157 origCellId_,
00158 IOstream::BINARY
00159 );
00160
00161
00162
00163 writeMeshLabelList
00164 (
00165 registry,
00166 "cellTableId",
00167 cellTableId_,
00168 IOstream::ASCII
00169 );
00170 }
00171
00172
00173