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