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 "extrude2DMesh.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 #include <dynamicMesh/polyTopoChange.H>
00029
00030
00031
00032 namespace Foam
00033 {
00034
00035 defineTypeNameAndDebug(extrude2DMesh, 0);
00036
00037 }
00038
00039
00040
00041
00042
00043
00044
00045 Foam::extrude2DMesh::extrude2DMesh(const polyMesh& mesh)
00046 :
00047 mesh_(mesh)
00048 {}
00049
00050
00051
00052
00053 void Foam::extrude2DMesh::setRefinement
00054 (
00055 const direction extrudeDir,
00056 const scalar thickness,
00057 const label frontPatchI,
00058 polyTopoChange& meshMod
00059 ) const
00060 {
00061 for (label cellI = 0; cellI < mesh_.nCells(); cellI++)
00062 {
00063 meshMod.addCell
00064 (
00065 -1,
00066 -1,
00067 -1,
00068 cellI,
00069 mesh_.cellZones().whichZone(cellI)
00070 );
00071 }
00072
00073
00074
00075
00076
00077 forAll(mesh_.points(), pointI)
00078 {
00079 meshMod.addPoint
00080 (
00081 mesh_.points()[pointI],
00082 pointI,
00083 -1,
00084 true
00085 );
00086 }
00087
00088
00089 forAll(mesh_.points(), pointI)
00090 {
00091 point newPoint(mesh_.points()[pointI]);
00092 newPoint[extrudeDir] = thickness;
00093
00094 meshMod.addPoint
00095 (
00096 newPoint,
00097 pointI,
00098 -1,
00099 true
00100 );
00101 }
00102
00103
00104
00105
00106
00107 const faceList& faces = mesh_.faces();
00108 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
00109
00110 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
00111 {
00112 label zoneID = mesh_.faceZones().whichZone(faceI);
00113 bool zoneFlip = false;
00114 if (zoneID != -1)
00115 {
00116 const faceZone& fZone = mesh_.faceZones()[zoneID];
00117 zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
00118 }
00119
00120 face newFace(4);
00121 const face& f = faces[faceI];
00122 newFace[0] = f[0];
00123 newFace[1] = f[1];
00124 newFace[2] = f[1]+mesh_.nPoints();
00125 newFace[3] = f[0]+mesh_.nPoints();
00126
00127 meshMod.addFace
00128 (
00129 newFace,
00130 mesh_.faceOwner()[faceI],
00131 mesh_.faceNeighbour()[faceI],
00132 -1,
00133 -1,
00134 faceI,
00135 false,
00136 -1,
00137 zoneID,
00138 zoneFlip
00139 );
00140 }
00141
00142 forAll(patches, patchI)
00143 {
00144 label startFaceI = patches[patchI].start();
00145 label endFaceI = startFaceI + patches[patchI].size();
00146
00147 for (label faceI = startFaceI; faceI < endFaceI; faceI++)
00148 {
00149 label zoneID = mesh_.faceZones().whichZone(faceI);
00150 bool zoneFlip = false;
00151 if (zoneID != -1)
00152 {
00153 const faceZone& fZone = mesh_.faceZones()[zoneID];
00154 zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
00155 }
00156
00157 face newFace(4);
00158 const face& f = faces[faceI];
00159 newFace[0] = f[0];
00160 newFace[1] = f[1];
00161 newFace[2] = f[1]+mesh_.nPoints();
00162 newFace[3] = f[0]+mesh_.nPoints();
00163
00164 meshMod.addFace
00165 (
00166 newFace,
00167 mesh_.faceOwner()[faceI],
00168 -1,
00169 -1,
00170 -1,
00171 faceI,
00172 false,
00173 patchI,
00174 zoneID,
00175 zoneFlip
00176 );
00177 }
00178 }
00179
00180
00181
00182
00183
00184 forAll(mesh_.cells(), cellI)
00185 {
00186 const cell& cFaces = mesh_.cells()[cellI];
00187
00188
00189 const face& f = faces[cFaces[0]];
00190
00191 face frontFace(cFaces.size());
00192 frontFace[0] = f[0];
00193
00194 label nextPointI = f[1];
00195 label nextFaceI = cFaces[0];
00196
00197 for (label i = 1; i < frontFace.size(); i++)
00198 {
00199 frontFace[i] = nextPointI;
00200
00201
00202 forAll(cFaces, cFaceI)
00203 {
00204 label faceI = cFaces[cFaceI];
00205 if (faceI != nextFaceI)
00206 {
00207 const face& f = faces[faceI];
00208
00209 if (f[0] == nextPointI)
00210 {
00211 nextPointI = f[1];
00212 nextFaceI = faceI;
00213 break;
00214 }
00215 else if (f[1] == nextPointI)
00216 {
00217 nextPointI = f[0];
00218 nextFaceI = faceI;
00219 break;
00220 }
00221 }
00222 }
00223 }
00224
00225
00226
00227 meshMod.addFace
00228 (
00229 frontFace.reverseFace(),
00230 cellI,
00231 -1,
00232 -1,
00233 -1,
00234 cFaces[0],
00235 false,
00236 frontPatchI,
00237 -1,
00238 false
00239 );
00240
00241
00242 forAll(frontFace, fp)
00243 {
00244 frontFace[fp] += mesh_.nPoints();
00245 }
00246 meshMod.addFace
00247 (
00248 frontFace,
00249 cellI,
00250 -1,
00251 -1,
00252 -1,
00253 cFaces[0],
00254 false,
00255 frontPatchI,
00256 -1,
00257 false
00258 );
00259 }
00260 }
00261
00262
00263