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 "polyPatch.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "polyBoundaryMesh.H"
00030 #include "polyMesh.H"
00031 #include "primitiveMesh.H"
00032 #include "SubField.H"
00033 #include "entry.H"
00034 #include "dictionary.H"
00035 #include "pointPatchField.H"
00036
00037
00038
00039 namespace Foam
00040 {
00041 defineTypeNameAndDebug(polyPatch, 0);
00042
00043 int polyPatch::disallowGenericPolyPatch
00044 (
00045 debug::debugSwitch("disallowGenericPolyPatch", 0)
00046 );
00047
00048 defineRunTimeSelectionTable(polyPatch, word);
00049 defineRunTimeSelectionTable(polyPatch, dictionary);
00050
00051 addToRunTimeSelectionTable(polyPatch, polyPatch, word);
00052 addToRunTimeSelectionTable(polyPatch, polyPatch, dictionary);
00053 }
00054
00055
00056
00057
00058 void Foam::polyPatch::movePoints(const pointField& p)
00059 {
00060 primitivePatch::movePoints(p);
00061 }
00062
00063 void Foam::polyPatch::updateMesh()
00064 {
00065 clearAddressing();
00066 }
00067
00068
00069
00070
00071 Foam::polyPatch::polyPatch
00072 (
00073 const word& name,
00074 const label size,
00075 const label start,
00076 const label index,
00077 const polyBoundaryMesh& bm
00078 )
00079 :
00080 patchIdentifier(name, index),
00081 primitivePatch
00082 (
00083 faceSubList(bm.mesh().faces(), size, start),
00084 bm.mesh().points()
00085 ),
00086 start_(start),
00087 boundaryMesh_(bm),
00088 faceCellsPtr_(NULL),
00089 mePtr_(NULL)
00090 {}
00091
00092
00093 Foam::polyPatch::polyPatch
00094 (
00095 const word& name,
00096 const dictionary& dict,
00097 const label index,
00098 const polyBoundaryMesh& bm
00099 )
00100 :
00101 patchIdentifier(name, dict, index),
00102 primitivePatch
00103 (
00104 faceSubList
00105 (
00106 bm.mesh().faces(),
00107 readLabel(dict.lookup("nFaces")),
00108 readLabel(dict.lookup("startFace"))
00109 ),
00110 bm.mesh().points()
00111 ),
00112 start_(readLabel(dict.lookup("startFace"))),
00113 boundaryMesh_(bm),
00114 faceCellsPtr_(NULL),
00115 mePtr_(NULL)
00116 {}
00117
00118
00119 Foam::polyPatch::polyPatch
00120 (
00121 const polyPatch& pp,
00122 const polyBoundaryMesh& bm
00123 )
00124 :
00125 patchIdentifier(pp),
00126 primitivePatch
00127 (
00128 faceSubList
00129 (
00130 bm.mesh().faces(),
00131 pp.size(),
00132 pp.start()
00133 ),
00134 bm.mesh().points()
00135 ),
00136 start_(pp.start()),
00137 boundaryMesh_(bm),
00138 faceCellsPtr_(NULL),
00139 mePtr_(NULL)
00140 {}
00141
00142
00143 Foam::polyPatch::polyPatch
00144 (
00145 const polyPatch& pp,
00146 const polyBoundaryMesh& bm,
00147 const label index,
00148 const label newSize,
00149 const label newStart
00150 )
00151 :
00152 patchIdentifier(pp, index),
00153 primitivePatch
00154 (
00155 faceSubList
00156 (
00157 bm.mesh().faces(),
00158 newSize,
00159 newStart
00160 ),
00161 bm.mesh().points()
00162 ),
00163 start_(newStart),
00164 boundaryMesh_(bm),
00165 faceCellsPtr_(NULL),
00166 mePtr_(NULL)
00167 {}
00168
00169
00170 Foam::polyPatch::polyPatch(const polyPatch& p)
00171 :
00172 patchIdentifier(p),
00173 primitivePatch(p),
00174 start_(p.start_),
00175 boundaryMesh_(p.boundaryMesh_),
00176 faceCellsPtr_(NULL),
00177 mePtr_(NULL)
00178 {}
00179
00180
00181
00182
00183 Foam::polyPatch::~polyPatch()
00184 {
00185 clearAddressing();
00186 }
00187
00188
00189
00190
00191 bool Foam::polyPatch::constraintType(const word& pt)
00192 {
00193 return pointPatchField<scalar>::pointPatchConstructorTablePtr_->found(pt);
00194 }
00195
00196
00197 Foam::wordList Foam::polyPatch::constraintTypes()
00198 {
00199 wordList cTypes(dictionaryConstructorTablePtr_->size());
00200
00201 label i = 0;
00202
00203 for
00204 (
00205 dictionaryConstructorTable::iterator cstrIter =
00206 dictionaryConstructorTablePtr_->begin();
00207 cstrIter != dictionaryConstructorTablePtr_->end();
00208 ++cstrIter
00209 )
00210 {
00211 if (constraintType(cstrIter.key()))
00212 {
00213 cTypes[i++] = cstrIter.key();
00214 }
00215 }
00216
00217 cTypes.setSize(i);
00218
00219 return cTypes;
00220 }
00221
00222
00223 const Foam::polyBoundaryMesh& Foam::polyPatch::boundaryMesh() const
00224 {
00225 return boundaryMesh_;
00226 }
00227
00228
00229 const Foam::vectorField::subField Foam::polyPatch::faceCentres() const
00230 {
00231 return patchSlice(boundaryMesh().mesh().faceCentres());
00232 }
00233
00234
00235 const Foam::vectorField::subField Foam::polyPatch::faceAreas() const
00236 {
00237 return patchSlice(boundaryMesh().mesh().faceAreas());
00238 }
00239
00240
00241
00242 Foam::tmp<Foam::vectorField> Foam::polyPatch::faceCellCentres() const
00243 {
00244 tmp<vectorField> tcc(new vectorField(size()));
00245 vectorField& cc = tcc();
00246
00247
00248 const vectorField& gcc = boundaryMesh_.mesh().cellCentres();
00249
00250 const unallocLabelList& faceCells = this->faceCells();
00251
00252 forAll (faceCells, facei)
00253 {
00254 cc[facei] = gcc[faceCells[facei]];
00255 }
00256
00257 return tcc;
00258 }
00259
00260
00261 const Foam::unallocLabelList& Foam::polyPatch::faceCells() const
00262 {
00263 if (!faceCellsPtr_)
00264 {
00265 faceCellsPtr_ = new labelList::subList
00266 (
00267 patchSlice(boundaryMesh().mesh().faceOwner())
00268 );
00269 }
00270
00271 return *faceCellsPtr_;
00272 }
00273
00274
00275 const Foam::labelList& Foam::polyPatch::meshEdges() const
00276 {
00277 if (!mePtr_)
00278 {
00279 mePtr_ =
00280 new labelList
00281 (
00282 primitivePatch::meshEdges
00283 (
00284 boundaryMesh().mesh().edges(),
00285 boundaryMesh().mesh().pointEdges()
00286 )
00287 );
00288 }
00289
00290 return *mePtr_;
00291 }
00292
00293
00294 void Foam::polyPatch::clearAddressing()
00295 {
00296 deleteDemandDrivenData(faceCellsPtr_);
00297 deleteDemandDrivenData(mePtr_);
00298 }
00299
00300
00301 void Foam::polyPatch::write(Ostream& os) const
00302 {
00303 os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
00304 patchIdentifier::write(os);
00305 os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
00306 os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
00307 }
00308
00309
00310 void Foam::polyPatch::initOrder(const primitivePatch&) const
00311 {}
00312
00313
00314 bool Foam::polyPatch::order
00315 (
00316 const primitivePatch&,
00317 labelList& faceMap,
00318 labelList& rotation
00319 ) const
00320 {
00321
00322 return false;
00323 }
00324
00325
00326
00327
00328 void Foam::polyPatch::operator=(const polyPatch& p)
00329 {
00330 clearAddressing();
00331
00332 patchIdentifier::operator=(p);
00333 primitivePatch::operator=(p);
00334 start_ = p.start_;
00335 }
00336
00337
00338
00339
00340 Foam::Ostream& Foam::operator<<(Ostream& os, const polyPatch& p)
00341 {
00342 p.write(os);
00343 os.check("Ostream& operator<<(Ostream& os, const polyPatch& p");
00344 return os;
00345 }
00346
00347
00348