triSurfaceLoader.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) 2017-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::triSurfaceLoader
28 
29 Description
30  Convenience class for loading single or multiple surface files
31  from the constant/triSurface (or other) directory.
32 
33  Surfaces selection based on word, wordRe, list of wordRe.
34  If multiple surfaces are selected, they are concatenated into a
35  single surface with offset faces,points,regions.
36 
37 SourceFiles
38  triSurfaceLoader.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef triSurfaceLoader_H
43 #define triSurfaceLoader_H
44 
45 #include "triSurface.H"
46 #include "wordRes.H"
47 #include "Enum.H"
48 #include "hashedWordList.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward declaration of classes
56 class triSurfaceLoader;
57 class Time;
58 
59 /*---------------------------------------------------------------------------*\
60  Class triSurfaceLoader Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class triSurfaceLoader
64 {
65 public:
66 
67  //- The file loading options for triSurfaceLoader
68  enum loadingOption
69  {
74  };
75 
76  //- The loading enumeration names
78 
79 
80 private:
81 
82  // Private data
83 
84  //- The directory to load from (eg, case/constant/triSurface)
85  fileName directory_;
86 
87  //- All available files
88  hashedWordList available_;
89 
90  //- Selected files
91  hashedWordList selected_;
92 
93 
94  // Private Member Functions
95 
96  //- No copy construct
97  triSurfaceLoader(const triSurfaceLoader&) = delete;
98 
99  //- No copy assignment
100  void operator=(const triSurfaceLoader&) = delete;
101 
102 public:
103 
104  // Constructors
105 
106  //- Construct with directory name
108 
109  //- Construct with time. Selects "constant/triSurface" directory.
110  triSurfaceLoader(const Time& runTime);
111 
112 
113  //- Destructor
114  ~triSurfaceLoader() = default;
115 
116 
117  // Member Functions
118 
119  // Access
120 
121  //- The directory being used
122  inline const fileName& directory() const
123  {
124  return directory_;
125  }
126 
127  //- The list of available files
128  inline const hashedWordList& available() const
129  {
130  return available_;
131  }
132 
133  //- The list of selected files
134  inline const hashedWordList& selected() const
135  {
136  return selected_;
137  }
138 
139 
140  // Edit
141 
142  //- Read directory and populate the 'available' files.
143  // Automatically called on construction.
144  label readDir();
145 
146  //- Populates 'selected' with all available files.
147  label selectAll();
148 
149  //- Populates 'selected' with a subset of the available files.
150  label select(const word& name);
151 
152  //- Populates 'selected' with a subset of the available files.
153  label select(const wordRe& mat);
154 
155  //- Populates 'selected' with a subset of the available files.
156  label select(const UList<wordRe>& matcher);
157 
158  //- Load a single file, or load and combine multiple selected files
159  // Optionally scale the surface(s) on input, with a zero or negative
160  // scale factor treated as no scaling.
162  (
163  const enum loadingOption opt = loadingOption::OFFSET_REGION,
164  const scalar scaleFactor = -1
165  ) const;
166 
167 };
168 
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 } // End namespace Foam
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #endif
177 
178 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
wordRes.H
Foam::Enum< loadingOption >
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::triSurfaceLoader::loadingOption
loadingOption
The file loading options for triSurfaceLoader.
Definition: triSurfaceLoader.H:67
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::triSurfaceLoader::loadingOptionNames
static const Enum< loadingOption > loadingOptionNames
The loading enumeration names.
Definition: triSurfaceLoader.H:76
Foam::triSurfaceLoader::available
const hashedWordList & available() const
The list of available files.
Definition: triSurfaceLoader.H:127
triSurface.H
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:80
Foam::triSurfaceLoader::FILE_REGION
"file" = One region for each file
Definition: triSurfaceLoader.H:70
Foam::triSurfaceLoader::select
label select(const word &name)
Populates 'selected' with a subset of the available files.
Definition: triSurfaceLoader.C:104
Foam::hashedWordList
A wordList with hashed named lookup, which can be faster in some situations than using the normal lis...
Definition: hashedWordList.H:54
Foam::triSurfaceLoader::MERGE_REGION
"merge" = Merge regions by name
Definition: triSurfaceLoader.H:72
Foam::triSurfaceLoader::~triSurfaceLoader
~triSurfaceLoader()=default
Destructor.
Foam::triSurfaceLoader::selected
const hashedWordList & selected() const
The list of selected files.
Definition: triSurfaceLoader.H:133
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::triSurfaceLoader::readDir
label readDir()
Read directory and populate the 'available' files.
Definition: triSurfaceLoader.C:72
Foam::triSurfaceLoader
Convenience class for loading single or multiple surface files from the constant/triSurface (or other...
Definition: triSurfaceLoader.H:62
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
hashedWordList.H
Foam::triSurfaceLoader::SINGLE_REGION
"single" = One region for all files
Definition: triSurfaceLoader.H:69
Foam::UList
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:103
Foam::triSurfaceLoader::selectAll
label selectAll()
Populates 'selected' with all available files.
Definition: triSurfaceLoader.C:97
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::triSurfaceLoader::OFFSET_REGION
"offset" = Offset regions per file
Definition: triSurfaceLoader.H:71
Foam::triSurfaceLoader::directory
const fileName & directory() const
The directory being used.
Definition: triSurfaceLoader.H:121
Foam::triSurfaceLoader::load
autoPtr< triSurface > load(const enum loadingOption opt=loadingOption::OFFSET_REGION, const scalar scaleFactor=-1) const
Load a single file, or load and combine multiple selected files.
Definition: triSurfaceLoader.C:212
Enum.H