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-2019 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 #include "MeshedSurfaceProxy.H"
28 #include "proxySurfaceWriter.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(surfaceWriter, 0);
36  defineRunTimeSelectionTable(surfaceWriter, word);
37  defineRunTimeSelectionTable(surfaceWriter, wordDict);
38 }
39 
40 
41 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
42 
44 Foam::surfaceWriter::New(const word& writeType)
45 {
46  wordConstructorTable::iterator cstrIter =
47  wordConstructorTablePtr_->find(writeType);
48 
49  if (cstrIter == wordConstructorTablePtr_->end())
50  {
52  {
53  // generally unknown, but can be written via MeshedSurfaceProxy
54  // use 'proxy' handler instead
55  return autoPtr<surfaceWriter>(new proxySurfaceWriter(writeType));
56  }
57 
58  if (cstrIter == wordConstructorTablePtr_->end())
59  {
61  << "Unknown write type \"" << writeType << "\"\n\n"
62  << "Valid write types : "
63  << wordConstructorTablePtr_->sortedToc() << nl
64  << "Valid proxy types : "
66  << exit(FatalError);
67  }
68  }
69 
70  return autoPtr<surfaceWriter>(cstrIter()());
71 }
72 
73 
75 Foam::surfaceWriter::New(const word& writeType, const dictionary& optDict)
76 {
77  // find constructors with dictionary options
78  wordDictConstructorTable::iterator cstrIter =
79  wordDictConstructorTablePtr_->find(writeType);
80 
81  if (cstrIter == wordDictConstructorTablePtr_->end())
82  {
83  // revert to versions without options
84  return Foam::surfaceWriter::New(writeType);
85  }
86 
87  return autoPtr<surfaceWriter>(cstrIter()(optDict));
88 }
89 
90 
91 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
92 
94 {}
95 
96 
97 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
98 
100 {}
101 
102 
103 // ************************************************************************* //
surfaceWriter()
Construct null.
Definition: surfaceWriter.C:93
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:158
#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.
Definition: surfaceWriter.C:99
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
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:44
Namespace for OpenFOAM.