41 { loadingOption::SINGLE_REGION,
"single" },
42 { loadingOption::FILE_REGION,
"file" },
44 { loadingOption::MERGE_REGION,
"merge" },
50Foam::triSurfaceLoader::triSurfaceLoader(
const fileName& directory)
52 directory_(directory),
60Foam::triSurfaceLoader::triSurfaceLoader(
const Time&
runTime)
62 directory_(
runTime.constantPath()/
"triSurface"),
91 available_ =
names.sortedToc();
93 return available_.
size();
99 selected_ = available_;
100 return selected_.size();
106 if (available_.found(
name))
109 selected_.front() =
name;
116 return selected_.size();
126 selected_ =
wordList(available_, foundIds);
128 else if (available_.found(
static_cast<const word&
>(mat)))
131 selected_.front() = mat;
136 <<
"Specified the surfaces " << mat <<
nl
137 <<
" - but could not find it"
141 return selected_.size();
154 DynamicList<label> foundIds(available_.size());
157 DynamicList<word> missing(matcher.size());
161 for (
const wordRe& mat : matcher)
168 for (
const label idx : indices)
170 if (hashedFound.insert(idx))
172 foundIds.append(idx);
178 const word& plain = mat;
179 const label idx = available_.find(plain);
183 if (hashedFound.insert(idx))
185 foundIds.append(idx);
188 else if (hashedMissing.insert(plain))
190 missing.append(plain);
198 <<
"Specified the surfaces " <<
flatOutput(matcher) <<
nl
199 <<
" - but could not find " <<
flatOutput(missing)
203 selected_ =
wordList(available_, foundIds);
204 return selected_.size();
210 const enum loadingOption opt,
211 const scalar scaleFactor
214 autoPtr<triSurface> output;
216 if (selected_.empty())
220 else if (selected_.size() == 1)
223 output.reset(
new triSurface(directory_/selected_[0], scaleFactor));
229 opt == loadingOption::SINGLE_REGION
230 || opt == loadingOption::FILE_REGION
238 if (surf.patches().size())
240 surf.patches().resize(1);
244 surf.patches().append
267 triSurface addsurf(directory_/selected_[surfi]);
269 addsurf.swapFaces(addfaces);
270 addsurf.swapPoints(addpoints);
288 case loadingOption::SINGLE_REGION:
303 case loadingOption::FILE_REGION:
319 case loadingOption::OFFSET_REGION:
333 f.region() += regoff;
339 case loadingOption::MERGE_REGION:
346 forAll(addpatches, patchi)
352 if (patchNameLookup.insert(patchName,
patchId))
359 patchId = patchNameLookup[patchName];
362 oldToNew.insert(patchi,
patchId);
370 f.region() = oldToNew[
f.region()];
379 faces.append(addfaces);
384 faces.transfer(addfaces);
390 if (scaleFactor > VSMALL)
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
A HashTable similar to std::unordered_map.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
void clear()
Remove all entries from table.
const word & name() const noexcept
Return the object name.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
void append(const T &val)
Append an element at the end of the list.
A HashTable to objects of type <T> with a label key.
void append(autoPtr< T > &ptr)
Move append an element to the end of the list.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T & first()
Access first element of the list, position [0].
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void size(const label n)
Older name for setAddressableSize.
bool empty() const noexcept
True if the list is empty (ie, size() is zero).
label size() const noexcept
The number of entries in the list.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
A class for handling file names.
Identifies a surface patch/zone by name and index, with geometric type.
A triFace with additional (region) index.
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.
label readDir()
Read directory and populate the 'available' files.
label selectAll()
Populates 'selected' with all available files.
label select(const word &name)
Populates 'selected' with a subset of the available 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
Triangulated surface description with patch information.
const geometricSurfacePatchList & patches() const noexcept
virtual void swapPoints(pointField &pts)
Swap points. Similar to movePoints, but returns the old points.
static bool canRead(const fileName &name, bool verbose=false)
Can we read this file format?
void swapFaces(List< labelledTri > &faceLst)
Swap the list of faces being addressed.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
bool isPattern() const noexcept
The wordRe is a pattern, not a literal string.
static labelList matching(const wordRe &select, const UList< StringType > &input, const bool invert=false)
Determine the list indices for all matches.
A class for handling words, derived from Foam::string.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< word > wordList
List of word.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
List< fileName > fileNameList
List of fileName.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
void sort(UList< T > &list)
Sort the list.
List< geometricSurfacePatch > geometricSurfacePatchList
List of geometricSurfacePatch.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::Type::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.