108 label maxConstraint = 0;
112 maxConstraint =
Foam::max(maxConstraint, constraints[i].first());
118 if (maxConstraint == 3)
123 / ppp.
name()+
"_fixedPoints.obj" 129 else if (maxConstraint == 2)
134 / ppp.
name()+
"_slidingPoints.obj" 138 os.
write(localPoints[i], constraints[i].second());
141 <<
" as coordinates and normals" 144 else if (maxConstraint == 1)
149 / ppp.
name()+
"_surfacePoints.obj" 165 const bool excludeProcPatches
172 for (
const label patchi : ids)
176 if (isType<emptyPolyPatch>(
pp))
180 else if (excludeProcPatches &&
bool(isA<processorPolyPatch>(
pp)))
194 label addMeshPointPatches
204 const scalar edgeFeatureAngle,
205 const scalar pointFeatureAngle,
206 const bool verbose =
true,
207 const bool writePoints =
false 210 const auto& pointBm = pMesh.
boundary();
212 const label nPointPatches = pointBm.
size();
254 if (faceZoneToCompactZone.
size())
266 forAll(faceZoneToCompactZone, zonei)
268 const label compacti = faceZoneToCompactZone[zonei];
271 const word patchName(surfZones[compacti].
name());
273 if (pointBm.findPatchID(patchName) == -1)
285 fzs[zonei].addressing()
289 const auto&
mp = fzPatch.meshPoints();
291 const vector nullVector(vector::uniform(0));
295 for (
const label pointi :
mp)
297 const label allPointi =
299 meshPointNormals[pointi] = pointNormals[allPointi];
311 forAll(meshPointNormals, pointi)
313 if (meshPointNormals[pointi] != nullVector)
315 meshPoints.append(pointi);
328 meshPointPatch::typeName
334 const auto& ppp = pointBm.last();
335 Info<<
"Added zone pointPatch " << ppp.
name()
338 <<
" points" <<
endl;
351 forAll(zoneToMeshPoints, zonei)
356 const word patchName(surfZones[zonei].
name() +
"Edges");
358 if (
nPoints && (pointBm.findPatchID(patchName) == -1))
365 zoneToMeshPoints[zonei],
366 zoneToConstraints[zonei],
369 meshPointPatch::typeName
375 const auto& ppp = pointBm.last();
376 Info<<
"Added feature-edges pointPatch " << ppp.
name()
389 const word allEdgePatchName(
"boundaryEdges");
390 const label nPatchEdgePoints =
392 if (nPatchEdgePoints && (pointBm.findPatchID(allEdgePatchName) == -1))
403 meshPointPatch::typeName
409 const auto& ppp = pointBm.last();
410 Info<<
"Added inter-patch pointPatch " << ppp.
name()
411 <<
" with " << nPatchEdgePoints <<
" points" <<
endl;
420 const word allPointPatchName(
"boundaryPoints");
421 const label nMultiPoints =
423 if (nMultiPoints && (pointBm.findPatchID(allPointPatchName) == -1))
431 multiZoneConstraints,
434 meshPointPatch::typeName
440 const auto& ppp = pointBm.last();
441 Info<<
"Added multi-patch pointPatch " << ppp.
name()
442 <<
" with " << nMultiPoints <<
" points" <<
endl;
456 if (!isA<processorPointPatch>(pointBm[patchi]))
458 oldToNew[patchi] = newPatchi++;
463 if (isA<processorPointPatch>(pointBm[patchi]))
465 oldToNew[patchi] = newPatchi++;
470 return pointBm.size() - nPointPatches;
476 int main(
int argc,
char *argv[])
480 "Extract patch or faceZone surfaces from a polyMesh." 492 "excludeProcPatches",
493 "Exclude processor patches" 499 "Specify single or multiple faceZones to extract\n" 500 "Eg, 'cells' or '( slice \"mfp-.*\" )'" 506 "Specify single patch or multiple patches to extract.\n" 507 "Eg, 'top' or '( front \".*back\" )'" 513 "Specify single patch or multiple patches to exclude from -patches." 514 " Eg, 'outlet' or '( inlet \".*Wall\" )'",
522 "Auto-extract feature edges/points and put into separate point-patches" 527 "Extract point-patches for selected faceZones" 532 "Write added pointPatch points to .obj files" 540 if (!userOutFileName.has_ext())
543 <<
"Missing extension on output name " << userOutFileName
547 Info<<
"Extracting surface from boundaryMesh ..." <<
nl <<
nl;
549 const bool includeProcPatches =
552 if (includeProcPatches)
554 Info<<
"Including all processor patches." <<
nl <<
endl;
558 Info<<
"Excluding all processor patches." <<
nl <<
endl;
561 wordRes includePatches, excludePatches;
575 if (selectedFaceZones.size())
581 scalar featureAngle = 180.0;
588 const bool extractZonePoints =
args.
found(
"extractZonePoints");
594 if (specifiedFeature)
596 Info<<
"Detecting all sharp (>" << featureAngle
597 <<
" degrees) patch edges." <<
nl <<
endl;
599 if (extractZonePoints)
601 Info<<
"Extracting all faceZone points as pointPatches." 607 Info<<
"Create pointMesh for time = " 622 if (timeDirs.
size() == 1)
624 outFileName = userOutFileName;
631 Info<<
" ... no mesh change." <<
nl;
638 const auto dot = userOutFileName.rfind(
'.');
641 userOutFileName.substr(0,
dot) +
"_" 643 + userOutFileName.
ext();
674 if (selectedFaceZones.size())
676 faceZoneIds = fzm.
indices(selectedFaceZones);
678 Info<<
"Additionally extracting faceZones " 679 << fzm.
names(selectedFaceZones) <<
nl;
703 patchSize.insert(
pp.name(),
pp.size());
708 for (
const label zonei : faceZoneIds)
711 zoneSize.insert(
pp.name(),
pp.size());
724 compactZoneID.insert(iter.key(), compactZoneID.size());
729 compactZoneID.insert(iter.key(), compactZoneID.size());
740 Info<<
"surfZone " << *iter
741 <<
" : " << surfZones[*iter].name()
749 label patchi =
bMesh.findPatchID(iter.key());
752 patchToCompactZone[patchi] = iter.val();
757 faceZoneToCompactZone[zoneI] = iter.val();
772 compactZones.
append(patchToCompactZone[
pp.index()]);
776 for (
const label zonei : faceZoneIds)
782 compactZones.
append(faceZoneToCompactZone[
pp.index()]);
838 gatheredPoints.clear();
840 faceList allFaces = ListListOps::combine<faceList>
845 gatheredFaces.clear();
847 labelList allZones = ListListOps::combine<labelList>
852 gatheredZones.clear();
877 Info<<
"Writing merged surface to " << globalCasePath <<
endl;
879 sortedFace.
write(globalCasePath);
883 if (specifiedFeature)
888 const label nAdded = addMeshPointPatches
898 ? faceZoneToCompactZone
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
const polyBoundaryMesh & pbm
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
const Type & value() const noexcept
Return const reference to value.
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
fileName path() const
Return path = rootPath/caseName. Same as TimePaths::path()
A class for handling file names.
static void setAdvanced(const word &optName, bool advanced=true)
Set an existing option as being 'advanced' or normal.
Identifies a surface patch/zone by name and index, with optional geometric type.
pointPatch with explicitly provided points instead of using the points of a polyPatch.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A pointBoundaryMesh is a pointPatch list with registered IO, a reference to the associated pointMesh...
A face is a list of labels corresponding to mesh vertices.
virtual Ostream & write(const char c) override
Write character.
label nPoints() const noexcept
Number of mesh points.
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.
virtual const fileName & name() const override
Read/write access to the name of the stream.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Unit conversion functions.
virtual const labelList & meshPoints() const
Return mesh points.
static FOAM_NO_DANGLING_REFERENCE const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
constexpr char nl
The newline '\n' character (0x0a)
Object access operator or list access operator (default is pass-through)
Database for mesh data, solution data, solver performance and other reduced data. ...
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< T > getList(const label index) const
Get a List of values from the argument at index.
static bool & parRun() noexcept
Test if this a parallel run.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Specify an alias for the option name.
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
void setCapacity(const label len)
Alter the size of the underlying storage.
autoPtr< globalIndex > mergePoints(labelList &pointToGlobal, labelList &uniquePoints) const
Helper for merging (collocated!) mesh point data.
Operations on lists of strings.
static bool isAbsolute(const std::string &str)
Return true if filename starts with a '/' or '\' or (windows-only) with a filesystem-root.
static void broadcast(Type &value, const int communicator=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
labelList faceLabels(nFaceLabels)
const pointMesh & mesh() const noexcept
Return the mesh reference.
bool processorCase() const noexcept
True if this is a processor case.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
static void gatherList(UList< T > &values, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather data, but keep individual values separate.
fileName path() const
The complete path for the object (with instance, local,...).
void reduce(T &value, [[maybe_unused]] BinaryOp bop, [[maybe_unused]] const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce)
virtual const pointField & points() const
Return raw points.
Mesh representing a set of points created from polyMesh.
#define forAll(list, i)
Loop across all elements in list.
word ext() const
Return file name extension (part after last .)
labelList indices(const wordRe &matcher, const bool useGroups=true) const
The (sorted) patch indices for all matches, optionally matching patch groups.
A list of faces which address into the list of points.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
const Map< label > & meshPointMap() const
Mesh point map.
vectorField pointField
pointField is a vectorField.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in time.
labelList indices(const wordRe &matcher, const bool useGroups=true) const
The (sorted) patch indices for all matches, optionally matching zone groups.
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
const Mesh & mesh() const noexcept
Reference to the mesh.
fileName globalPath() const
Return global path for the case = rootPath/globalCaseName. Same as TimePaths::globalPath() ...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
virtual const List< pointConstraint > & constraints() const
Return constraints.
label size() const noexcept
The number of entries in the list.
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
A List of wordRe with additional matching capabilities.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
const globalMeshData & globalData() const
Return parallel info (demand-driven)
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
void append(const T &val)
Copy append an element to the end of this list.
static void mapCombineGather(Container &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::mapGather with an in-place cop.
virtual const faceList & faces() const
Return raw faces.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh...
const word & name() const noexcept
The patch name.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
OBJstream os(runTime.globalPath()/outputName)
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
bool readListIfPresent(const word &optName, List< T > &list) const
If named option is present, get a List of values treating a single entry like a list of size 1...
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options and also set the runTime to the first i...
const pointBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values within a list.
T get(const label index) const
Get a value from the argument at index.
Basic pointPatch represents a set of points from the mesh.
A List with indirect addressing. Like IndirectList but does not store addressing. ...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
wordList names() const
A list of the zone names.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< vector > vectorField
Specialisation of Field<T> for vector.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Mesh consisting of general polyhedral cells.
A subset of mesh faces organised as a primitive patch.
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
readUpdateState
Enumeration defining the state of the mesh after a read update.
A patch is a list of labels that address the faces in the global face list.
const pointBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Foam::argList args(argc, argv)
ListType reorder(const labelUList &oldToNew, const ListType &input, const bool prune=false)
Reorder the elements of a list.
static const List< label > & null() noexcept
Return a null List (reference to a nullObject). Behaves like an empty List.
const dimensionedScalar mp
Proton mass.
bool found(const word &optName) const
Return true if the named option is found.
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
forAllConstIters(mixture.phases(), phase)
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.