89void simpleMarkFeatures
92 const bitSet& isBoundaryEdge,
93 const scalar featureAngle,
94 const bool concaveMultiCells,
95 const bool doNotPreserveFaceZones,
122 for (label edgeI =
pp.nInternalEdges(); edgeI <
pp.nEdges(); edgeI++)
124 label meshEdgeI = meshEdges[edgeI];
125 featureEdgeSet.
insert(meshEdgeI);
126 singleCellFeaturePointSet.
insert(
mesh.edges()[meshEdgeI][0]);
127 singleCellFeaturePointSet.
insert(
mesh.edges()[meshEdgeI][1]);
143 allBoundary.checkPointManifold(
false, &singleCellFeaturePointSet);
147 const labelList& meshPoints = allBoundary.meshPoints();
151 const labelList& eFaces = edgeFaces[edgeI];
153 if (eFaces.
size() > 2)
155 const edge&
e = allBoundary.edges()[edgeI];
162 singleCellFeaturePointSet.
insert(meshPoints[
e[0]]);
163 singleCellFeaturePointSet.
insert(meshPoints[
e[1]]);
170 const labelList& eFaces = edgeFaces[edgeI];
172 if (eFaces.
size() == 2)
174 label f0 = eFaces[0];
175 label f1 = eFaces[1];
178 const vector& n0 = allBoundary.faceNormals()[f0];
179 const vector& n1 = allBoundary.faceNormals()[f1];
181 if ((n0 & n1) < minCos)
183 const edge&
e = allBoundary.edges()[edgeI];
184 label v0 = meshPoints[
e[0]];
185 label v1 = meshPoints[
e[1]];
188 featureEdgeSet.
insert(meshEdgeI);
194 allBoundary[f1].centre(allBoundary.points())
195 - allBoundary[f0].centre(allBoundary.points())
198 if (concaveMultiCells && (c1c0 & n0) > SMALL)
201 Info<<
"Detected concave feature edge:" << edgeI
202 <<
" cos:" << (c1c0 & n0)
204 << allBoundary.points()[v0]
205 << allBoundary.points()[v1]
208 singleCellFeaturePointSet.
erase(v0);
209 multiCellFeaturePointSet.
insert(v0);
210 singleCellFeaturePointSet.
erase(v1);
211 multiCellFeaturePointSet.
insert(v1);
216 if (!multiCellFeaturePointSet.
found(v0))
218 singleCellFeaturePointSet.
insert(v0);
220 if (!multiCellFeaturePointSet.
found(v1))
222 singleCellFeaturePointSet.
insert(v1);
238 for (label facei =
mesh.nInternalFaces(); facei <
mesh.nFaces(); facei++)
240 featureFaceSet.
insert(facei);
246 if (doNotPreserveFaceZones)
248 if (faceZones.
size() > 0)
251 <<
"Detected " << faceZones.
size()
252 <<
" faceZones. These will not be preserved."
258 if (faceZones.
size() > 0)
260 Info<<
"Detected " << faceZones.
size()
261 <<
" faceZones. Preserving these by marking their"
262 <<
" points, edges and faces as features." <<
endl;
267 const faceZone& fz = faceZones[zoneI];
269 Info<<
"Inserting all faces in faceZone " << fz.
name()
270 <<
" as features." <<
endl;
278 featureFaceSet.
insert(facei);
283 singleCellFeaturePointSet.
erase(
f[fp]);
284 multiCellFeaturePointSet.
insert(
f[fp]);
287 featureEdgeSet.
insert(fEdges[fp]);
294 featureFaces = featureFaceSet.
toc();
295 featureEdges = featureEdgeSet.
toc();
296 singleCellFeaturePoints = singleCellFeaturePointSet.
toc();
297 multiCellFeaturePoints = multiCellFeaturePointSet.
toc();
307 const labelList& singleCellFeaturePoints,
313 Info<<
"Dumping centres of featureFaces to obj file " << str.name()
322 Info<<
"Dumping featureEdges to obj file " << str.name() <<
endl;
327 const edge&
e =
mesh.edges()[featureEdges[i]];
332 str<<
"l " << vertI-1 <<
' ' << vertI <<
nl;
336 OFstream str(
"singleCellFeaturePoints.obj");
337 Info<<
"Dumping featurePoints that become a single cell to obj file "
338 << str.name() <<
endl;
339 forAll(singleCellFeaturePoints, i)
345 OFstream str(
"multiCellFeaturePoints.obj");
346 Info<<
"Dumping featurePoints that become multiple cells to obj file "
347 << str.name() <<
endl;
348 forAll(multiCellFeaturePoints, i)
356int main(
int argc,
char *argv[])
360 "Creates the dual of a polyMesh,"
361 " adhering to all the feature and patch edges."
376 "Have multiple faces in between cells"
381 "Split cells on concave boundary edges into multiple cells"
385 "doNotPreserveFaceZones",
386 "Disable the default behaviour of preserving faceZones by having"
387 " multiple faces in between cells"
394 const word oldInstance =
mesh.pointsInstance();
399 bitSet isBoundaryEdge(
mesh.nEdges());
400 for (label facei =
mesh.nInternalFaces(); facei <
mesh.nFaces(); facei++)
406 isBoundaryEdge.
set(fEdges[i]);
410 const scalar featureAngle =
args.get<scalar>(1);
413 Info<<
"Feature:" << featureAngle <<
endl
414 <<
"minCos :" << minCos <<
endl
418 const bool splitAllFaces =
args.found(
"splitAllFaces");
421 Info<<
"Splitting all internal faces to create multiple faces"
422 <<
" between two cells." <<
nl
426 const bool overwrite =
args.found(
"overwrite");
427 const bool doNotPreserveFaceZones =
args.found(
"doNotPreserveFaceZones");
428 const bool concaveMultiCells =
args.found(
"concaveMultiCells");
429 if (concaveMultiCells)
431 Info<<
"Generating multiple cells for points on concave feature edges."
452 doNotPreserveFaceZones,
456 singleCellFeaturePoints,
457 multiCellFeaturePoints
476 singleCellFeaturePoints,
477 multiCellFeaturePoints
526 dualMaker.setRefinement
531 singleCellFeaturePoints,
532 multiCellFeaturePoints,
540 mesh.updateMesh(map());
543 if (map().hasMotionPoints())
545 mesh.movePoints(map().preMotionPoints());
554 mesh.setInstance(oldInstance);
Field reading functions for post-processing utilities.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
List< Key > toc() const
The table of contents (the keys) in unsorted order.
bool found(const Key &key) const
Same as contains().
void reserve(label numEntries)
Reserve space for at least the specified number of elements (not the number of buckets) and regenerat...
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
The number of entries in the list.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
static void noParallel()
Remove the parallel options.
static void addNote(const string ¬e)
Add extra notes for the usage information.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void set(const bitSet &bitset)
Set specified bits from another bitset.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
A subset of mesh faces organised as a primitive patch.
A face is a list of labels corresponding to mesh vertices.
Creates dual of polyMesh. Every point becomes a cell (or multiple cells for feature points),...
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
A patch is a list of labels that address the faces in the global face list.
Direct mesh changes based on v1.3 polyTopoChange syntax.
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
static void removeFiles(const polyMesh &)
Helper: remove all sets files from mesh instance.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
const word & name() const noexcept
The zone name.
const polyBoundaryMesh & patches
#define WarningInFunction
Report a warning using Foam::Warning.
wordList ReadFields(const typename GeoMesh::Mesh &mesh, const IOobjectList &objects, PtrList< GeometricField< Type, PatchField, GeoMesh > > &fields, const bool syncPar=true, const bool readOldTime=false)
Read Geometric fields of templated type.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
messageStream Info
Information stream (stdout output on master, null elsewhere).
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with faceZone content on a polyMesh.
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
dimensionedScalar cos(const dimensionedScalar &ds)
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
Unit conversion functions.