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 
30  Neighbouring triangles (which are not marked for refinement get split
31  in half ('green' refinement).
32 
33  Reference:
34  \verbatim
35  R. Verfuerth, "A review of a posteriori
36  error estimation and adaptive mesh refinement techniques",
37  Wiley-Teubner, 1996)
38  \endverbatim
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #include "triSurface.H"
43 #include "triSurfaceTools.H"
44 #include "argList.H"
45 #include "OFstream.H"
46 
47 using namespace Foam;
48 
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 int main(int argc, char *argv[])
53 {
55  argList::validArgs.append("surfaceFile");
56  argList::validArgs.append("output surfaceFile");
57  argList args(argc, argv);
58 
59  const fileName surfFileName = args[1];
60  const fileName outFileName = args[2];
61 
62  Info<< "Reading surface from " << surfFileName << " ..." << endl;
63 
64  triSurface surf1(surfFileName);
65 
66  // Refine
68  (
69  surf1,
70  identity(surf1.size()) //Hack: refine all
71  );
72 
73  Info<< "Original surface:" << endl
74  << " triangles :" << surf1.size() << endl
75  << " vertices(used):" << surf1.nPoints() << endl
76  << "Refined surface:" << endl
77  << " triangles :" << surf2.size() << endl
78  << " vertices(used):" << surf2.nPoints() << endl << endl;
79 
80 
81  Info<< "Writing refined surface to " << outFileName << " ..." << endl;
82 
83  surf2.write(outFileName);
84 
85  Info<< "End\n" << endl;
86 
87  return 0;
88 }
89 
90 
91 // ************************************************************************* //
Foam::argList::validArgs
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:143
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::argList
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:97
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
OFstream.H
Foam::triSurface
Triangulated surface description with patch information.
Definition: triSurface.H:57
Foam::Info
messageStream Info
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:1867
main
int main(int argc, char *argv[])
Definition: postCalc.C:54
Foam::identity
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Definition: ListOps.C:104
Foam::PrimitivePatch::nPoints
label nPoints() const
Return number of points supporting patch faces.
Definition: PrimitivePatchTemplate.H:293
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::argList::noParallel
static void noParallel()
Remove the parallel options.
Definition: argList.C:161
Foam::triSurface::write
void write(const fileName &, const word &ext, const bool sort) const
Generic write routine. Chooses writer based on extension.
Definition: triSurface.C:433
args
Foam::argList args(argc, argv)
triSurfaceTools.H