FTRsurfaceFormat.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-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 
26 #include "FTRsurfaceFormat.H"
27 #include "Keyed.H"
28 #include "IFstream.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class Face>
34 (
35  const fileName& filename
36 )
37 {
38  read(filename);
39 }
40 
41 
42 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
43 
44 template<class Face>
46 (
47  const fileName& filename
48 )
49 {
50  this->clear();
51 
52  IFstream is(filename);
53  if (!is.good())
54  {
56  << "Cannot read file " << filename
57  << exit(FatalError);
58  }
59 
60  List<ftrPatch> ftrPatches(is);
61 
62  // points read directly
63  is >> this->storedPoints();
64 
65  // triFaces read with attached keys
66  List< Keyed<triFace> > facesRead(is);
67 
68  List<Face> faceLst(facesRead.size());
69  List<label> zoneIds(facesRead.size());
70 
71  // disentangle faces/keys - already triangulated
72  forAll(facesRead, faceI)
73  {
74  // unfortunately cannot transfer to save memory
75  faceLst[faceI] = facesRead[faceI];
76  zoneIds[faceI] = facesRead[faceI].key();
77  }
78 
79  this->storedFaces().transfer(faceLst);
80  this->storedZoneIds().transfer(zoneIds);
81  facesRead.clear();
82 
83  // change ftrPatch into surfZoneIdentifier
84  List<surfZoneIdentifier> newZones(ftrPatches.size());
85  forAll(newZones, zoneI)
86  {
87  newZones[zoneI] = surfZoneIdentifier
88  (
89  ftrPatches[zoneI].name(),
90  zoneI
91  );
92  }
93 
94  this->storedZoneToc().transfer(newZones);
95  return true;
96 }
97 
98 
99 // ************************************************************************* //
Foam::fileFormats::FTRsurfaceFormat::FTRsurfaceFormat
FTRsurfaceFormat(const FTRsurfaceFormat< Face > &)
Disallow default bitwise copy construct.
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
clear
UEqn clear()
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::IFstream
Input from file stream.
Definition: IFstream.H:81
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::List::transfer
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
FTRsurfaceFormat.H
Foam::surfZoneIdentifier
An identifier for a surface zone on a meshed surface.
Definition: surfZoneIdentifier.H:60
IFstream.H
Foam::FatalError
error FatalError
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Keyed.H
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
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
Foam::List::clear
void clear()
Clear the list, i.e. set size to zero.
Definition: List.C:379
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::IOstream::good
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:333
Foam::fileFormats::FTRsurfaceFormat::read
virtual bool read(const fileName &)
Read from file.
Definition: FTRsurfaceFormat.C:46
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47