Go to the documentation of this file.
81 packedLst[packedI++] = i;
84 packedLst.setSize(packedI);
99 packedElems[packedI++] = elems[i];
102 packedElems.setSize(packedI);
113 const scalar cosAngle,
114 const scalar sinAngle,
126 bool sameFaceOrder = !((own[f0] == celli) ^ (own[f1] == celli));
130 scalar normalCosAngle = n0 & n1;
134 normalCosAngle = -normalCosAngle;
147 scalar fcCosAngle = n0 & c1c0;
149 if (own[f0] != celli)
151 fcCosAngle = -fcCosAngle;
164 if (normalCosAngle < cosAngle)
185 if (normalCosAngle > cosAngle)
216 const edge&
e = edges[edgeI];
228 for (
const label facei : cFaces)
230 const face&
f = faces[facei];
232 label fp0 =
f.find(
e[0]);
233 label fp1 =
f.find(
e[1]);
269 if (leftI == -1 || rightI == -1)
277 const face& leftF = faces[leftI];
279 label leftV = leftF[(leftFp + 2) % leftF.size()];
281 const face& rightF = faces[rightI];
283 label rightV = rightF[(rightFp + 2) % rightF.size()];
286 loop[0] = ev.vertToEVert(
e[0]);
287 loop[1] = ev.vertToEVert(leftV);
288 loop[2] = ev.vertToEVert(rightV);
289 loop[3] = ev.vertToEVert(
e[1]);
292 loopWeights[0] = -GREAT;
293 loopWeights[1] = -GREAT;
294 loopWeights[2] = -GREAT;
295 loopWeights[3] = -GREAT;
299 cellEdgeWeights.
append(loopWeights);
328 vector planeN = eVec ^ halfNorm;
333 planeN += 0.01*halfNorm;
359 cellEdgeWeights.
append(loopWeights);
401 for (
const label celli : cellsToCut)
403 const labelList& cEdges = cellEdges[celli];
405 for (
const label edgeI : cEdges)
429 bool splitOk =
false;
449 if ((own[f0] == celli) ^ (own[f1] == celli))
452 halfNorm = 0.5*(n0 - n1);
458 halfNorm = 0.5*(n0 + n1);
484 label index = cellLoops.size() - 1;
485 const labelList& loop = cellLoops[index];
486 const scalarField& loopWeights = cellEdgeWeights[index];
494 edgeIsCut[ev.getEdge(
cut)] =
true;
495 edgeWeight[ev.getEdge(
cut)] = loopWeights[i];
499 vertIsCut[ev.getVertex(
cut)] =
true;
517 int main(
int argc,
char *argv[])
521 "Split cells with flat faces"
535 "Split cells from specified cellSet only"
540 "Use geometric cut for hexes as well"
546 "Edge snap tolerance (default 0.2)"
557 const scalar featureAngle =
args.
get<scalar>(1);
562 const bool geometry =
args.
found(
"geometry");
563 const bool overwrite =
args.
found(
"overwrite");
567 Info<<
"Trying to split cells with internal angles > feature angle\n" <<
nl
568 <<
"featureAngle : " << featureAngle <<
nl
569 <<
"edge snapping tol : " << edgeTol <<
nl;
572 Info<<
"candidate cells : cellSet " <<
args[
"set"] <<
nl;
576 Info<<
"candidate cells : all cells" <<
nl;
580 Info<<
"hex cuts : geometric; using edge tolerance" <<
nl;
584 Info<<
"hex cuts : topological; cut to opposite edge" <<
nl;
610 for (label celli = 0; celli <
mesh.
nCells(); celli++)
612 cellsToCut.insert(celli);
640 Info<<
"Writing " << cutSet.size() <<
" cells to cut to cellSet "
641 << cutSet.instance()/cutSet.local()/cutSet.name()
654 Info<<
"Actually cut cells:" << cuts.nLoops() <<
nl <<
endl;
656 if (cuts.nLoops() == 0)
662 forAll(cuts.cellLoops(), celli)
664 if (cuts.cellLoops()[celli].size())
668 cellsToCut.erase(celli);
679 cutter.setRefinement(cuts, meshMod);
691 if (morphMap().hasMotionPoints())
697 cutter.updateMesh(morphMap());
700 cellsToCut.updateMesh(morphMap());
702 Info<<
"Remaining:" << cellsToCut.size() <<
endl;
virtual const pointField & points() const
Return raw points.
A class for handling words, derived from Foam::string.
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
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.
dimensionedScalar sin(const dimensionedScalar &ds)
static word timeName(const scalar t, const int precision=precision_)
const cellList & cells() const
Direct mesh changes based on v1.3 polyTopoChange syntax.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
static void addNote(const string ¬e)
Add extra notes for the usage information.
label nEdges() const
Number of mesh edges.
Combines edge or vertex in single label. Used to specify cuts across cell circumference.
Unit conversion functions.
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
Vector< Cmpt > & normalise()
Normalise the vector by its magnitude.
DynamicList< T, SizeMin > & shrink()
Shrink the allocated space to the number of elements used.
T get(const label index) const
Get a value from the argument at index.
Mesh consisting of general polyhedral cells.
#define forAll(list, i)
Loop across all elements in list.
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
const fileName & pointsInstance() const
Return the current instance directory for points.
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
label nCells() const
Number of mesh cells.
const labelListList & cellEdges() const
messageStream Info
Information stream (uses stdout - output is on the master only)
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
virtual const labelList & faceOwner() const
Return face owner.
Implementation of cellLooper. Does pure geometric cut through cell.
static const cellModel & ref(const modelType model)
Look up reference to cellModel by enumeration. Fatal on failure.
Patchify triangles based on orientation w.r.t other (triangulated or triangulatable) surfaces.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
errorManip< error > abort(error &err)
A collection of cell labels.
const cellShapeList & cellShapes() const
Return cell shapes.
static void setSnapTol(const scalar tol)
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
IOstream & hex(IOstream &io)
VectorSpace< Form, Cmpt, Ncmpts > normalised(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Description of cell after splitting. Contains cellLabel and pointers to cells it it split in....
const vectorField & faceCentres() const
const dimensionedScalar e
Elementary charge.
label nPoints() const
Number of mesh points.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
A face is a list of labels corresponding to mesh vertices.
Various functions to operate on Lists.
Maps a geometry to a set of cell primitives.
static void noParallel()
Remove the parallel options.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Foam::argList args(argc, argv)
A cell is defined as a list of faces with extra functionality.
void setInstance(const fileName &instance, const IOobject::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
bool found(const word &optName) const
Return true if the named option is found.
Description of cuts across cells.
dimensionedScalar cos(const dimensionedScalar &ds)
const vectorField & faceAreas() const
Cell-face mesh analysis engine.