starcdSurfaceWriter.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 | Copyright (C) 2015 OpenCFD Ltd.
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 "starcdSurfaceWriter.H"
27 #include "MeshedSurfaceProxy.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  makeSurfaceWriterType(starcdSurfaceWriter);
35 }
36 
37 
38 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
39 
40 namespace Foam
41 {
42  template<>
44  (
45  Ostream& os,
46  const scalar& v
47  )
48  {
49  os << v << nl;
50  }
51 
52 
53  template<>
55  (
56  Ostream& os,
57  const vector& v
58  )
59  {
60  os << v[0] << ' ' << v[1] << ' ' << v[2] << nl;
61  }
62 
63 
64  template<>
66  (
67  Ostream& os,
68  const sphericalTensor& v
69  )
70  {
71  os << v[0] << nl;
72  }
73 
74 }
75 
76 
77 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
78 
80 :
82 {}
83 
84 
85 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
86 
88 {}
89 
90 
91 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92 
94 (
95  const fileName& outputDir,
96  const fileName& surfaceName,
97  const pointField& points,
98  const faceList& faces,
99  const bool verbose
100 ) const
101 {
102  if (!isDir(outputDir))
103  {
104  mkDir(outputDir);
105  }
106 
107  fileName outName(outputDir/surfaceName + ".inp");
108 
109  if (verbose)
110  {
111  Info<< "Writing geometry to " << outName << endl;
112  }
113 
114  MeshedSurfaceProxy<face>(points, faces).write(outName);
115 
116  return outName;
117 }
118 
119 
120 // create write methods
124 
125 
126 // ************************************************************************* //
MeshedSurfaceProxy.H
starcdSurfaceWriter.H
Foam::surfaceWriter
Base class for surface writers.
Definition: surfaceWriter.H:54
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::starcdSurfaceWriter::starcdSurfaceWriter
starcdSurfaceWriter()
Construct null.
Definition: starcdSurfaceWriter.C:79
Foam::MeshedSurfaceProxy::write
static void write(const fileName &, const MeshedSurfaceProxy< Face > &)
Write to file.
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::MeshedSurfaceProxy
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
Definition: MeshedSurface.H:73
makeSurfaceWriterMethods.H
Convenience macros for instantiating writer methods for surfaceWriter classes.
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::starcdSurfaceWriter::write
virtual fileName write(const fileName &outputDir, const fileName &surfaceName, const pointField &points, const faceList &faces, const bool verbose=false) const
Write single surface geometry to file.
Definition: starcdSurfaceWriter.C:94
Foam::starcdSurfaceWriter::writeData
static void writeData(Ostream &, const Type &)
Definition: starcdSurfaceWriterTemplates.C:33
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::isDir
bool isDir(const fileName &)
Does the name exist as a DIRECTORY in the file system?
Definition: POSIX.C:615
Foam::SphericalTensor
Templated 3D SphericalTensor derived from VectorSpace adding construction from 1 component,...
Definition: SphericalTensor.H:51
Foam::starcdSurfaceWriter
A surfaceWriter for STARCD files.
Definition: starcdSurfaceWriter.H:67
defineSurfaceWriterWriteField
defineSurfaceWriterWriteField(Foam::starcdSurfaceWriter, scalar)
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::starcdSurfaceWriter::~starcdSurfaceWriter
virtual ~starcdSurfaceWriter()
Destructor.
Definition: starcdSurfaceWriter.C:87
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::makeSurfaceWriterType
makeSurfaceWriterType(boundaryDataSurfaceWriter)
Foam::mkDir
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Definition: POSIX.C:419