41 #include "opt_octree.h" 70 return Point(p.
x(), p.
y(), p.
z());
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),
141 converter_(converter)
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 = " 424 foamyHexMeshDict.subDict(
"surfaceConformation")
427 Info<<
"Set up geometry in = " 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 = " 486 MarchingCubes& mc = octree.mc();
489 octree.build_isosurface(&
ref) ;
491 Info<<
"Constructed iso surface of distance in = " 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];
524 points[pointi] = converter.toGlobal(v);
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 = " 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 = " 624 Info<<
"writing surfMesh:\n " 625 << smesh.searchableSurface::objectPath() <<
nl <<
endl;
626 smesh.searchableSurface::write();
628 Info<<
"Written surface in = " const fvPatchList & patches
#define forAll(list, i)
Loop across all elements in list.
A class for handling file names.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void size(const label)
Override size to be inconsistent with allocated storage.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
scalar distance(const vector &p1, const vector &p2)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
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.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
A surface geometry formed of discrete facets, e.g. triangles and/or quadrilaterals, defined in a file using formats such as Wavefront OBJ, or stereolithography STL.
Conversion functions between point (Foam::) and Point (CGAL::)
scalarField samples(nIntervals, 0)
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))
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
static const word & geometryDir()
Return the geometry directory name.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Container for searchableSurfaces.
Triangle with additional region number.
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
vector point
Point is a vector.
vector span() const
The bounding box span (from minimum to maximum)
The geometricSurfacePatch is like patchIdentifier but for surfaces. Holds type, name and index...
Standard boundBox + extra functionality for use in octree.
Starts timing CPU usage and return elapsed time from start.
const point & min() const
Minimum point defining the bounding box.
static void addNote(const string &)
Add extra notes for the usage information.
Triangulated surface description with patch information.
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const stringList & args() const
Return arguments.