surfaceFormatsCore.H
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) 2017-2020 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
27Class
28 Foam::fileFormats::surfaceFormatsCore
29
30Description
31 A collection of helper functions for reading/writing surface formats.
32
33SourceFiles
34 surfaceFormatsCore.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef surfaceFormatsCore_H
39#define surfaceFormatsCore_H
40
41#include "Map.H"
42#include "HashSet.H"
43#include "wordRes.H"
44#include "labelList.H"
45#include "surfZoneList.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
52
53// Forward Declarations
54class ISstream;
55class Time;
56class triSurface;
57class IOobject;
58class dictionary;
59
60namespace fileFormats
61{
62
63/*---------------------------------------------------------------------------*\
64 Class fileFormats::surfaceFormatsCore Declaration
65\*---------------------------------------------------------------------------*/
68{
69protected:
70
71 // Friendship with triSurface (for IO helpers)
72 friend class ::Foam::triSurface;
73
74
75 // General
76
77 //- Read non-empty and non-comment line
78 static string getLineNoComment(ISstream& is, const char comment='#');
79
80 //- Return a surfZone list with a single entry, the size of which
81 //- corresponds to that of the container
82 template<class Container>
84 (
85 const Container& container,
86 const word& name = "zone0"
87 )
88 {
89 return List<surfZone>(1, surfZone(name, container.size()));
90 }
91
92 //- Return ids for zone/patch that match by name.
93 // Uses a combination of allow and deny lists.
94 //
95 // \see Foam::stringListOps::findMatching for details about matching
97 (
98 const surfZoneList& patches,
99 const wordRes& allow,
100 const wordRes& deny = wordRes()
101 );
102
103
104 // IO helpers
105
106 //- Return fileName.
107 // If fileName is relative gets treated as local to IOobject.
108 // Duplicate of triSurfaceMesh::relativeFilePath
110 (
111 const IOobject& io,
112 const fileName& f,
113 const bool isGlobal = true
114 );
115
116 //- Return fileName to load IOobject from.
117 // Fatal if the file does not exist
118 static fileName checkFile
119 (
120 const IOobject& io,
121 const bool isGlobal = true
122 );
123
124 //- Return fileName to load IOobject from.
125 // Supports optional override of fileName with "file" entry
126 // Fatal if the file does not exist
127 static fileName checkFile
128 (
129 const IOobject& io,
130 const dictionary& dict,
131 const bool isGlobal = true
132 );
133
134
135public:
136
137 // Static Data
138
139 //- The file extension corresponding to 'native' surface format
140 // Normally "ofs" (mnemonic: OF = OpenFOAM, S = Surface)
141 static word nativeExt;
142
143
144 // Static Member Functions
145
146 //- Verbose checking of fileType in the list of available types
147 static bool checkSupport
148 (
149 const wordHashSet& available,
150 const word& fileType,
151 const bool verbose = false,
152 const char* functionName = nullptr
153 );
154
155 //- Use IOobject information to resolve file to load from,
156 //- or empty if the file does not exist.
157 static fileName findFile
158 (
159 const IOobject& io,
160 const bool isGlobal = true
161 );
162
163 //- Use IOobject information to resolve file to load from,
164 //- or empty if the file does not exist.
165 // Supports optional override of fileName with "file" entry
166 static fileName findFile
167 (
168 const IOobject& io,
169 const dictionary& dict,
170 const bool isGlobal = true
171 );
172
173
174// //- Return the local file name (within time directory)
175// // NEEDS FIXING
176// static fileName localMeshFileName
177// (
178// const word& surfName = word::null
179// );
180//
181// //- Find instance with surfName
182// // NEEDS FIXING
183// static fileName findMeshInstance
184// (
185// const Time&,
186// const word& surfName = word::null
187// );
188//
189// //- Find mesh file with surfName
190// // NEEDS FIXING
191// static fileName findMeshFile
192// (
193// const Time&,
194// const word& surfName = word::null
195// );
196
197
198 // Constructors
199
200 //- Default construct
201 surfaceFormatsCore() = default;
202
203
204 //- Destructor
205 virtual ~surfaceFormatsCore() = default;
206};
207
208
209// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210
211} // End namespace fileFormats
212} // End namespace Foam
213
214// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215
216#endif
217
218// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
Generic input stream using a standard (STL) stream.
Definition: ISstream.H:58
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A collection of helper functions for reading/writing surface formats.
virtual ~surfaceFormatsCore()=default
Destructor.
static labelList getSelectedPatches(const surfZoneList &patches, const wordRes &allow, const wordRes &deny=wordRes())
Return ids for zone/patch that match by name.
surfaceFormatsCore()=default
Default construct.
static fileName checkFile(const IOobject &io, const bool isGlobal=true)
Return fileName to load IOobject from.
static fileName findFile(const IOobject &io, const bool isGlobal=true)
static string getLineNoComment(ISstream &is, const char comment='#')
Read non-empty and non-comment line.
static List< surfZone > oneZone(const Container &container, const word &name="zone0")
static fileName relativeFilePath(const IOobject &io, const fileName &f, const bool isGlobal=true)
Return fileName.
static word nativeExt
The file extension corresponding to 'native' surface format.
static bool checkSupport(const wordHashSet &available, const word &fileType, const bool verbose=false, const char *functionName=nullptr)
Verbose checking of fileType in the list of available types.
A class for handling file names.
Definition: fileName.H:76
A surface zone on a MeshedSurface.
Definition: surfZone.H:59
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
const polyBoundaryMesh & patches
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
labelList f(nPoints)
dictionary dict