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];
432 bool splitOk =
false;
434 if (!geometry && cellShapes[celli].model() == hex)
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)" 549 runTime.functionObjects().off();
553 const scalar featureAngle =
args.
argRead<scalar>(1);
563 Info<<
"Trying to split cells with internal angles > feature angle\n" << nl
564 <<
"featureAngle : " << featureAngle << nl
565 <<
"edge snapping tol : " << edgeTol <<
nl;
568 Info<<
"candidate cells : cellSet " <<
args[
"set"] <<
nl;
572 Info<<
"candidate cells : all cells" <<
nl;
576 Info<<
"hex cuts : geometric; using edge tolerance" <<
nl;
580 Info<<
"hex cuts : topological; cut to opposite edge" <<
nl;
606 for (
label celli = 0; celli < mesh.
nCells(); celli++)
635 cutSet.insert(cutCells[i]);
639 Info<<
"Writing " << cutSet.size() <<
" cells to cut to cellSet " 640 << cutSet.instance()/cutSet.local()/cutSet.name()
653 Info<<
"Actually cut cells:" << cuts.nLoops() << nl <<
endl;
655 if (cuts.nLoops() == 0)
661 forAll(cuts.cellLoops(), celli)
663 if (cuts.cellLoops()[celli].size())
667 cellsToCut.
erase(celli);
678 cutter.setRefinement(cuts, meshMod);
690 if (morphMap().hasMotionPoints())
692 mesh.
movePoints(morphMap().preMotionPoints());
696 cutter.updateMesh(morphMap());
709 Info<<
"Writing refined morphMesh to time " << runTime.timeName()
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
#define forAll(list, i)
Loop across all elements in list.
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static void setSnapTol(const scalar tol)
static const cellModel * lookup(const word &)
Look up a model by name and return a pointer to the model or NULL.
A face is a list of labels corresponding to mesh vertices.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Cell-face mesh analysis engine.
const vectorField & faceAreas() const
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.
virtual void updateMesh(const mapPolyMesh &morphMap)
Update any stored data for new labels.
static void noParallel()
Remove the parallel options.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
label size() const
Return number of elements in table.
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
const vectorField & faceCentres() const
bool insert(const Key &key)
Insert a new entry.
Description of cuts across cells.
const cellList & cells() const
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
virtual const pointField & points() const
Return raw points.
Various functions to operate on Lists.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
const cellShapeList & cellShapes() const
Return cell shapes.
dimensionedScalar cos(const dimensionedScalar &ds)
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...
Description of cell after splitting. Contains cellLabel and pointers to cells it it split in...
A class for handling words, derived from string.
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Combines edge or vertex in single label. Used to specify cuts across cell circumference.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
dimensionedScalar sin(const dimensionedScalar &ds)
label start() const
Return start vertex label.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
const labelListList & cellEdges() const
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
T argRead(const label index) const
Read a value from the argument at index.
void setInstance(const fileName &)
Set the instance for mesh files.
void setSize(const label)
Reset size of List.
const fileName & pointsInstance() const
Return the current instance directory for points.
A cell is defined as a list of faces with extra functionality.
A collection of cell labels.
Direct mesh changes based on v1.3 polyTopoChange syntax.
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
vector vec(const pointField &) const
Return the vector (end - start)
virtual bool write() const
Write using setting from DB.
virtual const labelList & faceOwner() const =0
Face face-owner addresing.
dimensioned< scalar > mag(const dimensioned< Type > &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
virtual Ostream & write(const token &)=0
Write next token to stream.
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.
static void addNote(const string &)
Add extra notes for the usage information.
virtual const labelList & faceOwner() const
Return face owner.
virtual const faceList & faces() const
Return raw faces.
Foam::argList args(argc, argv)
Implementation of cellLooper. Does pure geometric cut through cell.