Go to the documentation of this file.
41 #include "opt_octree.h"
75 point p(pt.x(), pt.y(), pt.z());
89 const Level min_level_;
138 data_access(max_level_,iso_val_),
139 min_level_(min_level),
140 geometryToConformTo_(geometryToConformTo),
146 virtual ~distanceCalc()
153 virtual bool need_refine(
const Cube &
c )
157 if ( l >= _max_level )
return false;
158 if ( l < min_level_ )
return true;
192 if (geometry[surfaces[i]].overlaps(bb))
356 virtual real value_at(
const Cube &
c )
358 return signedDistance(converter_.toGlobal(
c)) - _iso_val;
365 int main(
int argc,
char *argv[])
369 "Re-sample surfaces used in foamyHexMesh operation"
375 runTime.functionObjects().off();
379 Info<<
"Reading surfaces as specified in the foamyHexMeshDict and"
380 <<
" writing a re-sampled surface to " << exportName
402 "cvSearchableSurfaces",
409 foamyHexMeshDict.subDict(
"geometry"),
410 foamyHexMeshDict.lookupOrDefault(
"singleRegionName",
true)
413 Info<<
"Geometry read in = "
414 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
424 foamyHexMeshDict.subDict(
"surfaceConformation")
427 Info<<
"Set up geometry in = "
428 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
432 const labelList& surfaces = geometryToConformTo.surfaces();
435 const label minLevel = 2;
439 const scalar maxSize = 1.0 / (1 << minLevel);
440 const scalar halfMaxSize = 0.5*maxSize;
446 scalar wantedRange = 1.0-maxSize;
448 const treeBoundBox bb = geometryToConformTo.globalBounds();
452 point(wantedRange, wantedRange, wantedRange),
458 point(halfMaxSize, halfMaxSize, halfMaxSize),
481 octree.set_impl(&ref);
483 Info<<
"Calculated octree in = "
484 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
486 MarchingCubes& mc = octree.mc();
489 octree.build_isosurface(&ref) ;
491 Info<<
"Constructed iso surface of distance in = "
492 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
497 Triangle* triangles = mc.triangles();
498 label nTris = mc.ntrigs();
500 for (
label triI = 0; triI < nTris; ++triI)
502 const Triangle& t = triangles[triI];
503 if (t.v1 != t.v2 && t.v1 != t.v3 && t.v2 != t.v3)
519 Point* vertices = mc.vertices();
523 const Point& v = vertices[pointI];
533 const wordList& regions = geometry[surfaces[i]].regions();
534 regionOffsets[i] = nRegions;
535 nRegions += regions.
size();
543 const wordList& regions = geometry[surfaces[i]].regions();
550 geometry[surfaces[i]].
name() +
"_" + regions[regionI],
560 Info<<
"Extracted triSurface in = "
561 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
568 geometryToConformTo.findSurfaceNearest
587 if (hitSurfaces[triI] == surfI)
589 surfInfo.append(hitInfo[triI]);
590 surfIndices.append(triI);
596 geometry[surfaces[surfI]].getRegion(surfInfo, region);
600 label triI = surfIndices[i];
601 s[triI].region() = regionOffsets[surfI]+region[i];
606 Info<<
"Re-patched surface in = "
607 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
624 Info<<
"writing surfMesh:\n "
625 << smesh.searchableSurface::objectPath() <<
nl <<
endl;
626 smesh.searchableSurface::write();
628 Info<<
"Written surface in = "
629 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Starts timing CPU usage and return elapsed time from start.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Simple random number generator.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Conversion functions between point (Foam::) and Point (CGAL::)
const stringList & args() const
Return arguments.
CGAL::Triangle_3< K > Triangle
A class for handling file names.
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
static void addNote(const string &)
Add extra notes for the usage information.
#define forAll(list, i)
Loop across all elements in list.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
The geometricSurfacePatch is like patchIdentifier but for surfaces. Holds type, name and index.
Standard boundBox + extra functionality for use in octree.
IOoject and searching on triSurface.
Ostream & endl(Ostream &os)
Add newline and flush stream.
vector span() const
The bounding box span (from minimum to maximum)
scalarField samples(nIntervals, 0)
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.
Triangulated surface description with patch information.
static void signedDistance(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, const volumeType illegalHandling, labelList &nearestSurfaces, scalarField &distance)
Find signed distance to nearest surface. Outside is positive.
int main(int argc, char *argv[])
const point & min() const
Minimum describing the bounding box.
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){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
scalar distance(const vector &p1, const vector &p2)
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
std::stringstream converter
dimensionedSymmTensor sqr(const dimensionedVector &dv)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Container for searchableSurfaces.
Implements a timeout mechanism via sigalarm.
Triangle with additional region number.
const dimensionedScalar c
Speed of light in a vacuum.
void size(const label)
Override size to be inconsistent with allocated storage.
vector point
Point is a vector.
Foam::argList args(argc, argv)
cachedRandom rndGen(label(0), -1)
word name(const complex &)
Return a string representation of a complex.