75 packedLst[packedI++] = i;
78 packedLst.setSize(packedI);
93 packedElems[packedI++] = elems[i];
107 const scalar cosAngle,
108 const scalar sinAngle,
120 bool sameFaceOrder = !((own[f0] == celli) ^ (own[f1] == celli));
124 scalar normalCosAngle = n0 & n1;
128 normalCosAngle = -normalCosAngle;
136 c1c0 /=
mag(c1c0) + vSmall;
138 scalar fcCosAngle = n0 & c1c0;
140 if (own[f0] != celli)
142 fcCosAngle = -fcCosAngle;
155 if (normalCosAngle < cosAngle)
176 if (normalCosAngle > cosAngle)
207 const edge&
e = edges[edgeI];
217 const cell& cFaces = mesh.
cells()[celli];
221 label facei = cFaces[i];
223 const face&
f = faces[facei];
262 if (leftI == -1 || rightI == -1)
270 const face& leftF = faces[leftI];
272 label leftV = leftF[(leftFp + 2) % leftF.
size()];
274 const face& rightF = faces[rightI];
276 label rightV = rightF[(rightFp + 2) % rightF.
size()];
279 loop[0] = ev.vertToEVert(
e[0]);
280 loop[1] = ev.vertToEVert(leftV);
281 loop[2] = ev.vertToEVert(rightV);
282 loop[3] = ev.vertToEVert(
e[1]);
285 loopWeights[0] = -great;
286 loopWeights[1] = -great;
287 loopWeights[2] = -great;
288 loopWeights[3] = -great;
292 cellEdgeWeights.
append(loopWeights);
322 vector planeN = eVec ^ halfNorm;
327 planeN += 0.01*halfNorm;
329 planeN /=
mag(planeN);
354 cellEdgeWeights.
append(loopWeights);
400 const label celli = iter.key();
401 const labelList& cEdges = cellEdges[celli];
405 label edgeI = cEdges[i];
410 vector n0 = faceAreas[f0];
413 vector n1 = faceAreas[f1];
432 bool splitOk =
false;
452 if ((own[f0] == celli) ^ (own[f1] == celli))
455 halfNorm = 0.5*(n0 - n1);
461 halfNorm = 0.5*(n0 + n1);
488 const labelList& loop = cellLoops[index];
489 const scalarField& loopWeights = cellEdgeWeights[index];
497 edgeIsCut[ev.getEdge(cut)] =
true;
498 edgeWeight[ev.getEdge(cut)] = loopWeights[i];
502 vertIsCut[ev.getVertex(cut)] =
true;
520 int main(
int argc,
char *argv[])
524 "split cells with flat faces"
534 "split cells from specified cellSet only"
539 "use geometric cut for hexes as well"
544 "scalar",
"edge snap tolerance (default 0.2)"
552 const scalar featureAngle =
args.
argRead<scalar>(1);
562 Info<<
"Trying to split cells with internal angles > feature angle\n" <<
nl
563 <<
"featureAngle : " << featureAngle <<
nl
564 <<
"edge snapping tol : " << edgeTol <<
nl;
567 Info<<
"candidate cells : cellSet " <<
args[
"set"] <<
nl;
571 Info<<
"candidate cells : all cells" <<
nl;
575 Info<<
"hex cuts : geometric; using edge tolerance" <<
nl;
579 Info<<
"hex cuts : topological; cut to opposite edge" <<
nl;
605 for (
label celli = 0; celli < mesh.
nCells(); celli++)
634 cutSet.insert(cutCells[i]);
638 Info<<
"Writing " << cutSet.size() <<
" cells to cut to cellSet "
639 << cutSet.instance()/cutSet.local()/cutSet.name()
652 Info<<
"Actually cut cells:" << cuts.nLoops() <<
nl <<
endl;
654 if (cuts.nLoops() == 0)
660 forAll(cuts.cellLoops(), celli)
662 if (cuts.cellLoops()[celli].size())
666 cellsToCut.
erase(celli);
677 cutter.setRefinement(cuts, meshMod);
689 if (map().hasMotionPoints())
695 cutter.topoChange(map());
708 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.
virtual void setPoints(const pointField &)
Reset the points.
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 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
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)
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
Foam::argList args(argc, argv)
Unit conversion functions.