73 packedLst[packedI++] = i;
76 packedLst.setSize(packedI);
91 packedElems[packedI++] = elems[i];
105 const scalar cosAngle,
106 const scalar sinAngle,
118 bool sameFaceOrder = !((own[f0] == celli) ^ (own[f1] == celli));
122 scalar normalCosAngle = n0 & n1;
126 normalCosAngle = -normalCosAngle;
134 c1c0 /=
mag(c1c0) + vSmall;
136 scalar fcCosAngle = n0 & c1c0;
138 if (own[f0] != celli)
140 fcCosAngle = -fcCosAngle;
153 if (normalCosAngle < cosAngle)
174 if (normalCosAngle > cosAngle)
205 const edge&
e = edges[edgeI];
215 const cell& cFaces = mesh.
cells()[celli];
219 label facei = cFaces[i];
221 const face&
f = faces[facei];
260 if (leftI == -1 || rightI == -1)
268 const face& leftF = faces[leftI];
270 label leftV = leftF[(leftFp + 2) % leftF.
size()];
272 const face& rightF = faces[rightI];
274 label rightV = rightF[(rightFp + 2) % rightF.
size()];
277 loop[0] = ev.vertToEVert(
e[0]);
278 loop[1] = ev.vertToEVert(leftV);
279 loop[2] = ev.vertToEVert(rightV);
280 loop[3] = ev.vertToEVert(
e[1]);
283 loopWeights[0] = -great;
284 loopWeights[1] = -great;
285 loopWeights[2] = -great;
286 loopWeights[3] = -great;
290 cellEdgeWeights.
append(loopWeights);
320 vector planeN = eVec ^ halfNorm;
325 planeN += 0.01*halfNorm;
327 planeN /=
mag(planeN);
352 cellEdgeWeights.
append(loopWeights);
398 const label celli = iter.key();
399 const labelList& cEdges = cellEdges[celli];
403 label edgeI = cEdges[i];
408 vector n0 = faceAreas[f0];
411 vector n1 = faceAreas[f1];
430 bool splitOk =
false;
450 if ((own[f0] == celli) ^ (own[f1] == celli))
453 halfNorm = 0.5*(n0 - n1);
459 halfNorm = 0.5*(n0 + n1);
486 const labelList& loop = cellLoops[index];
487 const scalarField& loopWeights = cellEdgeWeights[index];
495 edgeIsCut[ev.getEdge(cut)] =
true;
496 edgeWeight[ev.getEdge(cut)] = loopWeights[i];
500 vertIsCut[ev.getVertex(cut)] =
true;
518 int main(
int argc,
char *argv[])
522 "split cells with flat faces"
532 "split cells from specified cellSet only"
537 "use geometric cut for hexes as well"
542 "scalar",
"edge snap tolerance (default 0.2)"
551 const scalar minCos =
Foam::cos(featureAngle);
552 const scalar minSin =
Foam::sin(featureAngle);
560 Info<<
"Trying to split cells with internal angles > feature angle\n" <<
nl
561 <<
"featureAngle : " <<
radToDeg(featureAngle) <<
nl
562 <<
"edge snapping tol : " << edgeTol <<
nl;
565 Info<<
"candidate cells : cellSet " <<
args[
"set"] <<
nl;
569 Info<<
"candidate cells : all cells" <<
nl;
573 Info<<
"hex cuts : geometric; using edge tolerance" <<
nl;
577 Info<<
"hex cuts : topological; cut to opposite edge" <<
nl;
603 for (
label celli = 0; celli < mesh.
nCells(); celli++)
632 cutSet.insert(cutCells[i]);
636 Info<<
"Writing " << cutSet.size() <<
" cells to cut to cellSet "
637 << cutSet.instance()/cutSet.local()/cutSet.name()
650 Info<<
"Actually cut cells:" << cuts.nLoops() <<
nl <<
endl;
652 if (cuts.nLoops() == 0)
658 forAll(cuts.cellLoops(), celli)
660 if (cuts.cellLoops()[celli].size())
664 cellsToCut.
erase(celli);
675 cutter.setRefinement(cuts, meshMod);
688 cutter.topoChange(map());
701 Info<<
"Writing refined morphMesh to time " << runTime.name()
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
bool insert(const Key &key)
Insert a new entry.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
label size() const
Return number of elements in table.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
virtual Ostream & write(const char)=0
Write character.
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
static void addNote(const string &)
Add extra notes for the usage information.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
bool optionFound(const word &opt) const
Return true if the named option is found.
static void noParallel()
Remove the parallel options.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
T argRead(const label index) const
Read a value from the argument at index.
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Description of cuts across cells.
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
static const cellModel * lookup(const word &)
Look up a model by name and return a pointer to the model or nullptr.
A collection of cell labels.
virtual void topoChange(const polyTopoChangeMap &map)
Update any stored data for new labels.
A cell is defined as a list of faces with extra functionality.
Combines edge or vertex in single label. Used to specify cuts across cell circumference.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A face is a list of labels corresponding to mesh vertices.
Implementation of cellLooper. Does pure geometric cut through cell.
static void setSnapTol(const scalar tol)
virtual bool cut(const vector &refDir, const label celli, const boolList &vertIsCut, const boolList &edgeIsCut, const scalarField &edgeWeight, labelList &loop, scalarField &loopWeights) const
Create cut along circumference of celli. Gets current mesh cuts.
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
const fileName & pointsInstance() const
Return the current instance directory for points.
virtual const pointField & points() const
Return raw points.
void setInstance(const fileName &)
Set the instance for mesh files.
Direct mesh changes based on v1.3 polyTopoChange syntax.
Cell-face mesh analysis engine.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const labelListList & cellEdges() const
const vectorField & faceCentres() const
const cellShapeList & cellShapes() const
Return cell shapes.
virtual const labelList & faceOwner() const =0
Face face-owner addressing.
const vectorField & faceAreas() const
const cellList & cells() const
virtual bool write(const bool write=true) const
Write using setting from DB.
Description of cell after splitting. Contains cellLabel and pointers to cells it split in....
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
const cellShapeList & cellShapes
scalar radToDeg(const scalar rad)
Convert radians to degrees.
scalar degToRad(const scalar deg)
Convert degrees to radians.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
dimensionedScalar sin(const dimensionedScalar &ds)
IOstream & hex(IOstream &io)
dimensioned< scalar > mag(const dimensioned< Type > &)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
dimensionedScalar cos(const dimensionedScalar &ds)
Foam::argList args(argc, argv)