initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / surfMesh / surfaceFormats / ftr / FTRsurfaceFormat.C
blobd0ccd5a66f1adf0d5c7d37c28c47c4a604a9ad5f
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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 "FTRsurfaceFormat.H"
28 #include "Keyed.H"
29 #include "IFstream.H"
31 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
33 template<class Face>
34 Foam::fileFormats::FTRsurfaceFormat<Face>::FTRsurfaceFormat
36     const fileName& filename
39     read(filename);
43 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
45 template<class Face>
46 bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
48     const fileName& filename
51     this->clear();
53     IFstream is(filename);
54     if (!is.good())
55     {
56         FatalErrorIn
57         (
58             "fileFormats::FTRsurfaceFormat::read(const fileName&)"
59         )
60             << "Cannot read file " << filename
61             << exit(FatalError);
62     }
64     List<ftrPatch> ftrPatches(is);
66     // points read directly
67     is >> this->storedPoints();
69     // triFaces read with attached keys
70     List< Keyed<triFace> > facesRead(is);
72     List<Face>  faceLst(facesRead.size());
73     List<label> zoneIds(facesRead.size());
75     // disentangle faces/keys - already triangulated
76     forAll(facesRead, faceI)
77     {
78         // unfortunately cannot transfer to save memory
79         faceLst[faceI] = facesRead[faceI];
80         zoneIds[faceI] = facesRead[faceI].key();
81     }
83     this->storedFaces().transfer(faceLst);
84     this->storedZoneIds().transfer(zoneIds);
85     facesRead.clear();
87     // change ftrPatch into surfZoneIdentifier
88     List<surfZoneIdentifier> newZones(ftrPatches.size());
89     forAll(newZones, zoneI)
90     {
91         newZones[zoneI] = surfZoneIdentifier
92         (
93             ftrPatches[zoneI].name(),
94             zoneI
95         );
96     }
98     this->storedZoneToc().transfer(newZones);
99     return true;
103 // ************************************************************************* //