54 static const scalar edgeTol = 1e-3;
58 void printEdgeStats(
const polyMesh& mesh)
74 static const vector z(0, 0, 1);
76 scalar minOther = great;
77 scalar maxOther = -great;
85 if (isMasterEdge[edgeI])
87 const edge& e = edges[edgeI];
91 scalar eMag =
mag(eVec);
95 if (
mag(eVec & x) > 1-edgeTol)
97 minX =
min(minX, eMag);
98 maxX =
max(maxX, eMag);
101 else if (
mag(eVec & y) > 1-edgeTol)
103 minY =
min(minY, eMag);
104 maxY =
max(maxY, eMag);
107 else if (
mag(eVec & z) > 1-edgeTol)
109 minZ =
min(minZ, eMag);
110 maxZ =
max(maxZ, eMag);
115 minOther =
min(minOther, eMag);
116 maxOther =
max(maxOther, eMag);
140 Info<<
"Mesh edge statistics:" <<
nl 141 <<
" x aligned : number:" << nX <<
"\tminLen:" << minX
142 <<
"\tmaxLen:" << maxX <<
nl 143 <<
" y aligned : number:" << nY <<
"\tminLen:" << minY
144 <<
"\tmaxLen:" << maxY <<
nl 145 <<
" z aligned : number:" << nZ <<
"\tminLen:" << minZ
146 <<
"\tmaxLen:" << maxZ <<
nl 147 <<
" other : number:" << nEdges - nX - nY - nZ
148 <<
"\tminLen:" << minOther
149 <<
"\tmaxLen:" << maxOther <<
nl <<
endl;
153 int main(
int argc,
char *argv[])
157 "refine cells in multiple directions" 176 printEdgeStats(mesh);
211 <<
"Cannot open specified refinement dictionary " 216 Info<<
"Refining according to " << dictPath <<
nl <<
endl;
220 else if (!refineAllCells)
242 if (refineDict.size())
249 <<
" cells from cellSet " 253 refCells =
cells.toc();
264 Info<<
"3D case; refining all directions" <<
nl <<
endl;
273 refineDict.
add(
"useHexTopology",
"true");
283 Info<<
"2D case; refining in directions y,z\n" <<
endl;
287 else if (dirs.y() == -1)
289 Info<<
"2D case; refining in directions x,z\n" <<
endl;
295 Info<<
"2D case; refining in directions x,y\n" <<
endl;
303 refineDict.
add(
"useHexTopology",
"false");
306 refineDict.
add(
"coordinateSystem",
"global");
311 refineDict.
add(
"globalCoeffs", coeffsDict);
313 refineDict.
add(
"geometricCut",
"false");
314 refineDict.
add(
"writeMesh",
"false");
344 cellSet newCells(mesh,
"refinedCells", refCells.
size());
346 forAll(oldToNew, oldCelli)
348 const labelList& added = oldToNew[oldCelli];
352 newCells.insert(added[i]);
356 Info<<
"Writing refined cells (" 359 << newCells.instance()/newCells.local()/newCells.name()
384 "From cells in mesh at " 386 +
" to cells in mesh at " 390 forAll(oldToNew, oldCelli)
392 const labelList& added = oldToNew[oldCelli];
398 newToOld[added[i]] = oldCelli;
404 newToOld[oldCelli] = oldCelli;
408 Info<<
"Writing map from new to old cell to " 409 << newToOld.objectPath() <<
nl <<
endl;
413 printEdgeStats(mesh);
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool typeHeaderOk(const bool checkType=true)
Read header (uses typeFilePath to find file) and check header.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void off()
Switch the function objects off.
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Does multiple pass refinement to refine cells in multiple directions.
void size(const label)
Override size to be inconsistent with allocated storage.
Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per c...
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool optionFound(const word &opt) const
Return true if the named option is found.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Vector< scalar > vector
A scalar version of the templated Vector.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
virtual const pointField & points() const
Return raw points.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
string & note()
Return non-constant access to the optional note.
const fileName & pointsInstance() const
Return the current instance directory for points.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
A class for handling words, derived from string.
const word dictName("particleTrackDict")
const word & system() const
Return system name.
vector vec(const pointField &) const
Return the vector (end - start)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
IOobject dictIO(dictName, runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE)
void setInstance(const fileName &)
Set the instance for mesh files.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const functionObjectList & functionObjects() const
Return the list of function objects.
A collection of cell labels.
dimensioned< scalar > mag(const dimensioned< Type > &)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
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 bool write(const bool write=true) const
Write using setting from DB.
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.