boundaryDataSurfaceWriter.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) 2015 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 
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  makeSurfaceWriterType(boundaryDataSurfaceWriter);
34 }
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
39 :
41 {}
42 
43 
44 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
45 
47 {}
48 
49 
50 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
51 
53 (
54  const fileName& outputDir,
55  const fileName& surfaceName,
56  const pointField& points,
57  const faceList& faces,
58  const bool verbose
59 ) const
60 {
61  const fileName baseDir(outputDir.path()/surfaceName);
62  const fileName timeName(outputDir.name());
63 
64 
65  // Construct dummy time to use as an objectRegistry
66  const fileName caseDir(getEnv("FOAM_CASE"));
67  Time dummyTime
68  (
69  caseDir.path(), //rootPath,
70  caseDir.name(), //caseName,
71  "system", //systemName,
72  "constant", //constantName,
73  false //enableFunctionObjects
74  );
75 
76 
77  // Write points
78  if (verbose)
79  {
80  Info<< "Writing points to " << baseDir/"points" << endl;
81  }
82 
83  pointIOField pts
84  (
85  IOobject
86  (
87  baseDir/"points",
88  dummyTime,
91  false
92  ),
93  points
94  );
95 
96  {
97  // Do like regIOobject::writeObject but don't do instance() adaptation
98  // since this would write to e.g. 0/ instead of postProcessing/
99 
100  // Try opening an OFstream for object
101  mkDir(pts.path());
102  OFstream os(pts.objectPath());
103 
104  pts.writeHeader(os);
105  pts.writeData(os);
106  pts.writeEndDivider(os);
107  }
108 
109  return baseDir;
110 }
111 
112 
113 // create write methods
115 
116 
117 // ************************************************************************* //
boundaryDataSurfaceWriter.H
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::boundaryDataSurfaceWriter::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: boundaryDataSurfaceWriter.C:53
Foam::surfaceWriter
Base class for surface writers.
Definition: surfaceWriter.H:54
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::IOField< vector >
Foam::boundaryDataSurfaceWriter
A surfaceWriter for outputting to a form useable for the timeVaryingMapped boundary condition....
Definition: boundaryDataSurfaceWriter.H:88
Foam::IOobject::writeEndDivider
static Stream & writeEndDivider(Stream &os)
Write the standard end file divider.
Definition: IOobjectI.H:118
Foam::fileName::path
fileName path() const
Return directory path name (part before last /)
Definition: fileName.C:293
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::boundaryDataSurfaceWriter::~boundaryDataSurfaceWriter
virtual ~boundaryDataSurfaceWriter()
Destructor.
Definition: boundaryDataSurfaceWriter.C:46
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
Foam::fileName::name
word name() const
Return file name (part beyond last /)
Definition: fileName.C:212
Foam::IOobject::objectPath
fileName objectPath() const
Return complete path + object name.
Definition: IOobject.H:376
Foam::IOobject::writeHeader
bool writeHeader(Ostream &) const
Write header.
Definition: IOobjectWriteHeader.C:67
makeSurfaceWriterMethods.H
Convenience macros for instantiating writer methods for surfaceWriter classes.
Foam::getEnv
string getEnv(const word &)
Return environment variable of given name.
Definition: POSIX.C:101
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
Foam::Info
messageStream Info
Foam::defineSurfaceWriterWriteFields
defineSurfaceWriterWriteFields(nastranSurfaceWriter)
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
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
timeName
word timeName
Definition: getTimeIndex.H:3
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
Foam::boundaryDataSurfaceWriter::boundaryDataSurfaceWriter
boundaryDataSurfaceWriter()
Construct null.
Definition: boundaryDataSurfaceWriter.C:38
Foam::IOobject::path
fileName path() const
Return complete path.
Definition: IOobject.C:293
caseDir
static fileName caseDir
Definition: globalFoam.H:42
Foam::IOField::writeData
bool writeData(Ostream &) const
Pure virtual writaData function.
Definition: IOField.C:169