OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

FTRsurfaceFormat.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "FTRsurfaceFormat.H"
00028 #include "Keyed.H"
00029 #include "IFstream.H"
00030 
00031 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00032 
00033 template<class Face>
00034 Foam::fileFormats::FTRsurfaceFormat<Face>::FTRsurfaceFormat
00035 (
00036     const fileName& filename
00037 )
00038 {
00039     read(filename);
00040 }
00041 
00042 
00043 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00044 
00045 template<class Face>
00046 bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
00047 (
00048     const fileName& filename
00049 )
00050 {
00051     this->clear();
00052 
00053     IFstream is(filename);
00054     if (!is.good())
00055     {
00056         FatalErrorIn
00057         (
00058             "fileFormats::FTRsurfaceFormat::read(const fileName&)"
00059         )
00060             << "Cannot read file " << filename
00061             << exit(FatalError);
00062     }
00063 
00064     List<ftrPatch> ftrPatches(is);
00065 
00066     // points read directly
00067     is >> this->storedPoints();
00068 
00069     // triFaces read with attached keys
00070     List< Keyed<triFace> > facesRead(is);
00071 
00072     List<Face>  faceLst(facesRead.size());
00073     List<label> zoneIds(facesRead.size());
00074 
00075     // disentangle faces/keys - already triangulated
00076     forAll(facesRead, faceI)
00077     {
00078         // unfortunately cannot transfer to save memory
00079         faceLst[faceI] = facesRead[faceI];
00080         zoneIds[faceI] = facesRead[faceI].key();
00081     }
00082 
00083     this->storedFaces().transfer(faceLst);
00084     this->storedZoneIds().transfer(zoneIds);
00085     facesRead.clear();
00086 
00087     // change ftrPatch into surfZoneIdentifier
00088     List<surfZoneIdentifier> newZones(ftrPatches.size());
00089     forAll(newZones, zoneI)
00090     {
00091         newZones[zoneI] = surfZoneIdentifier
00092         (
00093             ftrPatches[zoneI].name(),
00094             zoneI
00095         );
00096     }
00097 
00098     this->storedZoneToc().transfer(newZones);
00099     return true;
00100 }
00101 
00102 
00103 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd