60static const scalar edgeTol = 1
e-3;
80 static const vector z(0, 0, 1);
82 scalar minOther = GREAT;
83 scalar maxOther = -GREAT;
85 bitSet isMasterEdge(syncTools::getMasterEdges(
mesh));
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;
159int main(
int argc,
char *argv[])
163 "Refine cells in multiple directions"
169 argList::addOption(
"dict",
"file",
"Alternative refineMeshDict");
171 argList::addBoolOption
177 argList::noFunctionObjects();
183 const word oldInstance =
mesh.pointsInstance();
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();
272 if (
mesh.nGeometricD() == 3)
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");
328 string oldTimeName(
runTime.timeName());
343 mesh.setInstance(oldInstance);
358 newCells.insert(added);
361 Info<<
"Writing refined cells ("
364 << newCells.instance()/newCells.local()/newCells.name()
380 polyMesh::meshSubDir,
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);
reduce(hasMovingMesh, orOp< bool >())
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
void size(const label n)
Older name for setAddressableSize.
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
bool found(const word &optName) const
Return true if the named option is found.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
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
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 point labels. The functionality it provides supports the discretisation on a...
A class for handling file names.
Does multiple pass refinement to refine cells in multiple directions.
Mesh consisting of general polyhedral cells.
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")
const labelList nEdges(UPstream::listGatherValues< label >(aMesh.nEdges()))
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
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.