starcdSurfaceWriterTemplates.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-2014 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 "OFstream.H"
27 #include "OSspecific.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class Type>
33 (
34  Ostream& os,
35  const Type& v
36 )
37 {}
38 
39 
40 template<class Type>
42 (
43  const fileName& outputDir,
44  const fileName& surfaceName,
45  const pointField& points,
46  const faceList& faces,
47  const word& fieldName,
48  const Field<Type>& values,
49  const bool isNodeValues,
50  const bool verbose
51 ) const
52 {
53  if (!isDir(outputDir))
54  {
55  mkDir(outputDir);
56  }
57 
58  OFstream os(outputDir/fieldName + '_' + surfaceName + ".usr");
59 
60  if (verbose)
61  {
62  Info<< "Writing field " << fieldName << " to " << os.name() << endl;
63  }
64 
65  // no header, just write values
66  forAll(values, elemI)
67  {
68  os << elemI+1 << ' ';
69  writeData(os, values[elemI]);
70  }
71 
72  return os.name();
73 }
74 
75 
76 // ************************************************************************* //
Foam::starcdSurfaceWriter::writeTemplate
fileName writeTemplate(const fileName &outputDir, const fileName &surfaceName, const pointField &points, const faceList &faces, const word &fieldName, const Field< Type > &values, const bool isNodeValues, const bool verbose) const
Templated write operation.
OSspecific.H
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
OFstream.H
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::Info
messageStream Info
writeData
const bool writeData(readBool(pdfDictionary.lookup("writeData")))
Foam::starcdSurfaceWriter::writeData
static void writeData(Ostream &, const Type &)
Definition: starcdSurfaceWriterTemplates.C:33
Foam::isDir
bool isDir(const fileName &)
Does the name exist as a DIRECTORY in the file system?
Definition: POSIX.C:615
Foam::OFstream
Output to file stream.
Definition: OFstream.H:81
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::OFstream::name
const fileName & name() const
Return the name of the stream.
Definition: OFstream.H:118
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
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