44#include "opt_octree.h"
78 point p(pt.x(), pt.y(), pt.z());
92 const Level min_level_;
112 searchableSurfacesQueries::signedDistance
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;
367int main(
int argc,
char *argv[])
371 "Re-sample surfaces used in foamyHexMesh operation"
374 argList::addArgument(
"output",
"The output triSurface/ file");
376 argList::noFunctionObjects();
383 Info<<
"Reading surfaces as specified in the foamyHexMeshDict and"
384 <<
" writing a re-sampled surface to " << exportName
396 IOobject::MUST_READ_IF_MODIFIED,
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);
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;
622 IOobject::AUTO_WRITE,
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;
CGAL::Triangle_3< K > Triangle
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
void size(const label n)
Older name for setAddressableSize.
T get(const label index) const
Get a value from the argument at index.
const point & min() const
Minimum describing the bounding box.
vector span() const
The bounding box span (from minimum to maximum)
Starts timing CPU usage and return elapsed time from start.
A class for handling file names.
Identifies a surface patch/zone by name and index, with geometric type.
A triFace with additional (region) index.
Conversion functions between point (Foam::) and Point (CGAL::)
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Implements a timeout mechanism via sigalarm.
Standard boundBox with extra functionality for use in octree.
IOoject and searching on triSurface.
Triangulated surface description with patch information.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
const polyBoundaryMesh & patches
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))
const dimensionedScalar c
Speed of light in a vacuum.
scalar distance(const vector &p1, const vector &p2)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
pointField vertices(const blockVertexList &bvl)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
scalarField samples(nIntervals, Zero)