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-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::triSurfaceLoader
28
29Description
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
37SourceFiles
38 triSurfaceLoader.C
39
40\*---------------------------------------------------------------------------*/
41
42#ifndef Foam_triSurfaceLoader_H
43#define Foam_triSurfaceLoader_H
44
45#include "triSurface.H"
46#include "wordRes.H"
47#include "Enum.H"
48#include "wordList.H"
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52namespace Foam
53{
54
55// Forward Declarations
56class triSurfaceLoader;
57class Time;
58
59/*---------------------------------------------------------------------------*\
60 Class triSurfaceLoader Declaration
61\*---------------------------------------------------------------------------*/
64{
65public:
66
67 //- The file loading options for triSurfaceLoader
68 enum loadingOption
69 {
74 };
75
76 //- The loading enumeration names
78
79
80private:
81
82 // Private Data
83
84 //- The directory to load from (eg, case/constant/triSurface)
85 fileName directory_;
86
87 //- All available files
88 wordList available_;
89
90 //- Selected files
91 wordList 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
102public:
103
104 // Constructors
105
106 //- Construct with directory name
108
109 //- Construct with time. Selects "constant/triSurface" directory.
111
112
113 //- Destructor
114 ~triSurfaceLoader() = default;
115
116
117 // Member Functions
118
119 // Access
120
121 //- The directory being used
122 const fileName& directory() const noexcept
123 {
124 return directory_;
125 }
126
127 //- The list of available files
128 const wordList& available() const noexcept
129 {
130 return available_;
131 }
132
133 //- The list of selected files
134 const wordList& selected() const noexcept
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 (
164 const scalar scaleFactor = -1
165 ) const;
166};
167
168
169// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170
171} // End namespace Foam
172
173// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174
175#endif
176
177// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
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
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A class for handling file names.
Definition: fileName.H:76
Convenience class for loading single or multiple surface files from the constant/triSurface (or other...
static const Enum< loadingOption > loadingOptionNames
The loading enumeration names.
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.
~triSurfaceLoader()=default
Destructor.
label readDir()
Read directory and populate the 'available' files.
label selectAll()
Populates 'selected' with all available files.
const wordList & available() const noexcept
The list of available files.
label select(const word &name)
Populates 'selected' with a subset of the available files.
const wordList & selected() const noexcept
The list of selected files.
const fileName & directory() const noexcept
The directory being used.
loadingOption
The file loading options for triSurfaceLoader.
@ FILE_REGION
"file" = One region for each file
@ MERGE_REGION
"merge" = Merge regions by name
@ OFFSET_REGION
"offset" = Offset regions per file
@ SINGLE_REGION
"single" = One region for all files
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:83
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59