surfaceWriter.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 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  (
73  "surfaceWriter::New(const word&)"
74  ) << "Unknown write type \"" << writeType << "\"\n\n"
75  << "Valid write types : "
76  << wordConstructorTablePtr_->sortedToc() << nl
77  << "Valid proxy types : "
79  << exit(FatalError);
80  }
81  }
82 
83  return autoPtr<surfaceWriter>(cstrIter()());
84 }
85 
86 
88 Foam::surfaceWriter::New(const word& writeType, const dictionary& optDict)
89 {
90  // find constructors with dictionary options
91  wordDictConstructorTable::iterator cstrIter =
92  wordDictConstructorTablePtr_->find(writeType);
93 
94  if (cstrIter == wordDictConstructorTablePtr_->end())
95  {
96  // revert to versions without options
97  return Foam::surfaceWriter::New(writeType);
98  }
99 
100  return autoPtr<surfaceWriter>(cstrIter()(optDict));
101 }
102 
103 
104 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
105 
107 {}
108 
109 
110 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
111 
113 {}
114 
115 
116 // ************************************************************************* //
A surfaceWriter that writes the geometry via the MeshedSurfaceProxy, but which does not support any f...
surfaceWriter()
Construct null.
static wordHashSet writeTypes()
The file format types that can be written via MeshedSurfaceProxy.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats...
Definition: MeshedSurface.H:73
A class for handling words, derived from string.
Definition: word.H:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Macros for easy insertion into run-time selection tables.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
error FatalError
virtual ~surfaceWriter()
Destructor.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
addNamedToRunTimeSelectionTable(GAMGProcAgglomeration, noneGAMGProcAgglomeration, GAMGAgglomeration, none)
static autoPtr< surfaceWriter > New(const word &writeType)
Return a reference to the selected surfaceWriter.
Definition: surfaceWriter.C:55
defineTypeNameAndDebug(combustionModel, 0)