surfaceWriter.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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 \*---------------------------------------------------------------------------*/
25 
26 #include "surfaceWriter.H"
27 
28 #include "MeshedSurfaceProxy.H"
29 #include "proxySurfaceWriter.H"
30 
31 #include "HashTable.H"
32 #include "word.H"
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39  defineTypeNameAndDebug(surfaceWriter, 0);
40  defineRunTimeSelectionTable(surfaceWriter, word);
41  defineRunTimeSelectionTable(surfaceWriter, wordDict);
43  (
44  surfaceWriter,
45  surfaceWriter,
46  word,
47  null
48  );
49 }
50 
51 
52 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
53 
55 Foam::surfaceWriter::New(const word& writeType)
56 {
57  wordConstructorTable::iterator cstrIter =
58  wordConstructorTablePtr_->find(writeType);
59 
60  if (cstrIter == wordConstructorTablePtr_->end())
61  {
63  {
64  // generally unknown, but can be written via MeshedSurfaceProxy
65  // use 'proxy' handler instead
66  return autoPtr<surfaceWriter>(new proxySurfaceWriter(writeType));
67  }
68 
69  if (cstrIter == wordConstructorTablePtr_->end())
70  {
72  << "Unknown write type \"" << writeType << "\"\n\n"
73  << "Valid write types : "
74  << wordConstructorTablePtr_->sortedToc() << nl
75  << "Valid proxy types : "
77  << exit(FatalError);
78  }
79  }
80 
81  return autoPtr<surfaceWriter>(cstrIter()());
82 }
83 
84 
86 Foam::surfaceWriter::New(const word& writeType, const dictionary& optDict)
87 {
88  // find constructors with dictionary options
89  wordDictConstructorTable::iterator cstrIter =
90  wordDictConstructorTablePtr_->find(writeType);
91 
92  if (cstrIter == wordDictConstructorTablePtr_->end())
93  {
94  // revert to versions without options
95  return Foam::surfaceWriter::New(writeType);
96  }
97 
98  return autoPtr<surfaceWriter>(cstrIter()(optDict));
99 }
100 
101 
102 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
103 
105 {}
106 
107 
108 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
109 
111 {}
112 
113 
114 // ************************************************************************* //
surfaceWriter()
Construct null.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
Macros for easy insertion into run-time selection tables.
virtual ~surfaceWriter()
Destructor.
A class for handling words, derived from string.
Definition: word.H:59
A surfaceWriter that writes the geometry via the MeshedSurfaceProxy, but which does not support any f...
static const char nl
Definition: Ostream.H:265
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats...
Definition: MeshedSurface.H:73
addNamedToRunTimeSelectionTable(GAMGProcAgglomeration, noneGAMGProcAgglomeration, GAMGAgglomeration, none)
static wordHashSet writeTypes()
The file format types that can be written via MeshedSurfaceProxy.
static autoPtr< surfaceWriter > New(const word &writeType)
Return a reference to the selected surfaceWriter.
Definition: surfaceWriter.C:55
Namespace for OpenFOAM.