44#include "opt_octree.h"
78 point p(pt.x(), pt.y(), pt.z());
92 const Level min_level_;
94 const conformationSurfaces& geometryToConformTo_;
96 const pointConversion& converter_;
103 const searchableSurfaces& geometry = geometryToConformTo_.
geometry();
112 searchableSurfacesQueries::signedDistance
137 const conformationSurfaces& geometryToConformTo,
138 const pointConversion& converter
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;
184 const searchableSurfaces& geometry =
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"
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;
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...
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label n)
Older name for setAddressableSize.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
static void addNote(const string ¬e)
Add extra notes for the usage information.
const point & min() const noexcept
Minimum describing the bounding box.
vector span() const
The bounding box span (from minimum to maximum).
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)
List< word > wordList
List of word.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
pointField vertices(const blockVertexList &bvl)
vector point
Point is a vector.
List< geometricSurfacePatch > geometricSurfacePatchList
List of geometricSurfacePatch.
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
vectorField pointField
pointField is a vectorField.
cpuTimePosix cpuTime
Selection of preferred clock mechanism for the elapsed cpu time.
constexpr char nl
The newline '\n' character (0x0a).
std::vector< Triangle > triangles
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
scalarField samples(nIntervals, Zero)