FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

surfaceAutoPatch.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Application
00025     surfaceAutoPatch
00026 
00027 Description
00028     Patches surface according to feature angle. Like autoPatch.
00029 
00030 Usage
00031 
00032     - surfaceAutoPatch [OPTIONS] <Foam surface file> <Foam output surface file> <included angle [0..180]>
00033 
00034     @param <Foam surface file> \n
00035     @todo Detailed description of argument.
00036 
00037     @param <Foam output surface file> \n
00038     @todo Detailed description of argument.
00039 
00040     @param <included angle [0..180]> \n
00041     @todo Detailed description of argument.
00042 
00043     @param -case <dir>\n
00044     Case directory.
00045 
00046     @param -help \n
00047     Display help message.
00048 
00049     @param -doc \n
00050     Display Doxygen API documentation page for this application.
00051 
00052     @param -srcDoc \n
00053     Display Doxygen source documentation page for this application.
00054 
00055 \*---------------------------------------------------------------------------*/
00056 
00057 #include <OpenFOAM/triangle.H>
00058 #include <triSurface/triSurface.H>
00059 #include <OpenFOAM/argList.H>
00060 #include <meshTools/surfaceFeatures.H>
00061 #include <meshTools/treeBoundBox.H>
00062 #include <meshTools/meshTools.H>
00063 #include <OpenFOAM/OFstream.H>
00064 
00065 using namespace Foam;
00066 
00067 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00068 
00069 // Main program:
00070 
00071 int main(int argc, char *argv[])
00072 {
00073     argList::noParallel();
00074     argList::validArgs.clear();
00075     argList::validArgs.append("input surface file");
00076     argList::validArgs.append("output surface file");
00077     argList::validArgs.append("included angle [0..180]");
00078     argList args(argc, argv);
00079 
00080     fileName inFileName(args.additionalArgs()[0]);
00081     fileName outFileName(args.additionalArgs()[1]);
00082     scalar includedAngle(readScalar(IStringStream(args.additionalArgs()[2])()));
00083 
00084     Pout<< "Surface        : " << inFileName << nl
00085         << endl;
00086 
00087 
00088     // Read
00089     // ~~~~
00090 
00091     Info << "Reading : " << inFileName << endl;
00092     triSurface surf(inFileName);
00093 
00094     Info<< "Read surface:" << endl;
00095     surf.writeStats(Info);
00096     Info<< endl;
00097     
00098 
00099 
00100     // Construct features from surface&featureangle
00101     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00102 
00103     Info<< "Constructing feature set from included angle " << includedAngle
00104         << endl;
00105 
00106     surfaceFeatures set(surf, includedAngle);
00107 
00108     Pout<< nl
00109         << "Feature set:" << nl
00110         << "    feature points : " << set.featurePoints().size() << nl
00111         << "    feature edges  : " << set.featureEdges().size() << nl
00112         << "    of which" << nl
00113         << "        region edges   : " << set.nRegionEdges() << nl
00114         << "        external edges : " << set.nExternalEdges() << nl
00115         << "        internal edges : " << set.nInternalEdges() << nl
00116         << endl;
00117 
00118     // Get per-edge status.
00119     boolList borderEdge(surf.nEdges(), false);
00120     forAll(set.featureEdges(), i)
00121     {
00122         borderEdge[set.featureEdges()[i]] = true;
00123     }
00124 
00125     labelList faceRegion(surf.size());
00126     label nRegions = surf.markZones(borderEdge, faceRegion);
00127 
00128     // Reregion triangles.
00129     forAll(surf, i)
00130     {
00131         surf[i].region() = faceRegion[i];
00132     }
00133 
00134     // Create some patches
00135     surf.patches().setSize(nRegions);
00136 
00137     forAll(surf.patches(), patchI)
00138     {
00139         surf.patches()[patchI].name() = "patch" + Foam::name(patchI);
00140         surf.patches()[patchI].geometricType() = "empty";
00141     }
00142 
00143 
00144     Info << "Writing : " << outFileName << endl;
00145     surf.write(outFileName, true);
00146 
00147     Info<< "End\n" << endl;
00148 
00149     return 0;
00150 }
00151 
00152 
00153 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines