60 static const scalar edgeTol = 1
e-3;
80 static const vector z(0, 0, 1);
82 scalar minOther = GREAT;
83 scalar maxOther = -GREAT;
91 if (isMasterEdge.test(edgeI))
93 const edge&
e = edges[edgeI];
97 scalar eMag =
mag(eVec);
101 if (
mag(eVec &
x) > 1-edgeTol)
103 minX =
min(minX, eMag);
104 maxX =
max(maxX, eMag);
107 else if (
mag(eVec &
y) > 1-edgeTol)
109 minY =
min(minY, eMag);
110 maxY =
max(maxY, eMag);
113 else if (
mag(eVec & z) > 1-edgeTol)
115 minZ =
min(minZ, eMag);
116 maxZ =
max(maxZ, eMag);
121 minOther =
min(minOther, eMag);
122 maxOther =
max(maxOther, eMag);
146 Info<<
"Mesh edge statistics:" <<
nl 147 <<
" x aligned : number:" << nX <<
"\tminLen:" << minX
148 <<
"\tmaxLen:" << maxX <<
nl 149 <<
" y aligned : number:" << nY <<
"\tminLen:" << minY
150 <<
"\tmaxLen:" << maxY <<
nl 151 <<
" z aligned : number:" << nZ <<
"\tminLen:" << minZ
152 <<
"\tmaxLen:" << maxZ <<
nl 153 <<
" other : number:" << nEdges - nX - nY - nZ
154 <<
"\tminLen:" << minOther
155 <<
"\tmaxLen:" << maxOther <<
nl <<
endl;
159 int main(
int argc,
char *argv[])
163 "Refine cells in multiple directions" 185 printEdgeStats(
mesh);
191 const bool refineAllCells =
args.
found(
"all");
192 const bool overwrite =
args.
found(
"overwrite");
227 Info<<
"Refining according to ";
229 if (dictPath.empty())
239 else if (dictPath.empty())
241 Info<<
"Refinement dictionary " <<
dictName <<
" not found" <<
nl;
246 <<
"Cannot open specified refinement dictionary " 252 if (refineDict.size())
259 <<
" cells from cellSet " 263 refCells =
cells.toc();
274 Info<<
"3D case; refining all directions" <<
nl <<
endl;
283 refineDict.
add(
"useHexTopology",
"true");
293 Info<<
"2D case; refining in directions y,z\n" <<
endl;
297 else if (dirs.y() == -1)
299 Info<<
"2D case; refining in directions x,z\n" <<
endl;
305 Info<<
"2D case; refining in directions x,y\n" <<
endl;
313 refineDict.
add(
"useHexTopology",
"false");
316 refineDict.
add(
"coordinateSystem",
"global");
321 refineDict.
add(
"globalCoeffs", coeffsDict);
323 refineDict.
add(
"geometricCut",
"false");
324 refineDict.
add(
"writeMesh",
"false");
361 Info<<
"Writing refined cells (" 364 << newCells.instance()/newCells.local()/newCells.name()
388 "From cells in mesh at " 390 +
" to cells in mesh at " 394 forAll(oldToNew, oldCelli)
396 const labelList& added = oldToNew[oldCelli];
400 for (
const label celli : added)
402 newToOld[celli] = oldCelli;
408 newToOld[oldCelli] = oldCelli;
412 Info<<
"Writing map from new to old cell to " 413 << newToOld.objectPath() <<
nl <<
endl;
417 printEdgeStats(
mesh);
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
Does multiple pass refinement to refine cells in multiple directions.
Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per c...
const word dictName("faMeshDefinition")
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Ostream & endl(Ostream &os)
Add newline and flush stream.
const string & note() const noexcept
Return the optional note.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
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.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
const dimensionedScalar e
Elementary charge.
const fileName & pointsInstance() const
Return the current instance directory for points.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
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...
A class for handling words, derived from Foam::string.
const word & system() const noexcept
Return system name.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
label nEdges() const
Number of mesh edges.
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (respects is_globalIOobject trait) and check its info.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
label nCells() const noexcept
Number of mesh cells.
A collection of cell labels.
Automatically write from objectRegistry::writeObject()
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Mesh consisting of general polyhedral cells.
Foam::argList args(argc, argv)
Defines the attributes of an object for which implicit objectRegistry management is supported...
bool found(const word &optName) const
Return true if the named option is found.
static IOobject selectIO(const IOobject &io, const fileName &altFile, const word &ioName="")
Return the IOobject, but also consider an alternative file name.