60static const scalar edgeTol = 1
e-3;
80 for (
const label edgei : isMasterEdge)
82 const edge&
e = edges[edgei];
86 scalar eMag =
mag(eVec);
90 if (
mag(eVec.x()) > 1-edgeTol)
95 else if (
mag(eVec.y()) > 1-edgeTol)
100 else if (
mag(eVec.z()) > 1-edgeTol)
122 Info<<
"Mesh edge statistics:" <<
nl
123 <<
" x aligned : number:" << nX
124 <<
"\tminLen:" << limitsX.min() <<
"\tmaxLen:" << limitsX.max() <<
nl
125 <<
" y aligned : number:" << nY
126 <<
"\tminLen:" << limitsY.min() <<
"\tmaxLen:" << limitsY.max() <<
nl
127 <<
" z aligned : number:" << nZ
128 <<
"\tminLen:" << limitsZ.min() <<
"\tmaxLen:" << limitsZ.max() <<
nl
129 <<
" other : number:" << nAny
130 <<
"\tminLen:" << limitsAny.min()
131 <<
"\tmaxLen:" << limitsAny.max() <<
nl <<
endl;
135int main(
int argc,
char *argv[])
139 "Refine cells in multiple directions"
159 const word oldInstance =
mesh.pointsInstance();
161 printEdgeStats(
mesh);
167 const bool refineAllCells =
args.found(
"all");
168 const bool overwrite =
args.found(
"overwrite");
203 Info<<
"Refining according to ";
217 Info<<
"Refinement dictionary " <<
dictName <<
" not found" <<
nl;
222 <<
"Cannot open specified refinement dictionary "
228 if (refineDict.
size())
235 <<
" cells from cellSet "
239 refCells =
cells.toc();
248 if (
mesh.nGeometricD() == 3)
250 Info<<
"3D case; refining all directions" <<
nl <<
endl;
259 refineDict.
add(
"useHexTopology",
"true");
269 Info<<
"2D case; refining in directions y,z\n" <<
endl;
273 else if (dirs.y() == -1)
275 Info<<
"2D case; refining in directions x,z\n" <<
endl;
281 Info<<
"2D case; refining in directions x,y\n" <<
endl;
289 refineDict.
add(
"useHexTopology",
"false");
292 refineDict.
add(
"coordinateSystem",
"global");
297 refineDict.
add(
"globalCoeffs", coeffsDict);
299 refineDict.
add(
"geometricCut",
"false");
300 refineDict.
add(
"writeMesh",
"false");
304 string oldTimeName(
runTime.timeName());
319 mesh.setInstance(oldInstance);
334 newCells.insert(added);
337 Info<<
"Writing refined cells ("
340 << newCells.instance()/newCells.local()/newCells.name()
364 "From cells in mesh at "
366 +
" to cells in mesh at "
370 forAll(oldToNew, oldCelli)
372 const labelList& added = oldToNew[oldCelli];
376 for (
const label celli : added)
378 newToOld[celli] = oldCelli;
384 newToOld[oldCelli] = oldCelli;
388 Info<<
"Writing map from new to old cell to "
389 << newToOld.objectPath() <<
nl <<
endl;
393 printEdgeStats(
mesh);
label size() const noexcept
The number of elements in list.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
@ NO_READ
Nothing to be read.
@ MUST_READ
Reading required.
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static IOobject selectIO(const IOobject &io, const fileName &altFile, const word &ioName="")
Return the IOobject, but also consider an alternative file name.
void size(const label n)
Older name for setAddressableSize.
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
static void addNote(const string ¬e)
Add extra notes for the usage information.
A collection of cell labels.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
entry * add(entry *entryPtr, 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 vertex labels. This can correspond to a directed graph edge or an edge on a ...
A class for handling file names.
Does multiple pass refinement to refine cells in multiple directions.
Mesh consisting of general polyhedral cells.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh").
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const word dictName("faMeshDefinition")
fileName dictPath(runTime.system()/regionDir/faMesh::prefix()/areaRegionDir/dictName)
return returnReduce(nRefine-oldNRefine, sumOp< label >())
List< edge > edgeList
List of edge.
List< word > wordList
List of word.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
IOList< label > labelIOList
IO for a List of label.
messageStream Info
Information stream (stdout output on master, null elsewhere).
MinMax< scalar > scalarMinMax
A scalar min/max range.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.