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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2013 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Application
27  surfaceRefineRedGreen
28 
29 Group
30  grpSurfaceUtilities
31 
32 Description
33  Refine by splitting all three edges of triangle ('red' refinement).
34 
35  Neighbouring triangles (which are not marked for refinement get split
36  in half ('green' refinement).
37 
38  Reference:
39  \verbatim
40  R. Verfuerth, "A review of a posteriori
41  error estimation and adaptive mesh refinement techniques",
42  Wiley-Teubner, 1996)
43  \endverbatim
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #include "triSurface.H"
48 #include "triSurfaceTools.H"
49 #include "argList.H"
50 #include "OFstream.H"
51 
52 using namespace Foam;
53 
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 int main(int argc, char *argv[])
58 {
60  (
61  "Refine by splitting all three edges of triangle"
62  );
64  argList::addArgument("input", "The input surface file");
65  argList::addArgument("output", "The output surface file");
66  argList args(argc, argv);
67 
68  const fileName surfFileName = args[1];
69  const fileName outFileName = args[2];
70 
71  Info<< "Reading surface from " << surfFileName << " ..." << endl;
72 
73  triSurface surf1(surfFileName);
74 
75  // Refine
77  (
78  surf1,
79  identity(surf1.size()) //Hack: refine all
80  );
81 
82  Info<< "Original surface:" << endl
83  << " triangles :" << surf1.size() << endl
84  << " vertices(used):" << surf1.nPoints() << endl
85  << "Refined surface:" << endl
86  << " triangles :" << surf2.size() << endl
87  << " vertices(used):" << surf2.nPoints() << endl << endl;
88 
89 
90  Info<< "Writing refined surface to " << outFileName << " ..." << endl;
91 
92  surf2.write(outFileName);
93 
94  Info<< "End\n" << endl;
95 
96  return 0;
97 }
98 
99 
100 // ************************************************************************* //
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::argList::addNote
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:413
Foam::argList
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:123
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
triSurface.H
OFstream.H
Foam::argList::addArgument
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
Definition: argList.C:302
Foam::triSurface::write
void write(Ostream &os) const
Write to Ostream in simple OpenFOAM format.
Definition: triSurfaceIO.C:336
Foam::triSurface
Triangulated surface description with patch information.
Definition: triSurface.H:76
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
argList.H
Foam::triSurfaceTools::redGreenRefine
static triSurface redGreenRefine(const triSurface &surf, const labelList &refineFaces)
Refine face by splitting all edges. Neighbouring face is.
Definition: triSurfaceTools.C:1742
Foam::PrimitivePatch::nPoints
label nPoints() const
Return number of points supporting patch faces.
Definition: PrimitivePatch.H:316
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::identity
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
Definition: labelList.C:38
Foam::argList::noParallel
static void noParallel()
Remove the parallel options.
Definition: argList.C:491
args
Foam::argList args(argc, argv)
triSurfaceTools.H