refineWallLayer.C
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 #include "argList.H"
00034 #include "Time.H"
00035 #include "polyTopoChange.H"
00036 #include "polyTopoChanger.H"
00037 #include "mapPolyMesh.H"
00038 #include "polyMesh.H"
00039 #include "cellCuts.H"
00040 #include "cellSet.H"
00041 #include "meshCutter.H"
00042
00043 using namespace Foam;
00044
00045
00046
00047
00048 int main(int argc, char *argv[])
00049 {
00050 Foam::argList::noParallel();
00051 Foam::argList::validArgs.append("patchName");
00052 Foam::argList::validArgs.append("edgeWeight");
00053 Foam::argList::validOptions.insert("useSet", "cellSet");
00054 Foam::argList::validOptions.insert("overwrite", "");
00055
00056 # include "setRootCase.H"
00057 # include "createTime.H"
00058 runTime.functionObjects().off();
00059 # include "createPolyMesh.H"
00060 const word oldInstance = mesh.pointsInstance();
00061
00062 word patchName(args.additionalArgs()[0]);
00063
00064 scalar weight(readScalar(IStringStream(args.additionalArgs()[1])()));
00065 bool overwrite = args.optionFound("overwrite");
00066
00067
00068 label patchID = mesh.boundaryMesh().findPatchID(patchName);
00069
00070 if (patchID == -1)
00071 {
00072 FatalErrorIn(args.executable())
00073 << "Cannot find patch " << patchName << endl
00074 << "Valid patches are " << mesh.boundaryMesh().names()
00075 << exit(FatalError);
00076 }
00077 const polyPatch& pp = mesh.boundaryMesh()[patchID];
00078
00079
00080
00081
00082 labelHashSet cutCells(4*pp.size());
00083
00084 const labelList& meshPoints = pp.meshPoints();
00085
00086 forAll(meshPoints, pointI)
00087 {
00088 label meshPointI = meshPoints[pointI];
00089
00090 const labelList& pCells = mesh.pointCells()[meshPointI];
00091
00092 forAll(pCells, pCellI)
00093 {
00094 cutCells.insert(pCells[pCellI]);
00095 }
00096 }
00097
00098 Info<< "Selected " << cutCells.size()
00099 << " cells connected to patch " << pp.name() << endl << endl;
00100
00101
00102
00103
00104
00105 bool useSet = args.optionFound("useSet");
00106
00107 if (useSet)
00108 {
00109 word setName(args.option("useSet"));
00110
00111 Info<< "Subsetting cells to cut based on cellSet" << setName << endl
00112 << endl;
00113
00114 cellSet cells(mesh, setName);
00115
00116 Info<< "Read " << cells.size() << " cells from cellSet "
00117 << cells.instance()/cells.local()/cells.name()
00118 << endl << endl;
00119
00120 for
00121 (
00122 cellSet::const_iterator iter = cells.begin();
00123 iter != cells.end();
00124 ++iter
00125 )
00126 {
00127 cutCells.erase(iter.key());
00128 }
00129 Info<< "Removed from cells to cut all the ones not in set " << setName
00130 << endl << endl;
00131 }
00132
00133
00134
00135 boolList vertOnPatch(mesh.nPoints(), false);
00136
00137 forAll(meshPoints, pointI)
00138 {
00139 label meshPointI = meshPoints[pointI];
00140
00141 vertOnPatch[meshPointI] = true;
00142 }
00143
00144
00145
00146
00147 DynamicList<label> allCutEdges(pp.nEdges());
00148
00149 DynamicList<scalar> allCutEdgeWeights(pp.nEdges());
00150
00151 forAll(meshPoints, pointI)
00152 {
00153 label meshPointI = meshPoints[pointI];
00154
00155 const labelList& pEdges = mesh.pointEdges()[meshPointI];
00156
00157 forAll(pEdges, pEdgeI)
00158 {
00159 label edgeI = pEdges[pEdgeI];
00160
00161 const edge& e = mesh.edges()[edgeI];
00162
00163 label otherPointI = e.otherVertex(meshPointI);
00164
00165 if (!vertOnPatch[otherPointI])
00166 {
00167 allCutEdges.append(edgeI);
00168
00169 if (e.start() == meshPointI)
00170 {
00171 allCutEdgeWeights.append(weight);
00172 }
00173 else
00174 {
00175 allCutEdgeWeights.append(1 - weight);
00176 }
00177 }
00178 }
00179 }
00180
00181 allCutEdges.shrink();
00182 allCutEdgeWeights.shrink();
00183
00184 Info<< "Cutting:" << endl
00185 << " cells:" << cutCells.size() << endl
00186 << " edges:" << allCutEdges.size() << endl
00187 << endl;
00188
00189
00190 scalarField cutEdgeWeights;
00191 cutEdgeWeights.transfer(allCutEdgeWeights);
00192 allCutEdgeWeights.clear();
00193
00194
00195
00196 cellCuts cuts
00197 (
00198 mesh,
00199 cutCells.toc(),
00200 labelList(0),
00201 allCutEdges,
00202 cutEdgeWeights
00203 );
00204
00205 polyTopoChange meshMod(mesh);
00206
00207
00208 meshCutter cutter(mesh);
00209
00210
00211 cutter.setRefinement(cuts, meshMod);
00212
00213
00214 Info<< "Morphing ..." << endl;
00215
00216 if (!overwrite)
00217 {
00218 runTime++;
00219 }
00220
00221 autoPtr<mapPolyMesh> morphMap = meshMod.changeMesh(mesh, false);
00222
00223 if (morphMap().hasMotionPoints())
00224 {
00225 mesh.movePoints(morphMap().preMotionPoints());
00226 }
00227
00228
00229 cutter.updateMesh(morphMap());
00230
00231 if (overwrite)
00232 {
00233 mesh.setInstance(oldInstance);
00234 }
00235
00236
00237 Info << "Writing refined morphMesh to time " << runTime.timeName() << endl;
00238
00239 mesh.write();
00240
00241 Info << "End\n" << endl;
00242
00243 return 0;
00244 }
00245
00246
00247
Copyright © 2000-2009 OpenCFD Ltd