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) 2011-2013 OpenFOAM Foundation
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). (R. Verfuerth, "A review of a posteriori
31  error estimation and adaptive mesh refinement techniques",
32  Wiley-Teubner, 1996)
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #include "triSurface.H"
37 #include "triSurfaceTools.H"
38 #include "argList.H"
39 #include "OFstream.H"
40 
41 using namespace Foam;
42 
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 int main(int argc, char *argv[])
47 {
49  argList::validArgs.append("surfaceFile");
50  argList::validArgs.append("output surfaceFile");
51  argList args(argc, argv);
52 
53  const fileName surfFileName = args[1];
54  const fileName outFileName = args[2];
55 
56  Info<< "Reading surface from " << surfFileName << " ..." << endl;
57 
58  triSurface surf1(surfFileName);
59 
60  // Refine
62  (
63  surf1,
64  identity(surf1.size()) //Hack: refine all
65  );
66 
67  Info<< "Original surface:" << endl
68  << " triangles :" << surf1.size() << endl
69  << " vertices(used):" << surf1.nPoints() << endl
70  << "Refined surface:" << endl
71  << " triangles :" << surf2.size() << endl
72  << " vertices(used):" << surf2.nPoints() << endl << endl;
73 
74 
75  Info<< "Writing refined surface to " << outFileName << " ..." << endl;
76 
77  surf2.write(outFileName);
78 
79  Info<< "End\n" << endl;
80 
81  return 0;
82 }
83 
84 
85 // ************************************************************************* //
label nPoints() const
Return number of points supporting patch faces.
A class for handling file names.
Definition: fileName.H:69
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
static void noParallel()
Remove the parallel options.
Definition: argList.C:146
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Definition: ListOps.C:104
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:154
static triSurface redGreenRefine(const triSurface &surf, const labelList &refineFaces)
Refine face by splitting all edges. Neighbouring face is.
Extract command arguments and options from the supplied argc and argv parameters. ...
Definition: argList.H:102
messageStream Info
Triangulated surface description with patch information.
Definition: triSurface.H:65
Foam::argList args(argc, argv)
Namespace for OpenFOAM.