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)
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 =
points[pointi].dist(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();
719 isoFaces.setSize(iso.size());
722 isoFaces[i] = iso[i];
724 isoPoints = iso.points();
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.
fileName path() const
Return path = rootPath/caseName. Same as TimePaths::path()
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/"finiteArea-edgesCentres"))
label nPoints() const noexcept
Number of mesh points.
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...
IOstream & hex(IOstream &io)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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.
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject. Registered with typeName.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
const labelList & processorPatches() const noexcept
Return list of processor patch labels.
constexpr char nl
The newline '\n' character (0x0a)
wordList patchTypes(nPatches)
Write faces/points (optionally with fields) as a vtp file or a legacy vtk file.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
static unsigned int defaultPrecision() noexcept
Return the default precision.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
A bounding box defined in terms of min/max extrema points.
label k
Boltzmann constant.
Ignore writing from objectRegistry::writeObject()
const point & min() const noexcept
Minimum describing the bounding box.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
An enumeration wrapper for classification of a location as being inside/outside of a volume...
static const decompositionModel & New(const polyMesh &mesh, const fileName &decompDictFile="", const dictionary *fallback=nullptr)
Read and register on mesh, optionally with alternative decomposeParDict path/name or with fallback co...
const Time & time() const
Return the top-level database.
decompositionMethod & decomposer() const
Return demand-driven decomposition method.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Neighbour processor patch.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
static const cellModel & ref(const modelType model)
Look up reference to cellModel by enumeration. Fatal on failure.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
A List obtained as a section of another List.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.
static void gatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
Foam::autoPtr< Foam::dynamicFvMesh > meshPtr
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
static word defaultRegion
Return the default region name.
Extract command arguments and options from the supplied argc and argv parameters. ...
scalar mag() const
The magnitude/length of the bounding box diagonal.
const word & system() const noexcept
Return system name.
wordList patchNames(nPatches)
virtual const labelList & faceOwner() const
Return face owner.
Container for searchableSurfaces. The collection is specified as a dictionary. For example...
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.
const globalMeshData & globalData() const
Return parallel info (demand-driven)
label nInternalFaces() const noexcept
Number of internal faces.
A surface formed by the iso value. After "Polygonising A Scalar Field Using Tetrahedrons", Paul Bourke (http://paulbourke.net/geometry/polygonise) and "Regularised Marching Tetrahedra: improved iso-surface extraction", G.M. Treece, R.W. Prager and A.H. Gee.
A location inside the volume.
virtual const faceList & faces() const
Return raw faces.
A location outside the volume.
const vectorField & cellCentres() const
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
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 word & constant() const noexcept
Return constant name.
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field...
int neighbProcNo() const noexcept
Return neighbour processor number.
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))
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
label nCells() const noexcept
Number of mesh cells.
Mesh data needed to do the Finite Volume discretisation.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
Maps a geometry to a set of cell primitives.
vector span() const
The bounding box span (from minimum to maximum)
Standard boundBox with extra functionality for use in octree.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual bool writeGeometry()
Write patch topology.
Store a background polyMesh to use for the decomposition of space and queries for parallel conformalV...
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Mesh consisting of general polyhedral cells.
const volVectorField & C() const
Return cell centres as volVectorField.
IOstreamOption::streamFormat writeFormat() const noexcept
Get write stream format.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
Foam::argList args(argc, argv)
Defines the attributes of an object for which implicit objectRegistry management is supported...
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
Do not request registration (bool: false)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
bool found(const word &optName) const
Return true if the named option is found.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights=scalarField::null()) const
Return the wanted processor number for every coordinate, using uniform or specified point weights...
static constexpr const zero Zero
Global zero (0)