STARCDsurfaceFormatCore.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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 
27 #include "clock.H"
28 #include "regExp.H"
29 #include "IStringStream.H"
30 
31 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
32 
33 // parse things like this:
34 // CTNAME 1 someName
35 // don't bother with the older comma-delimited format
36 
39 (
40  IFstream& is
41 )
42 {
44 
45  regExp ctnameRE
46  (
47  " *CTNA[^ ]*" // keyword - min 4 chars
48  "[[:space:]]+" // space delimited
49  "([0-9]+)" // 1: <digits>
50  "[[:space:]]+" // space delimited
51  "([^,[:space:]].*)", // 2: <name>
52  true // ignore case
53  );
54 
55  string line;
56  List<string> groups;
57  while (is.good() && is.getLine(line).good())
58  {
59  if (ctnameRE.match(line, groups))
60  {
61  const label tableId = atoi(groups[0].c_str());
62 
63  // strip bad chars
64  string::stripInvalid<word>(groups[1]);
65 
66  if (!groups[1].empty())
67  {
68  lookup.insert(tableId, groups[1]);
69  }
70  }
71  }
72 
73  return lookup;
74 }
75 
76 
78 (
79  Ostream& os,
80  const pointField& pointLst,
81  const label nFaces,
82  const UList<surfZone>& zoneLst
83 )
84 {
85  word caseName = os.name().lessExt().name();
86 
87  os << "! STAR-CD file written " << clock::dateTime().c_str() << nl
88  << "! " << pointLst.size() << " points, " << nFaces << " faces" << nl
89  << "! case " << caseName << nl
90  << "! ------------------------------" << nl;
91 
92  forAll(zoneLst, zoneI)
93  {
94  os << "ctable " << zoneI + 1 << " shell" << " ,,,,,," << nl
95  << "ctname " << zoneI + 1 << " "
96  << zoneLst[zoneI].name() << nl;
97  }
98 
99  os << "! ------------------------------" << nl
100  << "*set icvo mxv - 1" << nl
101  << "vread " << caseName << ".vrt icvo,,,coded" << nl
102  << "cread " << caseName << ".cel icvo,,,add,coded" << nl
103  << "*set icvo" << nl
104  << "! end" << nl;
105 
106  os.flush();
107 }
108 
109 
110 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A line primitive.
Definition: line.H:56
virtual void flush()=0
Flush stream.
bool match(const std::string &) const
Return true if it matches the entire string.
Definition: regExp.C:201
Wrapper around POSIX extended regular expressions.
Definition: regExp.H:61
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:330
bool insert(const label &, const T &newElmt)
Insert a new hashedEntry.
Definition: HashTableI.H:80
static void writeCase(Ostream &, const pointField &, const label nFaces, const UList< surfZone > &)
stressControl lookup("compactNormalStress") >> compactNormalStress
A class for handling words, derived from string.
Definition: word.H:59
virtual const fileName & name() const
Return the name of the stream.
Definition: IOstream.H:294
word name() const
Return file name (part beyond last /)
Definition: fileName.C:195
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static const char nl
Definition: Ostream.H:260
Input from file stream.
Definition: IFstream.H:81
ISstream & getLine(string &, const bool continuation=true)
Read line into a string.
Definition: ISstream.C:692
fileName lessExt() const
Return file name without extension (part before last .)
Definition: fileName.C:284
static Map< word > readInpCellTable(IFstream &)
A HashTable to objects of type <T> with a label key.
Definition: Map.H:49