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 = " 111 foamyHexMeshDict.subDict(
"surfaceConformation")
114 Info<<
"Set up geometry in = " 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();
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 = " 202 Info<<
"Constructed iso surface in = " 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 = " 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 = " 336 Info<<
"writing surfMesh:\n " 337 << smesh.searchableSurface::objectPath() <<
nl <<
endl;
338 smesh.searchableSurface::write();
340 Info<<
"Written surface in = " const fvPatchList & patches
graph_traits< Graph >::vertex_descriptor Vertex
#define forAll(list, i)
Loop across all elements in list.
A class for handling file names.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void size(const label)
Override size to be inconsistent with allocated storage.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
label k
Boltzmann constant.
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...
A surface geometry formed of discrete facets, e.g. triangles and/or quadrilaterals, defined in a file using formats such as Wavefront OBJ, or stereolithography STL.
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))
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
static const word & geometryDir()
Return the geometry directory name.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
Container for searchableSurfaces.
Triangle with additional region number.
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross product operators.
word name(const complex &)
Return a string representation of a complex.
const point & max() const
Maximum point defining the bounding box.
vector point
Point is a vector.
Input from memory buffer stream.
vector span() const
The bounding box span (from minimum to maximum)
The geometricSurfacePatch is like patchIdentifier but for surfaces. Holds type, name and index...
Standard boundBox + extra functionality for use in octree.
Starts timing CPU usage and return elapsed time from start.
const point & min() const
Minimum point defining the bounding box.
static void addNote(const string &)
Add extra notes for the usage information.
Triangulated surface description with patch information.
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const stringList & args() const
Return arguments.