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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #include <OpenFOAM/argList.H>
00060 #include <OpenFOAM/Time.H>
00061 #include <OpenFOAM/polyMesh.H>
00062 #include <dynamicMesh/polyTopoChange.H>
00063 #include "extrude2DMesh.H"
00064 #include <OpenFOAM/emptyPolyPatch.H>
00065
00066 using namespace Foam;
00067
00068
00069
00070
00071
00072 int main(int argc, char *argv[])
00073 {
00074 argList::validArgs.append("thickness");
00075 argList::validOptions.insert("overwrite", "");
00076 # include <OpenFOAM/setRootCase.H>
00077 # include <OpenFOAM/createTime.H>
00078 runTime.functionObjects().off();
00079 # include <OpenFOAM/createPolyMesh.H>
00080 const word oldInstance = mesh.pointsInstance();
00081
00082 scalar thickness(readScalar(IStringStream(args.additionalArgs()[0])()));
00083 bool overwrite = args.optionFound("overwrite");
00084
00085
00086
00087
00088
00089 const faceList& faces = mesh.faces();
00090 forAll(faces, faceI)
00091 {
00092 if (faces[faceI].size() != 2)
00093 {
00094 FatalErrorIn(args.executable())
00095 << "Face " << faceI << " size " << faces[faceI].size()
00096 << " is not of size 2 so mesh is not proper two-dimensional."
00097 << exit(FatalError);
00098 }
00099 }
00100
00101
00102
00103
00104
00105 scalar minRange = GREAT;
00106 direction extrudeDir = 4;
00107
00108 for (direction dir = 0; dir < 3; dir++)
00109 {
00110 scalarField cmpts(mesh.points().component(dir));
00111
00112 scalar range = max(cmpts)-min(cmpts);
00113
00114 Info<< "Direction:" << dir << " range:" << range << endl;
00115
00116 if (range < minRange)
00117 {
00118 minRange = range;
00119 extrudeDir = dir;
00120 }
00121 }
00122
00123 Info<< "Extruding in direction " << extrudeDir
00124 << " with thickness " << thickness << nl
00125 << endl;
00126
00127
00128
00129 const polyBoundaryMesh& patches = mesh.boundaryMesh();
00130
00131
00132
00133
00134
00135 label frontPatchI = patches.findPatchID("frontAndBack");
00136
00137 if (frontPatchI == -1)
00138 {
00139
00140 List<polyPatch*> newPatches(patches.size()+1);
00141
00142 forAll(patches, patchI)
00143 {
00144 const polyPatch& pp = patches[patchI];
00145
00146 newPatches[patchI] = pp.clone
00147 (
00148 patches,
00149 newPatches.size(),
00150 pp.size(),
00151 pp.start()
00152 ).ptr();
00153 }
00154
00155 frontPatchI = patches.size();
00156
00157 newPatches[frontPatchI] = new emptyPolyPatch
00158 (
00159 "frontAndBack",
00160 0,
00161 mesh.nFaces(),
00162 frontPatchI,
00163 patches
00164 );
00165
00166 Info<< "Adding empty patch " << newPatches[frontPatchI]->name()
00167 << " at index " << frontPatchI
00168 << " for front and back faces." << nl << endl;
00169
00170 mesh.removeBoundary();
00171 mesh.addPatches(newPatches);
00172 }
00173
00174
00175
00176
00177 polyTopoChange meshMod(mesh.boundaryMesh().size());
00178
00179
00180 extrude2DMesh extruder(mesh);
00181
00182
00183 extruder.setRefinement
00184 (
00185 extrudeDir,
00186 thickness,
00187 frontPatchI,
00188 meshMod
00189 );
00190
00191
00192 autoPtr<mapPolyMesh> morphMap = meshMod.changeMesh(mesh, false);
00193
00194 mesh.updateMesh(morphMap);
00195
00196 if (!overwrite)
00197 {
00198 runTime++;
00199 }
00200 else
00201 {
00202 mesh.setInstance(oldInstance);
00203 }
00204
00205
00206 Pout<< "Writing extruded mesh to time " << runTime.timeName() << nl
00207 << endl;
00208
00209 mesh.write();
00210
00211 Pout<< "End\n" << endl;
00212
00213 return 0;
00214 }
00215
00216
00217