55 static const scalar edgeTol = 1
e-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"
176 printEdgeStats(mesh);
190 const word dictName(
"refineMeshDict");
195 if (dictIO.headerOk())
197 Info<<
"Refining according to "
205 <<
"Cannot open specified refinement dictionary "
210 else if (!refineAllCells)
212 if (dictIO.headerOk())
214 Info<<
"Refining according to "
221 Info<<
"Refinement dictionary "
223 <<
" not found" <<
nl <<
endl;
227 if (refineDict.size())
234 <<
" cells from cellSet "
238 refCells =
cells.toc();
249 Info<<
"3D case; refining all directions" <<
nl <<
endl;
258 refineDict.
add(
"useHexTopology",
"true");
268 Info<<
"2D case; refining in directions y,z\n" <<
endl;
272 else if (dirs.y() == -1)
274 Info<<
"2D case; refining in directions x,z\n" <<
endl;
280 Info<<
"2D case; refining in directions x,y\n" <<
endl;
288 refineDict.
add(
"useHexTopology",
"false");
291 refineDict.
add(
"coordinateSystem",
"global");
296 refineDict.
add(
"globalCoeffs", coeffsDict);
298 refineDict.
add(
"geometricCut",
"false");
299 refineDict.
add(
"writeMesh",
"false");
303 string oldTimeName(runTime.name());
329 cellSet newCells(mesh,
"refinedCells", refCells.
size());
331 forAll(oldToNew, oldCelli)
333 const labelList& added = oldToNew[oldCelli];
337 newCells.insert(added[i]);
341 Info<<
"Writing refined cells ("
344 << newCells.instance()/newCells.local()/newCells.name()
369 "From cells in mesh at "
371 +
" to cells in mesh at "
375 forAll(oldToNew, oldCelli)
377 const labelList& added = oldToNew[oldCelli];
383 newToOld[added[i]] = oldCelli;
389 newToOld[oldCelli] = oldCelli;
393 Info<<
"Writing map from new to old cell to "
394 << newToOld.relativeObjectPath() <<
nl <<
endl;
398 printEdgeStats(mesh);
#define forAll(list, i)
Loop across all elements in list.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void size(const label)
Override size to be inconsistent with allocated storage.
virtual Ostream & write(const char)=0
Write character.
static void addNote(const string &)
Add extra notes for the usage information.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
bool optionFound(const word &opt) const
Return true if the named option is found.
A collection of cell labels.
A list of keyword definitions, which are a keyword followed by any number of values (e....
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per c...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Does multiple pass refinement to refine cells in multiple directions.
Mesh consisting of general polyhedral cells.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
const fileName & pointsInstance() const
Return the current instance directory for points.
virtual const pointField & points() const
Return raw points.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
void setInstance(const fileName &)
Set the instance for mesh files.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
virtual bool write(const bool write=true) const
Write using setting from DB.
Templated form of IOobject providing type information for file reading and header type checking.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
IOobject systemDictIO(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Vector< scalar > vector
A scalar version of the templated Vector.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
Foam::argList args(argc, argv)
Trait for obtaining global write status.