ensightSurfaceWriter.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2014 OpenFOAM Foundation
9  Copyright (C) 2015-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "ensightSurfaceWriter.H"
30 #include "IOmanip.H"
31 #include "Fstream.H"
32 #include "OSspecific.H"
33 #include "ensightCase.H"
34 #include "ensightOutput.H"
35 #include "ensightOutputSurface.H"
36 #include "ensightPTraits.H"
37 #include "surfaceWriterMethods.H"
39 
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 namespace surfaceWriters
45 {
46  defineTypeName(ensightWriter);
47  addToRunTimeSelectionTable(surfaceWriter, ensightWriter, word);
49 }
50 }
51 
52 
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54 
56 :
57  surfaceWriter(),
58  caseOpts_(IOstreamOption::BINARY),
59  collateTimes_(true),
60  caching_("fieldsDict") // Historic name
61 {}
62 
63 
65 (
66  const dictionary& options
67 )
68 :
69  surfaceWriter(options),
70  caseOpts_("format", options, IOstreamOption::BINARY),
71  collateTimes_(options.getOrDefault("collateTimes", true)),
72  caching_("fieldsDict") // Historic name
73 {
74  caseOpts_.timeFormat("timeFormat", options);
75  caseOpts_.timePrecision("timePrecision", options);
76 }
77 
78 
80 (
81  const meshedSurf& surf,
82  const fileName& outputPath,
83  bool parallel,
84  const dictionary& options
85 )
86 :
87  ensightWriter(options)
88 {
89  open(surf, outputPath, parallel);
90 }
91 
92 
94 (
95  const pointField& points,
96  const faceList& faces,
97  const fileName& outputPath,
98  bool parallel,
99  const dictionary& options
100 )
101 :
102  ensightWriter(options)
103 {
104  open(points, faces, outputPath, parallel);
105 }
106 
107 
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 
111 {
112  caching_.clear();
114 }
116 
117 // Note that ensight does supports geometry in a separate file,
118 // but setting this true leaves geometry files in the wrong places
119 // (when there are fields).
120 //
121 // Make this false to let the field writers take back control
123 {
124  return false;
125 }
126 
127 
129 {
130  // if (collateTimes_)
131  // {
132  // return writeCollated();
133  // }
134  // else
135  // {
136  // return writeUncollated();
137  // }
138 
139  return writeUncollated();
140 }
141 
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
147 
148 
149 // Field writing implementations
150 
151 template<class Type>
152 Foam::fileName Foam::surfaceWriters::ensightWriter::writeTemplate
153 (
154  const word& fieldName,
155  const Field<Type>& localValues
156 )
157 {
158  if (collateTimes_)
159  {
160  return writeCollated(fieldName, localValues);
161  }
162  else
163  {
164  return writeUncollated(fieldName, localValues);
165  }
166 }
167 
168 
170 
171 
172 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A surfaceWriter for Ensight format.
A simple container for options an IOstream can normally have.
Macros for easy insertion into run-time selection tables.
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:43
virtual bool separateGeometry() const
True if the surface format supports geometry in a separate file.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
virtual fileName write()
Write surface geometry to file.
const pointField & points
virtual void close()
Finish output, clears output times.
A class for handling words, derived from Foam::string.
Definition: word.H:63
Istream and Ostream manipulators taking arguments.
virtual void close()
Finish output, performing any necessary cleanup.
Convenience macros for instantiating surfaceWriter methods.
defineTypeName(abaqusWriter)
defineSurfaceWriterWriteFields(Foam::surfaceWriters::ensightWriter)
Base class for surface writers.
addToRunTimeSelectionTable(surfaceWriter, abaqusWriter, word)
Namespace for OpenFOAM.