All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2020 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 
45 (
46  const word& writeType,
47  const IOstream::streamFormat format
48 )
49 {
50  wordConstructorTable::iterator cstrIter =
51  wordConstructorTablePtr_->find(writeType);
52 
53  if (cstrIter == wordConstructorTablePtr_->end())
54  {
56  {
57  // generally unknown, but can be written via MeshedSurfaceProxy
58  // use 'proxy' handler instead
59  return autoPtr<surfaceWriter>(new proxySurfaceWriter(writeType));
60  }
61 
62  if (cstrIter == wordConstructorTablePtr_->end())
63  {
65  << "Unknown write type \"" << writeType << "\"\n\n"
66  << "Valid write types : "
67  << wordConstructorTablePtr_->sortedToc() << nl
68  << "Valid proxy types : "
70  << exit(FatalError);
71  }
72  }
73 
74  return autoPtr<surfaceWriter>(cstrIter()(format));
75 }
76 
77 
80 (
81  const word& writeType,
82  const dictionary& optDict
83 )
84 {
85  // find constructors with dictionary options
86  wordDictConstructorTable::iterator cstrIter =
87  wordDictConstructorTablePtr_->find(writeType);
88 
89  if (cstrIter == wordDictConstructorTablePtr_->end())
90  {
92 
93  if (optDict.found("writeFormat"))
94  {
95  writeFormat = IOstream::formatEnum
96  (
97  optDict.lookup("writeFormat")
98  );
99  }
100 
101  // Revert to versions without options
102  return Foam::surfaceWriter::New(writeType, writeFormat);
103  }
104 
105  return autoPtr<surfaceWriter>(cstrIter()(optDict));
106 }
107 
108 
109 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
110 
112 :
113  writeFormat_(writeFormat)
114 {}
115 
116 
118 :
119  writeFormat_(IOstream::ASCII)
120 {
121  if (optDict.found("writeFormat"))
122  {
124  (
125  optDict.lookup("writeFormat")
126  );
127  }
128 }
129 
130 
131 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
132 
134 {}
135 
136 
137 // ************************************************************************* //
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:667
static streamFormat formatEnum(const word &)
Return stream format of given format name.
Definition: IOstream.C:39
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
static autoPtr< surfaceWriter > New(const word &writeType, const IOstream::streamFormat writeFormat)
Return a reference to the selected surfaceWriter.
Definition: surfaceWriter.C:45
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
word format(conversionProperties.lookup("format"))
Macros for easy insertion into run-time selection tables.
virtual ~surfaceWriter()
Destructor.
IOstream::streamFormat writeFormat_
Write format.
Definition: surfaceWriter.H:62
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...
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86
static const char nl
Definition: Ostream.H:260
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats...
Definition: MeshedSurface.H:73
An IOstream is an abstract base class for all input/output systems; be they streams, files, token lists etc.
Definition: IOstream.H:71
surfaceWriter(const IOstream::streamFormat writeFormat)
Construct given write format.
static wordHashSet writeTypes()
The file format types that can be written via MeshedSurfaceProxy.
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:812