82 void simpleMarkFeatures
86 const scalar featureAngle,
87 const bool concaveMultiCells,
88 const bool doNotPreserveFaceZones,
117 label meshEdgeI = meshEdges[edgeI];
118 featureEdgeSet.
insert(meshEdgeI);
119 singleCellFeaturePointSet.
insert(mesh.
edges()[meshEdgeI][0]);
120 singleCellFeaturePointSet.
insert(mesh.
edges()[meshEdgeI][1]);
149 const labelList& meshPoints = allBoundary.meshPoints();
153 const labelList& eFaces = edgeFaces[edgeI];
155 if (eFaces.
size() > 2)
157 const edge& e = allBoundary.edges()[edgeI];
164 singleCellFeaturePointSet.
insert(meshPoints[e[0]]);
165 singleCellFeaturePointSet.
insert(meshPoints[e[1]]);
172 const labelList& eFaces = edgeFaces[edgeI];
174 if (eFaces.
size() == 2)
176 label f0 = eFaces[0];
177 label f1 = eFaces[1];
180 const vector& n0 = allBoundary.faceNormals()[f0];
181 const vector& n1 = allBoundary.faceNormals()[
f1];
183 if ((n0 & n1) < minCos)
185 const edge& e = allBoundary.edges()[edgeI];
186 label v0 = meshPoints[e[0]];
187 label v1 = meshPoints[e[1]];
190 featureEdgeSet.
insert(meshEdgeI);
196 allBoundary[f1].centre(allBoundary.points())
197 - allBoundary[f0].centre(allBoundary.points())
200 if (concaveMultiCells && (c1c0 & n0) > SMALL)
203 Info<<
"Detected concave feature edge:" << edgeI
204 <<
" cos:" << (c1c0 & n0)
206 << allBoundary.points()[v0]
207 << allBoundary.points()[v1]
210 singleCellFeaturePointSet.
erase(v0);
211 multiCellFeaturePointSet.
insert(v0);
212 singleCellFeaturePointSet.
erase(v1);
213 multiCellFeaturePointSet.
insert(v1);
218 if (!multiCellFeaturePointSet.
found(v0))
220 singleCellFeaturePointSet.
insert(v0);
222 if (!multiCellFeaturePointSet.
found(v1))
224 singleCellFeaturePointSet.
insert(v1);
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)
356 int main(
int argc,
char *argv[])
365 "have multiple faces inbetween cells" 370 "split cells on concave boundary edges into multiple cells" 374 "doNotPreserveFaceZones",
375 "disable the default behaviour of preserving faceZones by having" 376 " multiple faces inbetween cells" 395 isBoundaryEdge.
set(fEdges[i], 1);
399 const scalar featureAngle =
args.
argRead<scalar>(1);
402 Info<<
"Feature:" << featureAngle << endl
403 <<
"minCos :" << minCos << endl
410 Info<<
"Splitting all internal faces to create multiple faces" 411 <<
" between two cells." <<
nl 418 "doNotPreserveFaceZones" 421 if (concaveMultiCells)
423 Info<<
"Generating multiple cells for points on concave feature edges." 444 doNotPreserveFaceZones,
448 singleCellFeaturePoints,
449 multiCellFeaturePoints
468 singleCellFeaturePoints,
469 multiCellFeaturePoints
518 dualMaker.setRefinement
523 singleCellFeaturePoints,
524 multiCellFeaturePoints,
535 if (map().hasMotionPoints())
549 Info<<
"Writing dual mesh to " << runTime.timeName() <<
endl;
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
wordList ReadFields(const Mesh &mesh, const IOobjectList &objects, PtrList< GeoField > &fields, const bool syncPar=true)
Read all fields of the specified type.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
List of IOobjects with searching and retrieving facilities.
A face is a list of labels corresponding to mesh vertices.
Unit conversion functions.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void noParallel()
Remove the parallel options.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Field reading functions for post-processing utilities.
const vectorField & faceCentres() const
bool insert(const Key &key)
Insert a new entry.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
virtual const pointField & points() const
Return raw points.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
const word & name() const
Return name.
A list of faces which address into the list of points.
A List obtained as a section of another List.
bool checkPointManifold(const bool report=false, labelHashSet *setPtr=NULL) const
Checks primitivePatch for faces sharing point but not edge.
dimensionedScalar cos(const dimensionedScalar &ds)
void set(const PackedList< 1 > &)
Set specified bits.
bool optionFound(const word &opt) const
Return true if the named option is found.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
virtual void updateMesh(const mapPolyMesh &mpm)
Update the mesh corresponding to given map.
A class for handling words, derived from string.
List< Key > toc() const
Return the table of contents.
bool found(const Key &) const
Return true if hashedEntry is found in table.
const labelList & meshEdges() const
Return global edge index for local edges.
Creates dual of polyMesh. Every point becomes a cell (or multiple cells for feature points)...
T argRead(const label index) const
Read a value from the argument at index.
void setInstance(const fileName &)
Set the instance for mesh files.
label nEdges() const
Return number of edges in patch.
#define WarningInFunction
Report a warning using Foam::Warning.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
const fileName & pointsInstance() const
Return the current instance directory for points.
label nInternalEdges() const
Number of internal edges.
Direct mesh changes based on v1.3 polyTopoChange syntax.
virtual bool write() const
Write using setting from DB.
const faceZoneMesh & faceZones() const
Return face zone mesh.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Mesh consisting of general polyhedral cells.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
A subset of mesh faces organised as a primitive patch.
A patch is a list of labels that address the faces in the global face list.
virtual const faceList & faces() const
Return raw faces.
Foam::argList args(argc, argv)
const labelListList & faceEdges() const
label nInternalFaces() const
label size() const
Return the number of elements in the UPtrList.