Go to the documentation of this file.
57 static const scalar defaultMergeTol = 1
e-6;
60 scalar getMergeDistance
67 const scalar mergeTol =
73 Info<<
"Merge tolerance : " << mergeTol <<
nl
74 <<
"Write tolerance : " << writeTol <<
endl;
79 <<
"Your current settings specify ASCII writing with "
81 <<
"Your merging tolerance (" << mergeTol <<
") is finer than this."
83 <<
"Please change your writeFormat to binary"
84 <<
" or increase the writePrecision" <<
endl
85 <<
"or adjust the merge tolerance (-mergeTol)."
89 scalar mergeDist = mergeTol * bb.
mag();
91 Info<<
"Overall meshes bounding box : " << bb <<
nl
92 <<
"Relative tolerance : " << mergeTol <<
nl
93 <<
"Absolute matching distance : " << mergeDist <<
nl
127 label maxProcCells = 0;
128 label totProcFaces = 0;
129 label maxProcPatches = 0;
130 label totProcPatches = 0;
131 label maxProcFaces = 0;
136 <<
"Processor " << proci <<
nl
137 <<
" Number of cells = " << globalCells.localSize(proci)
140 label nProcFaces = 0;
142 const labelList& nei = patchNeiProcNo[proci];
144 forAll(patchNeiProcNo[proci], i)
146 Info<<
" Number of faces shared with processor "
147 << patchNeiProcNo[proci][i] <<
" = " << patchSize[proci][i]
150 nProcFaces += patchSize[proci][i];
153 Info<<
" Number of processor patches = " << nei.size() <<
nl
154 <<
" Number of processor faces = " << nProcFaces <<
nl
155 <<
" Number of boundary faces = "
156 << globalBoundaryFaces.localSize(proci) <<
endl;
158 maxProcCells =
max(maxProcCells, globalCells.localSize(proci));
159 totProcFaces += nProcFaces;
160 totProcPatches += nei.size();
161 maxProcPatches =
max(maxProcPatches, nei.size());
162 maxProcFaces =
max(maxProcFaces, nProcFaces);
172 if (totProcPatches == 0)
176 if (totProcFaces == 0)
182 <<
"Number of processor faces = " << totProcFaces/2 <<
nl
183 <<
"Max number of cells = " << maxProcCells
184 <<
" (" << 100.0*(maxProcCells-avgProcCells)/avgProcCells
185 <<
"% above average " << avgProcCells <<
")" <<
nl
186 <<
"Max number of processor patches = " << maxProcPatches
187 <<
" (" << 100.0*(maxProcPatches-avgProcPatches)/avgProcPatches
188 <<
"% above average " << avgProcPatches <<
")" <<
nl
189 <<
"Max number of faces between processors = " << maxProcFaces
190 <<
" (" << 100.0*(maxProcFaces-avgProcFaces)/avgProcFaces
191 <<
"% above average " << avgProcFaces <<
")" <<
nl
205 return i*nCells[1]*nCells[2]+j*nCells[2]+
k;
235 if (nCells[0]+nCells[1]+nCells[2] > 0)
237 points.setSize((nCells[0]+1)*(nCells[1]+1)*(nCells[2]+1));
240 for (label i = 0; i <= nCells[0]; i++)
242 for (label j = 0; j <= nCells[1]; j++)
244 for (label
k = 0;
k <= nCells[2];
k++)
247 pt.
x() += i*cellSize[0];
248 pt.
y() += j*cellSize[1];
249 pt.
z() +=
k*cellSize[2];
250 points[vtxLabel(nCells, i, j,
k)] = pt;
262 for (label i = 0; i < nCells[0]; i++)
264 for (label j = 0; j < nCells[1]; j++)
266 for (label
k = 0;
k < nCells[2];
k++)
268 hexPoints[0] = vtxLabel(nCells, i, j,
k);
269 hexPoints[1] = vtxLabel(nCells, i+1, j,
k);
270 hexPoints[2] = vtxLabel(nCells, i+1, j+1,
k);
271 hexPoints[3] = vtxLabel(nCells, i, j+1,
k);
272 hexPoints[4] = vtxLabel(nCells, i, j,
k+1);
273 hexPoints[5] = vtxLabel(nCells, i+1, j,
k+1);
274 hexPoints[6] = vtxLabel(nCells, i+1, j+1,
k+1);
275 hexPoints[7] = vtxLabel(nCells, i, j+1,
k+1);
338 forAll(nearestSurfaces, i)
340 if (nearestSurfaces[i] == surfI)
342 surfPoints.append(
points[i]);
343 surfIndices.append(i);
348 label geomI = surfaces[surfI];
350 geometry[geomI].getVolumeType(surfPoints, volType);
355 label pointi = surfIndices[i];
356 scalar dist =
mag(
points[pointi] - nearest[pointi].hitPoint());
371 <<
"getVolumeType failure, neither INSIDE or OUTSIDE"
384 int main(
int argc,
char *argv[])
388 "Generate foamyHexMesh-consistent representation of surfaces"
393 "Write the resulting mesh and distance fields"
399 "The merge distance relative to the bounding box size (default 1e-6)"
407 const bool writeMesh =
args.
found(
"writeMesh");
411 Info<<
"Writing resulting mesh and cellDistance, pointDistance fields."
433 "cvSearchableSurfaces",
440 foamyHexMeshDict.subDict(
"geometry"),
441 foamyHexMeshDict.getOrDefault(
"singleRegionName",
true)
451 foamyHexMeshDict.subDict(
"surfaceConformation")
457 foamyHexMeshDict.subDict(
"motionControl"),
466 const treeBoundBox& bb = geometryToConformTo.globalBounds();
470 vector nScalarCells = span/cellShapeControls.defaultCellSize();
476 label(nScalarCells.
x())+2,
477 label(nScalarCells.
y())+2,
478 label(nScalarCells.
z())+2
487 Info<<
"Generating initial hex mesh with" <<
nl
488 <<
" bounding box : " << bb <<
nl
489 <<
" nCells : " << nCells <<
nl
490 <<
" cellSize : " << cellSize <<
nl
512 Info<<
"Writing initial hex mesh to " <<
meshPtr().instance() <<
nl
545 Info<<
"Wanted distribution:"
546 << distributor.countCells(decomp) <<
nl <<
endl;
556 Info<<
"Writing redistributed mesh" <<
nl <<
endl;
561 Info<<
"Refining background mesh according to cell size specification" <<
nl
565 foamyHexMeshDict.
subDict(
"backgroundMeshDecomposition");
579 backgroundMesh.mesh().
write();
582 const scalar tolDim = getMergeDistance
586 backgroundMesh.mesh().bounds()
595 const fvMesh& fvm = backgroundMesh.mesh();
613 const labelList& surfaces = geometryToConformTo.surfaces();
619 const labelList& cellLevel = backgroundMesh.cellLevel();
624 distSqr[celli] =
magSqr(cellSize)/
pow(2, cellLevel[celli]);
629 cellDistance.primitiveFieldRef() = signedDistance
639 cellDistance.boundaryFieldRef();
646 fld.patch().patchInternalField(distSqr)
648 fld = signedDistance(patchDistSqr, cc, geometry, surfaces);
656 cellDistance.write();
681 label ownDistSqr = distSqr[own];
686 pointDistSqr[
f[fp]] =
max(pointDistSqr[
f[fp]], ownDistSqr);
697 pointDistance.primitiveFieldRef() = signedDistance
707 pointDistance.write();
722 isoFaces[i] = iso[i];
724 isoPoints = iso.points();
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
static autoPtr< T > New(Args &&... args)
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
virtual const pointField & points() const
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from Foam::string.
A class for handling file names.
virtual bool write(const bool valid=true) const
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
static word defaultRegion
T getOrDefault(const word &optName, const T &deflt) const
A class for managing temporary objects.
static constexpr const zero Zero
IOstream::streamFormat writeFormat() const
A List obtained as a section of another List.
Standard boundBox with extra functionality for use in octree.
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
static word timeName(const scalar t, const int precision=precision_)
static void addNote(const string ¬e)
static bool master(const label communicator=worldComm)
Extract command arguments and options from the supplied argc and argv parameters.
const polyBoundaryMesh & boundaryMesh() const
Ostream & endl(Ostream &os)
decompositionMethod & decomposer() const
Mesh consisting of general polyhedral cells.
const labelList & processorPatches() const noexcept
label nPoints() const noexcept
A surface formed by the iso value. After "Polygonising A Scalar Field Using Tetrahedrons",...
wordList patchTypes(nPatches)
static const decompositionModel & New(const polyMesh &mesh, const fileName &decompDictFile="", const dictionary *fallback=nullptr)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
static void noFunctionObjects(bool addWithOption=false)
label nCells() const noexcept
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Generic templated field type.
void setSize(const label n)
virtual const labelList & faceOwner() const
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
label nBoundaryFaces() const noexcept
Neighbour processor patch.
wordList patchNames(nPatches)
const point & min() const
static const cellModel & ref(const modelType model)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
label max(const labelHashSet &set, label maxValue=labelMin)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const volVectorField & C() const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Generic dimensioned Type class.
Base class for graphics format writing. Entry points are.
virtual bool write(const token &tok)=0
Mesh data needed to do the Finite Volume discretisation.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
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 void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
static unsigned int defaultPrecision() noexcept
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
const vectorField & cellCentres() const
const word & system() const
@ ASCII
"ascii" (normal default)
virtual const faceList & faces() const
#define FatalErrorInFunction
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
virtual labelList decompose(const pointField &points, const scalarField &pointWeights) const
static rangeType allProcs(const label communicator=worldComm)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
static int myProcNo(const label communicator=worldComm)
Write faces/points (optionally with fields) as a vtp file or a legacy vtk file.
label nInternalFaces() const noexcept
static bool & parRun() noexcept
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Store a background polyMesh to use for the decomposition of space and queries for parallel conformalV...
const dimensionedScalar e
@ INSIDE
A location inside the volume.
A bounding box defined in terms of min/max extrema points.
const Time & time() const
A face is a list of labels corresponding to mesh vertices.
Maps a geometry to a set of cell primitives.
const globalMeshData & globalData() const
const word & constant() const
Generic GeometricField class.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Foam::argList args(argc, argv)
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
Foam::autoPtr< Foam::fvMesh > meshPtr(nullptr)
static void findNearest(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &)
void setInstance(const fileName &instance, const IOobject::writeOption wOpt=IOobject::AUTO_WRITE)
static label nProcs(const label communicator=worldComm)
@ OUTSIDE
A location outside the volume.
const Boundary & boundaryField() const
bool found(const word &optName) const
A list of faces which address into the list of points.