surfaceSplitByPatch.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 #include "argList.H"
00031 #include "triSurface.H"
00032
00033 using namespace Foam;
00034
00035
00036
00037
00038 int main(int argc, char *argv[])
00039 {
00040 argList::noParallel();
00041 argList::validArgs.clear();
00042 argList::validArgs.append("input file");
00043 argList::argList args(argc, argv);
00044
00045 fileName surfName(args.additionalArgs()[0]);
00046
00047 Info<< "Reading surf from " << surfName << " ..." << nl << endl;
00048
00049 fileName surfBase = surfName.lessExt();
00050
00051 word extension = surfName.ext();
00052
00053 triSurface surf(surfName);
00054
00055 Info<< "Writing regions to separate files ..."
00056 << nl << endl;
00057
00058
00059 const geometricSurfacePatchList& patches = surf.patches();
00060
00061 forAll(patches, patchI)
00062 {
00063 const geometricSurfacePatch& pp = patches[patchI];
00064
00065 word patchName = pp.name();
00066
00067 if (patchName.empty())
00068 {
00069 patchName = "patch" + Foam::name(patchI);
00070 }
00071
00072 fileName outFile(surfBase + '_' + patchName + '.' + extension);
00073
00074 Info<< " Writing patch " << patchName << " to file " << outFile
00075 << endl;
00076
00077
00078
00079 boolList includeMap(surf.size(), false);
00080
00081 forAll(surf, faceI)
00082 {
00083 const labelledTri& f = surf[faceI];
00084
00085 if (f.region() == patchI)
00086 {
00087 includeMap[faceI] = true;
00088 }
00089 }
00090
00091
00092 labelList pointMap;
00093 labelList faceMap;
00094
00095 triSurface subSurf
00096 (
00097 surf.subsetMesh
00098 (
00099 includeMap,
00100 pointMap,
00101 faceMap
00102 )
00103 );
00104
00105 subSurf.write(outFile);
00106 }
00107
00108
00109 Info << "End\n" << endl;
00110
00111 return 0;
00112 }
00113
00114
00115
Copyright © 2000-2009 OpenCFD Ltd