Loading...
Searching...
No Matches
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-2022 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
34// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
35
36// parse things like this:
37// CTNAME 1 someName
38// don't bother with the older comma-delimited format
39
42{
44
45 if (!is.good())
46 {
47 return lookup;
48 }
49
50 const regExp ctname
51 (
52 " *CTNA[^ ]*" // keyword - min 4 chars
53 "[[:space:]]+" // space delimited
54 "([0-9]+)" // 1: <digits>
55 "[[:space:]]+" // space delimited
56 "([^,[:space:]].*)", // 2: <name>
57 true // ignore case
58 );
59
60 string line;
62
63 while (is.good() && is.getLine(line).good())
64 {
65 if (ctname.match(line, groups))
66 {
67 const label tableId = readLabel(groups.str(1));
68 const word tableName = word::validate(groups.str(2), true);
69
70 if (!tableName.empty())
71 {
72 lookup.insert(tableId, tableName);
73 }
74 }
75 }
76
77 return lookup;
78}
79
80
82(
83 Ostream& os,
84 const UList<point>& pts,
85 const label nFaces,
86 const UList<surfZone>& zoneLst
87)
88{
89 const word caseName = os.name().stem();
90
91 os << "! STARCD file written " << clock::dateTime().c_str() << nl
92 << "! " << pts.size() << " points, " << nFaces << " faces" << nl
93 << "! case " << caseName << nl
94 << "! ------------------------------" << nl;
95
96 forAll(zoneLst, zoneI)
97 {
98 os << "ctable " << zoneI + 1 << " shell" << " ,,,,,," << nl
99 << "ctname " << zoneI + 1 << " "
100 << zoneLst[zoneI].name() << nl;
101 }
102
103 os << "! ------------------------------" << nl
104 << "*set icvo mxv - 1" << nl
105 << "vread " << caseName << ".vrt icvo,,,coded" << nl
106 << "cread " << caseName << ".cel icvo,,,add,coded" << nl
107 << "*set icvo" << nl
108 << "! end" << nl;
109
110 os.flush();
111}
112
113
114// ************************************************************************* //
bool good() const noexcept
True if next operation might succeed.
Definition IOstream.H:281
Generic input stream using a standard (STL) stream.
Definition ISstream.H:54
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
Definition ISstreamI.H:69
A HashTable to objects of type <T> with a label key.
Definition Map.H:54
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
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:89
static std::string dateTime()
The current wall-clock date/time (in local time) as a string in ISO-8601 format (yyyy-mm-ddThh:mm:ss)...
Definition clock.C:53
static void writeCase(Ostream &os, const UList< point > &pts, const label nFaces, const UList< surfZone > &zoneLst)
static Map< word > readInpCellTable(ISstream &is)
A line primitive.
Definition line.H:180
Lookup type of boundary radiation properties.
Definition lookup.H:60
std::smatch results_type
Type for matches.
Definition regExpCxx.H:124
bool match(const std::string &text) const
True if the regex matches the entire text.
Definition regExpCxxI.H:282
A class for handling words, derived from Foam::string.
Definition word.H:66
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
Definition word.C:39
OBJstream os(runTime.globalPath()/outputName)
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition label.H:63
regExpCxx regExp
Selection of preferred regular expression implementation.
Definition regExpFwd.H:37
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
const pointField & pts
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299