Go to the documentation of this file.
33 #include "PatchTools.H"
36 #include "triSurface.H"
71 Info<<
"Merge tolerance : " << mergeTol <<
nl
72 <<
"Write tolerance : " << writeTol <<
endl;
77 <<
"Your current settings specify ASCII writing with "
79 <<
"Your merging tolerance (" << mergeTol <<
") is finer than this."
81 <<
"Please change your writeFormat to binary"
82 <<
" or increase the writePrecision" <<
endl
83 <<
"or adjust the merge tolerance (-mergeTol)."
87 scalar mergeDist = mergeTol * bb.
mag();
89 Info<<
"Overall meshes bounding box : " << bb <<
nl
90 <<
"Relative tolerance : " << mergeTol <<
nl
91 <<
"Absolute matching distance : " << mergeDist <<
nl
125 label maxProcCells = 0;
126 label totProcFaces = 0;
127 label maxProcPatches = 0;
128 label totProcPatches = 0;
129 label maxProcFaces = 0;
134 <<
"Processor " << procI <<
nl
135 <<
" Number of cells = " << globalCells.localSize(procI)
138 label nProcFaces = 0;
140 const labelList& nei = patchNeiProcNo[procI];
142 forAll(patchNeiProcNo[procI], i)
144 Info<<
" Number of faces shared with processor "
145 << patchNeiProcNo[procI][i] <<
" = " << patchSize[procI][i]
148 nProcFaces += patchSize[procI][i];
151 Info<<
" Number of processor patches = " << nei.
size() <<
nl
152 <<
" Number of processor faces = " << nProcFaces <<
nl
153 <<
" Number of boundary faces = "
154 << globalBoundaryFaces.localSize(procI) <<
endl;
156 maxProcCells =
max(maxProcCells, globalCells.localSize(procI));
157 totProcFaces += nProcFaces;
158 totProcPatches += nei.
size();
159 maxProcPatches =
max(maxProcPatches, nei.
size());
160 maxProcFaces =
max(maxProcFaces, nProcFaces);
170 if (totProcPatches == 0)
174 if (totProcFaces == 0)
180 <<
"Number of processor faces = " << totProcFaces/2 <<
nl
181 <<
"Max number of cells = " << maxProcCells
182 <<
" (" << 100.0*(maxProcCells-avgProcCells)/avgProcCells
183 <<
"% above average " << avgProcCells <<
")" <<
nl
184 <<
"Max number of processor patches = " << maxProcPatches
185 <<
" (" << 100.0*(maxProcPatches-avgProcPatches)/avgProcPatches
186 <<
"% above average " << avgProcPatches <<
")" <<
nl
187 <<
"Max number of faces between processors = " << maxProcFaces
188 <<
" (" << 100.0*(maxProcFaces-avgProcFaces)/avgProcFaces
189 <<
"% above average " << avgProcFaces <<
")" <<
nl
203 return i*nCells[1]*nCells[2]+j*nCells[2]+
k;
233 if (nCells[0]+nCells[1]+nCells[2] > 0)
235 points.setSize((nCells[0]+1)*(nCells[1]+1)*(nCells[2]+1));
238 for (
label i = 0; i <= nCells[0]; i++)
240 for (
label j = 0; j <= nCells[1]; j++)
242 for (
label k = 0;
k <= nCells[2];
k++)
245 pt.
x() += i*cellSize[0];
246 pt.
y() += j*cellSize[1];
247 pt.
z() +=
k*cellSize[2];
248 points[vtxLabel(nCells, i, j,
k)] = pt;
260 for (
label i = 0; i < nCells[0]; i++)
262 for (
label j = 0; j < nCells[1]; j++)
264 for (
label k = 0;
k < nCells[2];
k++)
266 hexPoints[0] = vtxLabel(nCells, i, j,
k);
267 hexPoints[1] = vtxLabel(nCells, i+1, j,
k);
268 hexPoints[2] = vtxLabel(nCells, i+1, j+1,
k);
269 hexPoints[3] = vtxLabel(nCells, i, j+1,
k);
270 hexPoints[4] = vtxLabel(nCells, i, j,
k+1);
271 hexPoints[5] = vtxLabel(nCells, i+1, j,
k+1);
272 hexPoints[6] = vtxLabel(nCells, i+1, j+1,
k+1);
273 hexPoints[7] = vtxLabel(nCells, i, j+1,
k+1);
291 xferMoveTo<pointField>(
points),
339 forAll(nearestSurfaces, i)
341 if (nearestSurfaces[i] == surfI)
343 surfPoints.append(
points[i]);
344 surfIndices.append(i);
349 label geomI = surfaces[surfI];
351 geometry[geomI].getVolumeType(surfPoints, volType);
356 label pointI = surfIndices[i];
357 scalar dist =
mag(
points[pointI] - nearest[pointI].hitPoint());
372 <<
"getVolumeType failure, neither INSIDE or OUTSIDE"
385 int main(
int argc,
char *argv[])
389 "Generate foamyHexMesh-consistent representation of surfaces"
394 "write the resulting mesh and distance fields"
400 "specify the merge distance relative to the bounding box size "
412 Info<<
"Writing resulting mesh and cellDistance, pointDistance fields."
434 "cvSearchableSurfaces",
441 foamyHexMeshDict.subDict(
"geometry"),
442 foamyHexMeshDict.lookupOrDefault(
"singleRegionName",
true)
452 foamyHexMeshDict.subDict(
"surfaceConformation")
458 foamyHexMeshDict.subDict(
"motionControl"),
467 const treeBoundBox& bb = geometryToConformTo.globalBounds();
471 vector nScalarCells = span/cellShapeControls.defaultCellSize();
477 label(nScalarCells.
x())+2,
478 label(nScalarCells.
y())+2,
488 Info<<
"Generating initial hex mesh with" <<
nl
489 <<
" bounding box : " << bb <<
nl
490 <<
" nCells : " << nCells <<
nl
491 <<
" cellSize : " << cellSize <<
nl
529 if (
isDir(decompDictFile))
531 decompDictFile = decompDictFile /
"decomposeParDict";
552 Info<<
"Wanted distribution:"
553 << distributor.countCells(decomp) <<
nl <<
endl;
563 Info<<
"Writing redistributed mesh" <<
nl <<
endl;
568 Info<<
"Refining backgroud mesh according to cell size specification" <<
nl
572 foamyHexMeshDict.
subDict(
"backgroundMeshDecomposition");
586 backgroundMesh.mesh().
write();
593 backgroundMesh.mesh().bounds()
602 const fvMesh& fvm = backgroundMesh.mesh();
620 const labelList& surfaces = geometryToConformTo.surfaces();
626 const labelList& cellLevel = backgroundMesh.cellLevel();
631 distSqr[cellI] =
magSqr(cellSize)/
pow(2, cellLevel[cellI]);
636 cellDistance.internalField() = signedDistance
650 fld.patch().patchInternalField(distSqr)
652 fld = signedDistance(patchDistSqr, cc, geometry, surfaces);
660 cellDistance.write();
685 label ownDistSqr = distSqr[own];
690 pointDistSqr[
f[fp]] =
max(pointDistSqr[
f[fp]], ownDistSqr);
701 pointDistance.internalField() = signedDistance
711 pointDistance.write();
727 isoFaces[i] = iso[i].triFaceFace();
729 isoPoints = iso.points();
const cellShapeList & cellShapes
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Simple random number generator.
virtual const pointField & points() const
Return raw points.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
scalar mag() const
The magnitude of the bounding box span.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from string.
A class for handling file names.
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
static void addNote(const string &)
Add extra notes for the usage information.
static word defaultRegion
Return the default region name.
#define forAll(list, i)
Loop across all elements in list.
A class for managing temporary objects.
const labelList & processorPatches() const
Return list of processor patch labels.
IOstream::streamFormat writeFormat() const
Default write format.
A List obtained as a section of another List.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Standard boundBox + extra functionality for use in octree.
faceListList boundary(nPatches)
static bool & parRun()
Is this a parallel run?
void printMeshData(const polyMesh &mesh)
virtual void write(const coordSet &, const wordList &, const List< const Field< Type > * > &, Ostream &) const =0
General entry point for writing.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
const functionObjectList & functionObjects() const
Return the list of function objects.
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
int neighbProcNo() const
Return neigbour processor number.
Extract command arguments and options from the supplied argc and argv parameters.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< scalar > mag(const dimensioned< Type > &)
const fileName & instance() const
Mesh consisting of general polyhedral cells.
static const pointMesh & New(const polyMesh &mesh)
A surface formed by the iso value. After "Polygonising A Scalar Field Using Tetrahedrons",...
wordList patchTypes(nPatches)
vector span() const
The bounding box span (from minimum to maximum)
virtual bool write() const
Write mesh using IO settings from time.
scalar getMergeDistance(const argList &args, const Time &runTime, const boundBox &bb)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
const word & system() const
Return system name.
virtual void off()
Switch the function objects off.
virtual Ostream & write(const token &)=0
Write next token to stream.
static const cellModel * lookup(const word &)
Look up a model by name and return a pointer to the model or NULL.
decompositionMethod & decomposer() const
virtual const labelList & faceOwner() const
Return face owner.
Neighbour processor patch.
int main(int argc, char *argv[])
wordList patchNames(nPatches)
const point & min() const
Minimum describing the bounding box.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
A list of keyword definitions, which are a keyword followed by any number of values (e....
label nInternalFaces() const
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Generic dimensioned Type class.
Base class for graphics format writing. Entry points are.
An analytical geometric cellShape.
Mesh data needed to do the Finite Volume discretisation.
bool isDir(const fileName &)
Does the name exist as a DIRECTORY in the file system?
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
const double e
Elementary charge.
Vector< scalar > vector
A scalar version of the templated Vector.
errorManipArg< error, int > exit(error &err, const int errNo=1)
IOstream & hex(IOstream &io)
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
static bool master(const label communicator=0)
Am I the master process.
void setInstance(const fileName &)
Set the instance for mesh files.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const boundBox & bounds() const
Return mesh bounding box.
static const decompositionModel & New(const polyMesh &mesh, const fileName &decompDictFile="")
Read (optionallly from absolute path) & register on mesh.
void setSize(const label)
Reset size of List.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
virtual labelList decompose(const pointField &points, const scalarField &pointWeights)
Return for every coordinate the wanted processor number.
const vectorField & cellCentres() const
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const volVectorField & C() const
Return cell centres as volVectorField.
fileName path() const
Return path.
static unsigned int defaultPrecision()
Return the default precision.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Container for searchableSurfaces.
const word & constant() const
Return constant name.
Store a background polyMesh to use for the decomposition of space and queries for parallel conformalV...
label k
Boltzmann constant.
bool optionFound(const word &opt) const
Return true if the named option is found.
A bounding box defined in terms of the points at its extremities.
const Time & time() const
Return the top-level database.
A face is a list of labels corresponding to mesh vertices.
A surfaceWriter for VTK legacy format.
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
void size(const label)
Override size to be inconsistent with allocated storage.
const globalMeshData & globalData() const
Return parallel info.
static const scalar defaultMergeTol
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Generic GeometricField class.
Foam::argList args(argc, argv)
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
static void findNearest(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &)
Find nearest. Return -1 (and a miss()) or surface and nearest.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
cachedRandom rndGen(label(0), -1)
void writeMesh(const string &msg, const meshRefinement &meshRefiner, const meshRefinement::debugType debugLevel, const meshRefinement::writeType writeLevel)
A list of faces which address into the list of points.