surfacePatchIOList.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 "surfacePatchIOList.H"
00028
00029
00030
00031 defineTypeNameAndDebug(Foam::surfacePatchIOList, 0);
00032
00033
00034
00035
00036
00037 Foam::surfacePatchIOList::surfacePatchIOList
00038 (
00039 const IOobject& io
00040 )
00041 :
00042 surfacePatchList(),
00043 regIOobject(io)
00044 {
00045 Foam::string functionName =
00046 "surfacePatchIOList::surfacePatchIOList"
00047 "(const IOobject& io)";
00048
00049
00050 if (readOpt() == IOobject::MUST_READ)
00051 {
00052 surfacePatchList& patches = *this;
00053
00054
00055 Istream& is = readStream(typeName);
00056
00057 PtrList<entry> patchEntries(is);
00058 patches.setSize(patchEntries.size());
00059
00060 label faceI = 0;
00061
00062 forAll(patches, patchI)
00063 {
00064 const dictionary& dict = patchEntries[patchI].dict();
00065
00066 label patchSize = readLabel(dict.lookup("nFaces"));
00067 label startFaceI = readLabel(dict.lookup("startFace"));
00068
00069 patches[patchI] =
00070 surfacePatch
00071 (
00072 word(dict.lookup("geometricType")),
00073 patchEntries[patchI].keyword(),
00074 patchSize,
00075 startFaceI,
00076 patchI
00077 );
00078
00079
00080 if (startFaceI != faceI)
00081 {
00082 FatalErrorIn(functionName)
00083 << "Patches are not ordered. Start of patch " << patchI
00084 << " does not correspond to sum of preceding patches."
00085 << endl
00086 << "while reading " << io.objectPath()
00087 << exit(FatalError);
00088 }
00089
00090 faceI += patchSize;
00091 }
00092
00093
00094 is.check(functionName.c_str());
00095
00096 close();
00097 }
00098 }
00099
00100
00101 Foam::surfacePatchIOList::surfacePatchIOList
00102 (
00103 const IOobject& io,
00104 const surfacePatchList& patches
00105 )
00106 :
00107 surfacePatchList(patches),
00108 regIOobject(io)
00109 {}
00110
00111
00112
00113
00114 Foam::surfacePatchIOList::~surfacePatchIOList()
00115 {}
00116
00117
00118
00119
00120
00121
00122 bool Foam::surfacePatchIOList::writeData(Ostream& os) const
00123 {
00124 os << *this;
00125 return os.good();
00126 }
00127
00128
00129
00130
00131 Foam::Ostream& Foam::operator<<(Ostream& os, const surfacePatchIOList& patches)
00132 {
00133 os << patches.size() << nl << token::BEGIN_LIST;
00134
00135 forAll(patches, patchI)
00136 {
00137 patches[patchI].writeDict(os);
00138 }
00139
00140 os << token::END_LIST;
00141
00142 return os;
00143 }
00144
00145
00146
00147
00148
00149
00150
00151
Copyright © 2000-2009 OpenCFD Ltd