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 "pointZoneSet.H"
00027 #include <OpenFOAM/mapPolyMesh.H>
00028 #include <OpenFOAM/polyMesh.H>
00029 #include <OpenFOAM/processorPolyPatch.H>
00030 #include <OpenFOAM/cyclicPolyPatch.H>
00031
00032 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00033
00034
00035
00036 namespace Foam
00037 {
00038
00039
00040
00041 defineTypeNameAndDebug(pointZoneSet, 0);
00042
00043 addToRunTimeSelectionTable(topoSet, pointZoneSet, word);
00044 addToRunTimeSelectionTable(topoSet, pointZoneSet, size);
00045 addToRunTimeSelectionTable(topoSet, pointZoneSet, set);
00046
00047
00048
00049
00050 void pointZoneSet::updateSet()
00051 {
00052 labelList order;
00053 sortedOrder(addressing_, order);
00054 inplaceReorder(order, addressing_);
00055
00056 pointSet::clearStorage();
00057 pointSet::resize(2*addressing_.size());
00058 forAll(addressing_, i)
00059 {
00060 pointSet::insert(addressing_[i]);
00061 }
00062 }
00063
00064
00065
00066
00067 pointZoneSet::pointZoneSet
00068 (
00069 const polyMesh& mesh,
00070 const word& name,
00071 readOption r,
00072 writeOption w
00073 )
00074 :
00075 pointSet(mesh, name, 1000),
00076 mesh_(mesh),
00077 addressing_(0)
00078 {
00079 const pointZoneMesh& pointZones = mesh.pointZones();
00080 label zoneID = pointZones.findZoneID(name);
00081
00082 if
00083 (
00084 (r == IOobject::MUST_READ)
00085 || (r == IOobject::READ_IF_PRESENT && zoneID != -1)
00086 )
00087 {
00088 const pointZone& fz = pointZones[zoneID];
00089 addressing_ = fz;
00090 }
00091
00092 updateSet();
00093
00094 check(mesh.nPoints());
00095 }
00096
00097
00098 pointZoneSet::pointZoneSet
00099 (
00100 const polyMesh& mesh,
00101 const word& name,
00102 const label size,
00103 writeOption w
00104 )
00105 :
00106 pointSet(mesh, name, size, w),
00107 mesh_(mesh),
00108 addressing_(0)
00109 {
00110 updateSet();
00111 }
00112
00113
00114 pointZoneSet::pointZoneSet
00115 (
00116 const polyMesh& mesh,
00117 const word& name,
00118 const topoSet& set,
00119 writeOption w
00120 )
00121 :
00122 pointSet(mesh, name, set.size(), w),
00123 mesh_(mesh),
00124 addressing_(refCast<const pointZoneSet>(set).addressing())
00125 {
00126 updateSet();
00127 }
00128
00129
00130
00131
00132 pointZoneSet::~pointZoneSet()
00133 {}
00134
00135
00136
00137
00138 void pointZoneSet::invert(const label maxLen)
00139 {
00140 label n = 0;
00141
00142 for (label pointI = 0; pointI < maxLen; pointI++)
00143 {
00144 if (!found(pointI))
00145 {
00146 addressing_[n] = pointI;
00147 n++;
00148 }
00149 }
00150 addressing_.setSize(n);
00151 updateSet();
00152 }
00153
00154
00155 void pointZoneSet::subset(const topoSet& set)
00156 {
00157 DynamicList<label> newAddressing(addressing_.size());
00158
00159 const pointZoneSet& fSet = refCast<const pointZoneSet>(set);
00160
00161 forAll(fSet.addressing(), i)
00162 {
00163 label pointI = fSet.addressing()[i];
00164
00165 if (found(pointI))
00166 {
00167 newAddressing.append(pointI);
00168 }
00169 }
00170
00171 addressing_.transfer(newAddressing);
00172 updateSet();
00173 }
00174
00175
00176 void pointZoneSet::addSet(const topoSet& set)
00177 {
00178 DynamicList<label> newAddressing(addressing_);
00179
00180 const pointZoneSet& fSet = refCast<const pointZoneSet>(set);
00181
00182 forAll(fSet.addressing(), i)
00183 {
00184 label pointI = fSet.addressing()[i];
00185
00186 if (!found(pointI))
00187 {
00188 newAddressing.append(pointI);
00189 }
00190 }
00191
00192 addressing_.transfer(newAddressing);
00193 updateSet();
00194 }
00195
00196
00197 void pointZoneSet::deleteSet(const topoSet& set)
00198 {
00199 DynamicList<label> newAddressing(addressing_.size());
00200
00201 const pointZoneSet& fSet = refCast<const pointZoneSet>(set);
00202
00203 forAll(addressing_, i)
00204 {
00205 label pointI = addressing_[i];
00206
00207 if (!fSet.found(pointI))
00208 {
00209
00210 newAddressing.append(pointI);
00211 }
00212 }
00213
00214 addressing_.transfer(newAddressing);
00215 updateSet();
00216 }
00217
00218
00219 void pointZoneSet::sync(const polyMesh& mesh)
00220 {}
00221
00222
00223 label pointZoneSet::maxSize(const polyMesh& mesh) const
00224 {
00225 return mesh.nPoints();
00226 }
00227
00228
00229
00230 bool pointZoneSet::writeObject
00231 (
00232 IOstream::streamFormat s,
00233 IOstream::versionNumber v,
00234 IOstream::compressionType c
00235 ) const
00236 {
00237
00238 word oldTypeName = typeName;
00239 const_cast<word&>(type()) = pointSet::typeName;
00240 bool ok = pointSet::writeObject(s, v, c);
00241 const_cast<word&>(type()) = oldTypeName;
00242
00243
00244 pointZoneMesh& pointZones = const_cast<polyMesh&>(mesh_).pointZones();
00245 label zoneID = pointZones.findZoneID(name());
00246
00247 if (zoneID == -1)
00248 {
00249 zoneID = pointZones.size();
00250
00251 pointZones.setSize(zoneID+1);
00252 pointZones.set
00253 (
00254 zoneID,
00255 new pointZone
00256 (
00257 name(),
00258 addressing_,
00259 zoneID,
00260 pointZones
00261 )
00262 );
00263 }
00264 else
00265 {
00266 pointZones[zoneID] = addressing_;
00267 }
00268 pointZones.clearAddressing();
00269
00270 return ok && pointZones.write();
00271 }
00272
00273
00274 void pointZoneSet::updateMesh(const mapPolyMesh& morphMap)
00275 {
00276
00277 labelList newAddressing(addressing_.size());
00278
00279 label n = 0;
00280 forAll(addressing_, i)
00281 {
00282 label pointI = addressing_[i];
00283 label newPointI = morphMap.reversePointMap()[pointI];
00284 if (newPointI >= 0)
00285 {
00286 newAddressing[n] = newPointI;
00287 n++;
00288 }
00289 }
00290 newAddressing.setSize(n);
00291
00292 addressing_.transfer(newAddressing);
00293
00294 updateSet();
00295 }
00296
00297
00298 void pointZoneSet::writeDebug
00299 (
00300 Ostream& os,
00301 const primitiveMesh& mesh,
00302 const label maxLen
00303 ) const
00304 {
00305 pointSet::writeDebug(os, mesh, maxLen);
00306 }
00307
00308
00309
00310
00311 }
00312
00313