41 { loadingOption::SINGLE_REGION,
"single" },
42 { loadingOption::FILE_REGION,
"file" },
43 { loadingOption::OFFSET_REGION,
"offset" },
44 { loadingOption::MERGE_REGION,
"merge" },
50 Foam::triSurfaceLoader::triSurfaceLoader(
const fileName& directory)
52 directory_(directory),
60 Foam::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_.first() =
name;
116 return selected_.size();
126 selected_ =
wordList(available_, foundIds);
128 else if (available_.found(static_cast<const word&>(mat)))
131 selected_.first() = 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
216 if (selected_.empty())
220 else if (selected_.size() == 1)
223 output.reset(
new triSurface(directory_/selected_[0], scaleFactor));
225 triSurface& surf =
output();
229 opt == loadingOption::SINGLE_REGION
230 || opt == loadingOption::FILE_REGION
233 for (labelledTri&
f : surf)
238 if (surf.patches().size())
244 surf.patches().append
246 geometricSurfacePatch(selected_[0].lessExt(), 0)
255 List<labelledTri> faces;
259 HashTable<label> patchNameLookup;
260 DynamicList<geometricSurfacePatch>
patches(16*selected_.size());
264 List<labelledTri> addfaces;
267 triSurface addsurf(directory_/selected_[surfi]);
269 addsurf.swapFaces(addfaces);
270 addsurf.swapPoints(addpoints);
277 for (labelledTri&
f : addfaces)
288 case loadingOption::SINGLE_REGION:
290 for (labelledTri&
f : addfaces)
303 case loadingOption::FILE_REGION:
305 for (labelledTri&
f : addfaces)
313 geometricSurfacePatch(selected_[surfi].lessExt(), surfi)
319 case loadingOption::OFFSET_REGION:
331 for (labelledTri&
f : addfaces)
333 f.region() += regoff;
339 case loadingOption::MERGE_REGION:
346 forAll(addpatches, patchi)
348 geometricSurfacePatch&
p = addpatches[patchi];
349 const word& patchName =
p.
name();
352 if (patchNameLookup.insert(patchName,
patchId))
359 patchId = patchNameLookup[patchName];
362 oldToNew.insert(patchi,
patchId);
368 for (labelledTri&
f : addfaces)
370 f.region() = oldToNew[
f.region()];
384 faces.transfer(addfaces);
390 if (scaleFactor > VSMALL)
void size(const label n)
Older name for setAddressableSize.
label select(const word &name)
Populates 'selected' with a subset of the available files.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void resize(const label len)
Adjust allocated size of list.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void append(const T &val)
Append an element at the end of the list.
const word & name() const noexcept
Return the object name.
constexpr char nl
The newline '\n' character (0x0a)
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.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
label readDir()
Read directory and populate the 'available' files.
#define forAll(list, i)
Loop across all elements in list.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
vectorField pointField
pointField is a vectorField.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
void clear()
Clear the list, i.e. set size to zero.
A class for handling words, derived from Foam::string.
void sort(UList< T > &list)
Sort the list.
label size() const noexcept
The number of entries in the list.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
List< geometricSurfacePatch > geometricSurfacePatchList
List of geometricSurfacePatch.
bool empty() const noexcept
True if the list is empty (ie, size() is zero)
List< word > wordList
List of word.
void append(autoPtr< T > &ptr)
Move append an element to the end of the list.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
const polyBoundaryMesh & patches
loadingOption
The file loading options for triSurfaceLoader.
static Ostream & output(Ostream &os, const IntRange< T > &range)
static bool canRead(const fileName &name, bool verbose=false)
Can we read this file format?
List< label > labelList
A List of labels.
static const Enum< loadingOption > loadingOptionNames
The loading enumeration names.
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.
labelList findStrings(const regExp &matcher, const UList< StringType > &input, const bool invert=false)
Return list indices for strings matching the regular expression.
label selectAll()
Populates 'selected' with all available files.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.