STARCDsurfaceFormatCore.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011 OpenFOAM Foundation
9 Copyright (C) 2016-2018 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
30#include "clock.H"
31#include "regExp.H"
32#include "IFstream.H"
33#include "SubStrings.H"
34
35// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
36
37// parse things like this:
38// CTNAME 1 someName
39// don't bother with the older comma-delimited format
40
43{
45
46 if (!is.good())
47 {
48 return lookup;
49 }
50
51 const regExp ctname
52 (
53 " *CTNA[^ ]*" // keyword - min 4 chars
54 "[[:space:]]+" // space delimited
55 "([0-9]+)" // 1: <digits>
56 "[[:space:]]+" // space delimited
57 "([^,[:space:]].*)", // 2: <name>
58 true // ignore case
59 );
60
61 string line;
63
64 while (is.good() && is.getLine(line).good())
65 {
66 if (ctname.match(line, groups))
67 {
68 const label tableId = readLabel(groups.str(1));
69 const word tableName = word::validate(groups.str(2), true);
70
71 if (!tableName.empty())
72 {
73 lookup.insert(tableId, tableName);
74 }
75 }
76 }
77
78 return lookup;
79}
80
81
83(
84 Ostream& os,
85 const UList<point>& pts,
86 const label nFaces,
87 const UList<surfZone>& zoneLst
88)
89{
90 const word caseName = os.name().nameLessExt();
91
92 os << "! STARCD file written " << clock::dateTime().c_str() << nl
93 << "! " << pts.size() << " points, " << nFaces << " faces" << nl
94 << "! case " << caseName << nl
95 << "! ------------------------------" << nl;
96
97 forAll(zoneLst, zoneI)
98 {
99 os << "ctable " << zoneI + 1 << " shell" << " ,,,,,," << nl
100 << "ctname " << zoneI + 1 << " "
101 << zoneLst[zoneI].name() << nl;
102 }
103
104 os << "! ------------------------------" << nl
105 << "*set icvo mxv - 1" << nl
106 << "vread " << caseName << ".vrt icvo,,,coded" << nl
107 << "cread " << caseName << ".cel icvo,,,add,coded" << nl
108 << "*set icvo" << nl
109 << "! end" << nl;
110
111 os.flush();
112}
113
114
115// ************************************************************************* //
bool good() const noexcept
True if next operation might succeed.
Definition: IOstream.H:233
Generic input stream using a standard (STL) stream.
Definition: ISstream.H:58
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
Definition: ISstreamI.H:76
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
static std::string dateTime()
Definition: clock.C:60
static void writeCase(Ostream &os, const UList< point > &pts, const label nFaces, const UList< surfZone > &zoneLst)
static Map< word > readInpCellTable(ISstream &is)
virtual void validate()
Validate the turbulence fields after construction.
Definition: kkLOmega.C:597
A line primitive.
Definition: line.H:68
Lookup type of boundary radiation properties.
Definition: lookup.H:66
Wrapper around C++11 regular expressions with some additional prefix-handling. The prefix-handling is...
Definition: regExpCxx.H:83
std::smatch results_type
Type for matches.
Definition: regExpCxx.H:114
bool match(const std::string &text) const
True if the regex matches the entire text.
Definition: regExpCxxI.H:289
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition: label.H:66
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333