Go to the documentation of this file.
44 #include "opt_octree.h"
78 point p(pt.x(), pt.y(), pt.z());
92 const Level min_level_;
141 data_access(max_level_,iso_val_),
142 min_level_(min_level),
143 geometryToConformTo_(geometryToConformTo),
144 converter_(converter)
149 virtual ~distanceCalc() =
default;
155 virtual bool need_refine(
const Cube &
c )
159 if ( l >= _max_level )
return false;
160 if ( l < min_level_ )
return true;
194 if (geometry[surfaces[i]].overlaps(bb))
358 virtual real value_at(
const Cube &
c )
360 return signedDistance(converter_.toGlobal(
c)) - _iso_val;
367 int main(
int argc,
char *argv[])
371 "Re-sample surfaces used in foamyHexMesh operation"
383 Info<<
"Reading surfaces as specified in the foamyHexMeshDict and"
384 <<
" writing a re-sampled surface to " << exportName
406 "cvSearchableSurfaces",
413 foamyHexMeshDict.subDict(
"geometry"),
414 foamyHexMeshDict.getOrDefault(
"singleRegionName",
true)
417 Info<<
"Geometry read in = "
418 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
428 foamyHexMeshDict.subDict(
"surfaceConformation")
431 Info<<
"Set up geometry in = "
432 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
436 const labelList& surfaces = geometryToConformTo.surfaces();
439 const label minLevel = 2;
443 const scalar maxSize = 1.0 / (1 << minLevel);
444 const scalar halfMaxSize = 0.5*maxSize;
450 scalar wantedRange = 1.0-maxSize;
452 const treeBoundBox bb = geometryToConformTo.globalBounds();
456 point(wantedRange, wantedRange, wantedRange),
462 point(halfMaxSize, halfMaxSize, halfMaxSize),
485 octree.set_impl(&
ref);
487 Info<<
"Calculated octree in = "
488 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
490 MarchingCubes& mc = octree.mc();
493 octree.build_isosurface(&
ref) ;
495 Info<<
"Constructed iso surface of distance in = "
496 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
501 Triangle* triangles = mc.triangles();
502 label nTris = mc.ntrigs();
504 for (label triI = 0; triI < nTris; ++triI)
506 const Triangle& t = triangles[triI];
507 if (t.v1 != t.v2 && t.v1 != t.v3 && t.v2 != t.v3)
528 points[pointi] = converter.toGlobal(v);
533 labelList regionOffsets(surfaces.size());
537 const wordList& regions = geometry[surfaces[i]].regions();
538 regionOffsets[i] = nRegions;
539 nRegions += regions.size();
547 const wordList& regions = geometry[surfaces[i]].regions();
553 geometry[surfaces[i]].
name() +
"_" + regions[regionI],
564 Info<<
"Extracted triSurface in = "
565 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
572 geometryToConformTo.findSurfaceNearest
591 if (hitSurfaces[triI] == surfI)
593 surfInfo.append(hitInfo[triI]);
594 surfIndices.append(triI);
600 geometry[surfaces[surfI]].getRegion(surfInfo, region);
604 label triI = surfIndices[i];
605 s[triI].region() = regionOffsets[surfI]+region[i];
610 Info<<
"Re-patched surface in = "
611 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
628 Info<<
"writing surfMesh:\n "
629 << smesh.searchableSurface::objectPath() <<
nl <<
endl;
630 smesh.searchableSurface::write();
632 Info<<
"Written surface in = "
633 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Conversion functions between point (Foam::) and Point (CGAL::)
CGAL::Triangle_3< K > Triangle
A class for handling file names.
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;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
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 with extra functionality for use in octree.
static void addNote(const string ¬e)
Add extra notes for the usage information.
IOoject and searching on triSurface.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const point & min() const
Minimum describing the bounding box.
#define forAll(list, i)
Loop across all elements in list.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
vector span() const
The bounding box span (from minimum to maximum)
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
Triangulated surface description with patch information.
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
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.
scalarField samples(nIntervals, Zero)
Starts timing CPU usage and return elapsed time from start.
pointField vertices(const blockVertexList &bvl)
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 > &)
const word & system() const
Return system name.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Implements a timeout mechanism via sigalarm.
const polyBoundaryMesh & patches
Triangle with additional region number.
const dimensionedScalar c
Speed of light in a vacuum.
vector point
Point is a vector.
const word & constant() const
Return constant name.
Foam::argList args(argc, argv)
A location outside the volume.