108 label maxConstraint = 0;
112 maxConstraint =
Foam::max(maxConstraint, constraints[i].first());
118 if (maxConstraint == 3)
123 / ppp.
name()+
"_fixedPoints.obj"
125 os.write(localPoints);
126 Info<<
"Written pointPatch " << ppp.
name() <<
" to " <<
os.name()
129 else if (maxConstraint == 2)
134 / ppp.
name()+
"_slidingPoints.obj"
138 os.write(localPoints[i], constraints[i].second());
140 Info<<
"Written pointPatch " << ppp.
name() <<
" to " <<
os.name()
141 <<
" as coordinates and normals"
144 else if (maxConstraint == 1)
149 / ppp.
name()+
"_surfacePoints.obj"
151 os.write(localPoints);
152 Info<<
"Written pointPatch " << ppp.
name() <<
" to " <<
os.name()
165 const bool excludeProcPatches
172 for (
const label patchi : ids)
194label 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();
211 const auto& fzs =
mesh.faceZones();
212 const label nPointPatches = pointBm.size();
218 List<pointConstraintList> zoneToConstraints;
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();
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;
458 oldToNew[patchi] = newPatchi++;
465 oldToNew[patchi] = newPatchi++;
470 return pointBm.size() - nPointPatches;
476int 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;
562 if (
args.readListIfPresent<
wordRe>(
"patches", includePatches))
567 if (
args.readListIfPresent<
wordRe>(
"exclude-patches", excludePatches))
575 if (selectedFaceZones.size())
581 scalar featureAngle = 180.0;
582 const bool specifiedFeature =
args.readIfPresent
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();
845 gatheredFaces.clear();
852 gatheredZones.clear();
857 std::move(allPoints),
872 ?
runTime.globalPath()/outFileName
877 Info<<
"Writing merged surface to " << globalCasePath <<
endl;
879 sortedFace.write(globalCasePath);
883 if (specifiedFeature)
888 const label nAdded = addMeshPointPatches
898 ? faceZoneToCompactZone
labelList faceLabels(nFaceLabels)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
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.
void setCapacity(const label len)
Alter the size of the underlying storage.
A HashTable similar to std::unordered_map.
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
static const List< label > & null() noexcept
static FOAM_NO_DANGLING_REFERENCE const pointMesh & New(const polyMesh &mesh, Args &&... args)
const Mesh & mesh() const noexcept
Reference to the mesh.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files.
const Map< label > & meshPointMap() const
Mesh point map.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
const List< face_type > & localFaces() const
Return patch faces addressing into local point 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.
static void gatherList(UList< T > &values, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather data, but keep individual values separate.
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...
A List with indirect addressing. Like IndirectList but does not store addressing.
void size(const label n)
Older name for setAddressableSize.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
static Form uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
wordList names() const
A list of the zone names.
labelList indices(const wordRe &matcher, const bool useGroups=true) const
The (sorted) patch indices for all matches, optionally matching zone groups.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
static void setAdvanced(const word &optName, bool advanced=true)
Set an existing option as being 'advanced' or normal.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
static void addNote(const string ¬e)
Add extra notes for the usage information.
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Specify an alias for the option name.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A subset of mesh faces organised as a primitive patch.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
static bool isAbsolute(const std::string &str)
Return true if filename starts with a '/' or '\' or (windows-only) with a filesystem-root.
pointPatch with explicitly provided points instead of using the points of a polyPatch.
virtual const List< pointConstraint > & constraints() const
Return constraints.
virtual const labelList & meshPoints() const
Return mesh points.
Database for mesh data, solution data, solver performance and other reduced data.
const word & name() const noexcept
The patch name.
A pointBoundaryMesh is a pointPatch list with registered IO, a reference to the associated pointMesh,...
const pointMesh & mesh() const noexcept
Return the mesh reference.
Mesh representing a set of points created from polyMesh.
const pointBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Basic pointPatch represents a set of points from the mesh.
const pointBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
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.
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
Identifies a surface patch/zone by name and index, with optional geometric type.
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
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...
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
word ext() const
Return file name extension (part after last .).
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
return returnReduce(nRefine-oldNRefine, sumOp< label >())
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
AccessType combine(const UList< T > &lists, AccessOp aop=accessOp< T >())
Combines sub-lists into a single list.
const dimensionedScalar mp
Proton mass.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values within a list.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
List< surfZoneIdentifier > surfZoneIdentifierList
List of surfZoneIdentifier.
messageStream Info
Information stream (stdout output on master, null elsewhere).
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with faceZone content on a polyMesh.
List< pointConstraint > pointConstraintList
List of pointConstraint.
List< face > faceList
List of faces.
List< instant > instantList
List of instants.
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Field< vector > vectorField
Specialisation of Field<T> for vector.
bool isType(const U &obj)
Check if typeid of the object and Type are identical.
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.
PrimitivePatch< List< face >, const pointField > bMesh
Holder of faceList and points. (v.s. e.g. primitivePatch which references points).
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
ListType reorder(const labelUList &oldToNew, const ListType &input, const bool prune=false)
Reorder the elements of a list.
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Operations on lists of strings.
Object access operator or list access operator (default is pass-through).
Unit conversion functions.