44#include "MarchingCubes.h"
53int main(
int argc,
char *argv[])
57 "Re-sample surfaces used in foamyHexMesh operation"
59 argList::addArgument(
"(nx ny nz)",
"The resampling interval");
60 argList::addArgument(
"output",
"The output triSurface/ file");
62 argList::noFunctionObjects();
70 Info<<
"Reading surfaces as specified in the foamyHexMeshDict and"
71 <<
" writing re-sampled " <<
n <<
" to " << exportName
83 IOobject::MUST_READ_IF_MODIFIED,
93 "cvSearchableSurfaces",
100 foamyHexMeshDict.subDict(
"geometry"),
101 foamyHexMeshDict.getOrDefault(
"singleRegionName",
true)
104 Info<<
"Geometry read in = "
105 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
115 foamyHexMeshDict.subDict(
"surfaceConformation")
118 Info<<
"Set up geometry in = "
119 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
127 bb.
min() -= smallVec;
128 bb.
max() += smallVec;
131 Info<<
"Meshing to bounding box " << bb <<
nl <<
endl;
141 MarchingCubes mc(span.x(), span.y(), span.z() ) ;
142 mc.set_resolution(
n.x(),
n.y(),
n.z());
151 for(
int k = 0 ;
k < mc.size_z() ;
k++ )
153 pt.
z() = bb.
min().
z() +
k*d.z();
154 for(
int j = 0 ; j < mc.size_y() ; j++ )
156 pt.
y() = bb.
min().
y() + j*d.y();
157 for(
int i = 0 ; i < mc.size_x() ; i++ )
159 pt.
x() = bb.
min().
x() + i*d.x();
165 Info<<
"Generated " <<
points.size() <<
" sampling points in = "
166 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
171 const labelList& surfaces = geometryToConformTo.surfaces();
175 searchableSurfacesQueries::signedDistance
181 searchableSurface::OUTSIDE,
189 for(
int k = 0 ;
k < mc.size_z() ;
k++ )
191 for(
int j = 0 ; j < mc.size_y() ; j++ )
193 for(
int i = 0 ; i < mc.size_x() ; i++ )
195 mc.set_data(
float(signedDist[pointi++]), i, j,
k);
200 Info<<
"Determined signed distance in = "
201 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
206 Info<<
"Constructed iso surface in = "
207 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
217 Triangle* triangles = mc.triangles();
238 bb.
min().
x() + v.x*span.x()/mc.size_x(),
239 bb.
min().
y() + v.y*span.y()/mc.size_y(),
240 bb.
min().
z() + v.z*span.z()/mc.size_z()
250 const wordList& regions = geometry[surfaces[i]].regions();
251 regionOffsets[i] = nRegions;
252 nRegions += regions.
size();
260 const wordList& regions = geometry[surfaces[i]].regions();
266 geometry[surfaces[i]].
name() +
"_" + regions[regionI],
276 Info<<
"Extracted triSurface in = "
277 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
284 geometryToConformTo.findSurfaceNearest
303 if (hitSurfaces[triI] == surfI)
305 surfInfo.append(hitInfo[triI]);
306 surfIndices.append(triI);
312 geometry[surfaces[surfI]].getRegion(surfInfo, region);
316 label triI = surfIndices[i];
317 s[triI].region() = regionOffsets[surfI]+region[i];
322 Info<<
"Re-patched surface in = "
323 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
334 IOobject::AUTO_WRITE,
340 Info<<
"writing surfMesh:\n "
341 << smesh.searchableSurface::objectPath() <<
nl <<
endl;
342 smesh.searchableSurface::write();
344 Info<<
"Written surface in = "
345 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
CGAL::Triangle_3< K > Triangle
graph_traits< Graph >::vertex_descriptor Vertex
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.
const Cmpt & z() const
Access to the vector z component.
const Cmpt & y() const
Access to the vector y component.
const Cmpt & x() const
Access to the vector x component.
T get(const label index) const
Get a value from the argument at index.
const point & min() const
Minimum describing the bounding box.
const point & max() const
Maximum 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.
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))
dimensionedSymmTensor sqr(const dimensionedVector &dv)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
pointField vertices(const blockVertexList &bvl)
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.