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 -------------------------------------------------------------------------------
11 License
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 Class
28  Foam::fileFormats::surfaceFormatsCore
29 
30 Description
31  A collection of helper functions for reading/writing surface formats.
32 
33 SourceFiles
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"
46 #include "surfZoneIdentifierList.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward Declarations
54 class ISstream;
55 class Time;
56 class triSurface;
57 class IOobject;
58 class dictionary;
59 
60 namespace fileFormats
61 {
62 
63 /*---------------------------------------------------------------------------*\
64  Class fileFormats::surfaceFormatsCore Declaration
65 \*---------------------------------------------------------------------------*/
66 
68 {
69 protected:
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 
135 public:
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 // ************************************************************************* //
Foam::fileFormats::surfaceFormatsCore::checkFile
static fileName checkFile(const IOobject &io, const bool isGlobal=true)
Return fileName to load IOobject from.
Definition: surfaceFormatsCore.C:257
wordRes.H
Foam::fileFormats::surfaceFormatsCore
A collection of helper functions for reading/writing surface formats.
Definition: surfaceFormatsCore.H:66
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::fileFormats::surfaceFormatsCore::nativeExt
static word nativeExt
The file extension corresponding to 'native' surface format.
Definition: surfaceFormatsCore.H:140
Foam::ISstream
Generic input stream using a standard (STL) stream.
Definition: ISstream.H:55
Foam::fileFormats::surfaceFormatsCore::getSelectedPatches
static labelList getSelectedPatches(const surfZoneList &patches, const wordRes &allow, const wordRes &deny=wordRes())
Return ids for zone/patch that match by name.
Definition: surfaceFormatsCore.C:60
Foam::HashSet< word, Hash< word > >
Foam::fileFormats::surfaceFormatsCore::~surfaceFormatsCore
virtual ~surfaceFormatsCore()=default
Destructor.
Foam::fileFormats::surfaceFormatsCore::surfaceFormatsCore
surfaceFormatsCore()=default
Default construct.
Foam::fileFormats::surfaceFormatsCore::checkSupport
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.
Definition: surfaceFormatsCore.C:326
Map.H
labelList.H
Foam::fileFormats::surfaceFormatsCore::getLineNoComment
static string getLineNoComment(ISstream &is, const char comment='#')
Read non-empty and non-comment line.
Definition: surfaceFormatsCore.C:43
HashSet.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::fileFormats::surfaceFormatsCore::oneZone
static List< surfZone > oneZone(const Container &container, const word &name="zone0")
Definition: surfaceFormatsCore.H:83
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
f
labelList f(nPoints)
Foam::List< surfZone >
Foam::surfZone
A surface zone on a MeshedSurface.
Definition: surfZone.H:56
Foam::fileFormats::surfaceFormatsCore::relativeFilePath
static fileName relativeFilePath(const IOobject &io, const fileName &f, const bool isGlobal=true)
Return fileName.
Definition: surfaceFormatsCore.C:178
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
surfZoneList.H
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::fileFormats::surfaceFormatsCore::findFile
static fileName findFile(const IOobject &io, const bool isGlobal=true)
Definition: surfaceFormatsCore.C:204
surfZoneIdentifierList.H