fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / surfMesh / MeshedSurfaceProxy / MeshedSurfaceProxy.C
blobf8b8ac7cbe62300f8b8081f12c3c04c682ee0594
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "MeshedSurfaceProxy.H"
29 #include "Time.H"
30 #include "surfMesh.H"
31 #include "OFstream.H"
32 #include "ListOps.H"
34 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
36 template<class Face>
37 Foam::wordHashSet Foam::MeshedSurfaceProxy<Face>::writeTypes()
39     return wordHashSet(*writefileExtensionMemberFunctionTablePtr_);
43 template<class Face>
44 bool Foam::MeshedSurfaceProxy<Face>::canWriteType
46     const word& ext,
47     const bool verbose
50     return checkSupport(writeTypes(), ext, verbose, "writing");
54 template<class Face>
55 void Foam::MeshedSurfaceProxy<Face>::write
57     const fileName& name,
58     const MeshedSurfaceProxy& surf
61     if (debug)
62     {
63         Info<< "MeshedSurfaceProxy::write"
64             "(const fileName&, const MeshedSurfaceProxy&) : "
65             "writing to " << name
66             << endl;
67     }
69     word ext = name.ext();
71     typename writefileExtensionMemberFunctionTable::iterator mfIter =
72         writefileExtensionMemberFunctionTablePtr_->find(ext);
74     if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
75     {
76         FatalErrorIn
77         (
78             "MeshedSurfaceProxy::write(const fileName&)"
79         )   << "Unknown file extension " << ext << nl << nl
80             << "Valid types are :" << endl
81             << writeTypes()
82             << exit(FatalError);
83     }
85     mfIter()(name, surf);
89 template<class Face>
90 void Foam::MeshedSurfaceProxy<Face>::write
92     const Time& t,
93     const word& surfName
94 ) const
96     // the surface name to be used
97     word name(surfName.size() ? surfName : surfaceRegistry::defaultName);
99     if (debug)
100     {
101         Info<< "MeshedSurfaceProxy::write"
102             "(const Time&, const word&) : "
103             "writing to " << name
104             << endl;
105     }
108     // the local location
109     const fileName objectDir
110     (
111         t.timePath()/surfaceRegistry::prefix/name/surfMesh::meshSubDir
112     );
114     if (!isDir(objectDir))
115     {
116         mkDir(objectDir);
117     }
120     // write surfMesh/points
121     {
122         pointIOField io
123         (
124             IOobject
125             (
126                 "points",
127                 t.timeName(),
128                 surfMesh::meshSubDir,
129                 t,
130                 IOobject::NO_READ,
131                 IOobject::NO_WRITE,
132                 false
133             )
134         );
136         OFstream os
137         (
138             objectDir/io.name(),
139             ios_base::out|ios_base::trunc,
140             t.writeFormat(),
141             IOstream::currentVersion,
142             t.writeCompression()
143         );
145         io.writeHeader(os);
147         os  << this->points();
149         io.writeEndDivider(os);
150     }
153     // write surfMesh/faces
154     {
155         faceIOList io
156         (
157             IOobject
158             (
159                 "faces",
160                 t.timeName(),
161                 surfMesh::meshSubDir,
162                 t,
163                 IOobject::NO_READ,
164                 IOobject::NO_WRITE,
165                 false
166             )
167         );
169         OFstream os
170         (
171             objectDir/io.name(),
172             ios_base::out|ios_base::trunc,
173             t.writeFormat(),
174             IOstream::currentVersion,
175             t.writeCompression()
176         );
177         io.writeHeader(os);
179         if (this->useFaceMap())
180         {
181             // this is really a bit annoying (and wasteful) but no other way
182             os  << reorder(this->faceMap(), this->faces());
183         }
184         else
185         {
186             os  << this->faces();
187         }
189         io.writeEndDivider(os);
190     }
193     // write surfMesh/surfZones
194     {
195         surfZoneIOList io
196         (
197             IOobject
198             (
199                 "surfZones",
200                 t.timeName(),
201                 surfMesh::meshSubDir,
202                 t,
203                 IOobject::NO_READ,
204                 IOobject::NO_WRITE,
205                 false
206             )
207         );
209         // write as ascii
210         OFstream os(objectDir/io.name());
211         io.writeHeader(os);
213         os  << this->surfZones();
215         io.writeEndDivider(os);
216     }
221 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
223 template<class Face>
224 Foam::MeshedSurfaceProxy<Face>::MeshedSurfaceProxy
226     const pointField& pointLst,
227     const List<Face>& faceLst,
228     const List<surfZone>& zoneLst,
229     const List<label>& faceMap
232     points_(pointLst),
233     faces_(faceLst),
234     zones_(zoneLst),
235     faceMap_(faceMap)
239 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
241 template<class Face>
242 Foam::MeshedSurfaceProxy<Face>::~MeshedSurfaceProxy()
246 // ************************************************************************* //