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 (map().hasMotionPoints())
696 cutter.topoChange(map());
709 Info<<
"Writing refined morphMesh to time " << runTime.timeName()
const labelListList & cellEdges() const
#define forAll(list, i)
Loop across all elements in list.
virtual Ostream & write(const char)=0
Write character.
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 nullptr.
A face is a list of labels corresponding to mesh vertices.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Cell-face mesh analysis engine.
Unit conversion functions.
void size(const label)
Override size to be inconsistent with allocated storage.
const cellShapeList & cellShapes() const
Return cell shapes.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
const cellList & cells() const
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
bool insert(const Key &key)
Insert a new entry.
Description of cuts across cells.
label size() const
Return number of elements in table.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
Various functions to operate on Lists.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
virtual const pointField & points() const
Return raw points.
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
const fileName & pointsInstance() const
Return the current instance directory for points.
dimensionedScalar cos(const dimensionedScalar &ds)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
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.
virtual const labelList & faceOwner() const
Return face owner.
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.
virtual const faceList & faces() const
Return raw faces.
errorManip< error > abort(error &err)
virtual void topoChange(const polyTopoChangeMap &map)
Update any stored data for new labels.
dimensionedScalar sin(const dimensionedScalar &ds)
vector vec(const pointField &) const
Return the vector (end - start)
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
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.
void setInstance(const fileName &)
Set the instance for mesh files.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const vectorField & faceCentres() const
void setSize(const label)
Reset size of List.
A cell is defined as a list of faces with extra functionality.
A collection of cell labels.
T argRead(const label index) const
Read a value from the argument at index.
const vectorField & faceAreas() const
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...
virtual const labelList & faceOwner() const =0
Face face-owner addressing.
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...
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 bool write(const bool write=true) const
Write using setting from DB.
virtual void setPoints(const pointField &)
Reset the points.
Foam::argList args(argc, argv)
label start() const
Return start vertex label.
Implementation of cellLooper. Does pure geometric cut through cell.