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;
502 label nTris = mc.ntrigs();
504 for (label triI = 0; triI < nTris; ++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;
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;
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.
A class for handling file names.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline '\n' character (0x0a)
Implements a timeout mechanism via sigalarm.
scalarField samples(nIntervals, Zero)
Ostream & endl(Ostream &os)
Add newline and flush stream.
std::vector< Triangle > triangles
scalar distance(const vector &p1, const vector &p2)
CGAL::Triangle_3< K > Triangle
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...
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...
#define forAll(list, i)
Loop across all elements in list.
IOoject and searching on triSurface.
Conversion functions between point (Foam::) and Point (CGAL::)
pointField vertices(const blockVertexList &bvl)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const word & system() const noexcept
Return system name.
Container for searchableSurfaces. The collection is specified as a dictionary. For example...
A triFace with additional (region) index.
A location outside the volume.
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
const word & constant() const noexcept
Return constant name.
vector point
Point is a vector.
T get(const label index) const
Get a value from the argument at index.
const dimensionedScalar c
Speed of light in a vacuum.
const polyBoundaryMesh & patches
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)
Identifies a surface patch/zone by name and index, with geometric type.
Standard boundBox with extra functionality for use in octree.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Triangulated surface description with patch information.
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))
Foam::argList args(argc, argv)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Do not request registration (bool: false)
Starts timing CPU usage and return elapsed time from start.