55 static const scalar edgeTol = 1e-3;
59 void printEdgeStats(
const polyMesh& mesh)
75 static const vector z(0, 0, 1);
77 scalar minOther = great;
78 scalar maxOther = -great;
86 if (isMasterEdge[edgeI])
88 const edge& e = edges[edgeI];
92 scalar eMag =
mag(eVec);
96 if (
mag(eVec & x) > 1-edgeTol)
98 minX =
min(minX, eMag);
99 maxX =
max(maxX, eMag);
102 else if (
mag(eVec & y) > 1-edgeTol)
104 minY =
min(minY, eMag);
105 maxY =
max(maxY, eMag);
108 else if (
mag(eVec & z) > 1-edgeTol)
110 minZ =
min(minZ, eMag);
111 maxZ =
max(maxZ, eMag);
116 minOther =
min(minOther, eMag);
117 maxOther =
max(maxOther, eMag);
141 Info<<
"Mesh edge statistics:" <<
nl 142 <<
" x aligned : number:" << nX <<
"\tminLen:" << minX
143 <<
"\tmaxLen:" << maxX <<
nl 144 <<
" y aligned : number:" << nY <<
"\tminLen:" << minY
145 <<
"\tmaxLen:" << maxY <<
nl 146 <<
" z aligned : number:" << nZ <<
"\tminLen:" << minZ
147 <<
"\tmaxLen:" << maxZ <<
nl 148 <<
" other : number:" << nEdges - nX - nY - nZ
149 <<
"\tminLen:" << minOther
150 <<
"\tmaxLen:" << maxOther <<
nl <<
endl;
154 int main(
int argc,
char *argv[])
158 "refine cells in multiple directions" 173 runTime.functionObjects().off();
177 printEdgeStats(mesh);
196 if (dictIO.headerOk())
198 Info<<
"Refining according to " 199 << dictIO.path(typeGlobalFile<IOdictionary>()) <<
nl <<
endl;
205 <<
"Cannot open specified refinement dictionary " 206 << dictIO.path(typeGlobalFile<IOdictionary>())
210 else if (!refineAllCells)
212 if (dictIO.headerOk())
214 Info<<
"Refining according to " 215 << dictIO.path(typeGlobalFile<IOdictionary>()) <<
nl <<
endl;
220 Info<<
"Refinement dictionary " 221 << dictIO.path(typeGlobalFile<IOdictionary>()) <<
" not found" 226 if (refineDict.size())
233 <<
" cells from cellSet " 237 refCells =
cells.toc();
248 Info<<
"3D case; refining all directions" <<
nl <<
endl;
257 refineDict.
add(
"useHexTopology",
"true");
267 Info<<
"2D case; refining in directions y,z\n" <<
endl;
271 else if (dirs.y() == -1)
273 Info<<
"2D case; refining in directions x,z\n" <<
endl;
279 Info<<
"2D case; refining in directions x,y\n" <<
endl;
287 refineDict.
add(
"useHexTopology",
"false");
290 refineDict.
add(
"coordinateSystem",
"global");
295 refineDict.
add(
"globalCoeffs", coeffsDict);
297 refineDict.
add(
"geometricCut",
"false");
298 refineDict.
add(
"writeMesh",
"false");
302 string oldTimeName(runTime.timeName());
328 cellSet newCells(mesh,
"refinedCells", refCells.
size());
330 forAll(oldToNew, oldCelli)
332 const labelList& added = oldToNew[oldCelli];
336 newCells.insert(added[i]);
340 Info<<
"Writing refined cells (" 343 << newCells.instance()/newCells.local()/newCells.name()
368 "From cells in mesh at " 370 +
" to cells in mesh at " 374 forAll(oldToNew, oldCelli)
376 const labelList& added = oldToNew[oldCelli];
382 newToOld[added[i]] = oldCelli;
388 newToOld[oldCelli] = oldCelli;
392 Info<<
"Writing map from new to old cell to " 393 << newToOld.relativeObjectPath() <<
nl <<
endl;
397 printEdgeStats(mesh);
#define forAll(list, i)
Loop across all elements in list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
virtual Ostream & write(const char)=0
Write character.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Templated form of IOobject providing type information for file reading and header type checking...
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.
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...
A class for handling words, derived from string.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
vector vec(const pointField &) const
Return the vector (end - start)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void setInstance(const fileName &)
Set the instance for mesh files.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
A collection of cell labels.
dimensioned< scalar > mag(const dimensioned< Type > &)
IOobject systemDictIO(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
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...
const word dictName("noiseDict")
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.