44 #include "MarchingCubes.h" 53 int main(
int argc,
char *argv[])
57 "Re-sample surfaces used in foamyHexMesh operation" 70 Info<<
"Reading surfaces as specified in the foamyHexMeshDict and" 71 <<
" writing re-sampled " <<
n <<
" to " << exportName
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 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();
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;
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();
262 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;
graph_traits< Graph >::vertex_descriptor Vertex
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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
std::vector< Triangle > triangles
CGAL::Triangle_3< K > Triangle
label k
Boltzmann constant.
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...
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.
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 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 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...
void grow(const scalar delta)
Expand box by adjusting min/max by specified amount in each dimension.
Do not request registration (bool: false)
Starts timing CPU usage and return elapsed time from start.