FreeFOAM The Cross-Platform CFD Toolkit
surfaceRefineRedGreen.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  surfaceRefineRedGreen
26 
27 Description
28  Refine by splitting all three edges of triangle ('red' refinement).
29  Neighbouring triangles (which are not marked for refinement get split
30  in half ('green') refinement.
31 
32  (R. Verfuerth, "A review of a posteriori error estimation and adaptive mesh
33  refinement techniques", Wiley-Teubner, 1996)
34 
35 Usage
36 
37  - surfaceRefineRedGreen [OPTIONS] <Foam surface file> <surface output file>
38 
39  @param <Foam surface file> \n
40  @todo Detailed description of argument.
41 
42  @param <surface output file> \n
43  @todo Detailed description of argument.
44 
45  @param -case <dir>\n
46  Case directory.
47 
48  @param -help \n
49  Display help message.
50 
51  @param -doc \n
52  Display Doxygen API documentation page for this application.
53 
54  @param -srcDoc \n
55  Display Doxygen source documentation page for this application.
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #include <triSurface/triSurface.H>
61 #include <OpenFOAM/argList.H>
62 #include <OpenFOAM/OFstream.H>
63 
64 using namespace Foam;
65 
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 // Main program:
69 
70 int main(int argc, char *argv[])
71 {
74  argList::validArgs.append("surface file");
75  argList::validArgs.append("output surface file");
76  argList args(argc, argv);
77 
78  fileName surfFileName(args.additionalArgs()[0]);
79  fileName outFileName(args.additionalArgs()[1]);
80 
81  Info<< "Reading surface from " << surfFileName << " ..." << endl;
82 
83  triSurface surf1(surfFileName);
84 
85  // Refine
87  (
88  surf1,
89  identity(surf1.size()) //Hack: refine all
90  );
91 
92  Info<< "Original surface:" << endl
93  << " triangles :" << surf1.size() << endl
94  << " vertices(used):" << surf1.nPoints() << endl
95  << "Refined surface:" << endl
96  << " triangles :" << surf2.size() << endl
97  << " vertices(used):" << surf2.nPoints() << endl << endl;
98 
99 
100  Info<< "Writing refined surface to " << outFileName << " ..." << endl;
101 
102  surf2.write(outFileName);
103 
104  Info << "End\n" << endl;
105 
106  return 0;
107 }
108 
109 
110 // ************************ vim: set sw=4 sts=4 et: ************************ //