Go to the documentation of this file.
40 #include "MarchingCubes.h"
49 int main(
int argc,
char *argv[])
53 "Re-sample surfaces used in foamyHexMesh operation"
61 runTime.functionObjects().off();
66 Info<<
"Reading surfaces as specified in the foamyHexMeshDict and"
67 <<
" writing re-sampled " <<
n <<
" to " << exportName
89 "cvSearchableSurfaces",
96 foamyHexMeshDict.subDict(
"geometry"),
97 foamyHexMeshDict.lookupOrDefault(
"singleRegionName",
true)
100 Info<<
"Geometry read in = "
101 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
111 foamyHexMeshDict.subDict(
"surfaceConformation")
114 Info<<
"Set up geometry in = "
115 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
123 bb.
min() -= smallVec;
124 bb.
max() += smallVec;
127 Info<<
"Meshing to bounding box " << bb <<
nl <<
endl;
137 MarchingCubes mc(span.x(), span.y(), span.z() ) ;
138 mc.set_resolution(
n.x(),
n.y(),
n.z());
147 for(
int k = 0 ;
k < mc.size_z() ;
k++ )
149 pt.
z() = bb.
min().
z() +
k*d.z();
150 for(
int j = 0 ; j < mc.size_y() ; j++ )
152 pt.
y() = bb.
min().
y() + j*d.y();
153 for(
int i = 0 ; i < mc.size_x() ; i++ )
155 pt.
x() = bb.
min().
x() + i*d.x();
161 Info<<
"Generated " <<
points.size() <<
" sampling points in = "
162 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
167 const labelList& surfaces = geometryToConformTo.surfaces();
177 searchableSurface::OUTSIDE,
185 for(
int k = 0 ;
k < mc.size_z() ;
k++ )
187 for(
int j = 0 ; j < mc.size_y() ; j++ )
189 for(
int i = 0 ; i < mc.size_x() ; i++ )
191 mc.set_data(
float(signedDist[pointI++]), i, j,
k);
196 Info<<
"Determined signed distance in = "
197 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
202 Info<<
"Constructed iso surface in = "
203 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
213 Triangle* triangles = mc.triangles();
227 Vertex* vertices = mc.vertices();
231 Vertex& v = vertices[pointI];
234 bb.
min().
x() + v.x*span.x()/mc.size_x(),
235 bb.
min().
y() + v.y*span.y()/mc.size_y(),
236 bb.
min().
z() + v.z*span.z()/mc.size_z()
246 const wordList& regions = geometry[surfaces[i]].regions();
247 regionOffsets[i] = nRegions;
248 nRegions += regions.
size();
256 const wordList& regions = geometry[surfaces[i]].regions();
263 geometry[surfaces[i]].
name() +
"_" + regions[regionI],
272 Info<<
"Extracted triSurface in = "
273 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
280 geometryToConformTo.findSurfaceNearest
299 if (hitSurfaces[triI] == surfI)
301 surfInfo.append(hitInfo[triI]);
302 surfIndices.append(triI);
308 geometry[surfaces[surfI]].getRegion(surfInfo, region);
312 label triI = surfIndices[i];
313 s[triI].region() = regionOffsets[surfI]+region[i];
318 Info<<
"Re-patched surface in = "
319 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
336 Info<<
"writing surfMesh:\n "
337 << smesh.searchableSurface::objectPath() <<
nl <<
endl;
338 smesh.searchableSurface::write();
340 Info<<
"Written surface in = "
341 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Starts timing CPU usage and return elapsed time from start.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Simple random number generator.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const stringList & args() const
Return arguments.
CGAL::Triangle_3< K > Triangle
A class for handling file names.
const point & max() const
Maximum describing the bounding box.
static void addNote(const string &)
Add extra notes for the usage information.
#define forAll(list, i)
Loop across all elements in list.
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 + extra functionality for use in octree.
graph_traits< Graph >::vertex_descriptor Vertex
IOoject and searching on triSurface.
Ostream & endl(Ostream &os)
Add newline and flush stream.
vector span() const
The bounding box span (from minimum to maximum)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
Triangulated surface description with patch information.
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.
int main(int argc, char *argv[])
const point & min() const
Minimum describing the bounding box.
Input from memory buffer stream.
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))
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Container for searchableSurfaces.
Implements a timeout mechanism via sigalarm.
label k
Boltzmann constant.
Triangle with additional region number.
void size(const label)
Override size to be inconsistent with allocated storage.
vector point
Point is a vector.
Foam::argList args(argc, argv)
cachedRandom rndGen(label(0), -1)
word name(const complex &)
Return a string representation of a complex.