Go to the documentation of this file.
44 Foam::sampledMeshedSurface::samplingSourceNames_
47 { samplingSource::insideCells,
"insideCells" },
48 { samplingSource::boundaryFaces,
"boundaryFaces" },
100 void Foam::sampledMeshedSurface::setZoneMap()
106 const auto& zones =
s.surfZones();
111 if (zoneIds_.empty() || zones.size() <= 1)
122 const label len =
min(zones[zonei].
size(), zoneIds_.size() - beg);
125 SubList<label>(zoneIds_, len, beg) = zonei;
132 const label len = (zoneIds_.size() - beg);
136 SubList<label>(zoneIds_, len, beg) =
max(0, zones.size()-1);
148 globalIndex globalCells(onBoundary() ?
mesh().nFaces() :
mesh().nCells());
152 const pointField& fc = surface_.faceCentres();
155 typedef Tuple2<scalar, label> nearInfo;
162 const indexedOctree<treeDataCell>& cellTree = meshSearcher.cellTree();
166 const point& pt = fc[facei];
167 auto& near = nearest[facei];
173 near.first() =
magSqr(info.hitPoint()-pt);
174 near.second() = globalCells.toGlobal(info.index());
178 else if (sampleSource_ == samplingSource::insideCells)
182 const auto& cellTree = meshSearcher.cellTree();
186 const point& pt = fc[facei];
187 auto& near = nearest[facei];
189 if (cellTree.bb().contains(pt))
191 const label index = cellTree.findInside(pt);
195 near.second() = globalCells.toGlobal(index);
205 const auto& bndTree = meshSearcher.nonCoupledBoundaryTree();
209 const point& pt = fc[facei];
210 auto& near = nearest[facei];
216 near.first() =
magSqr(info.hitPoint()-pt);
220 bndTree.shapes().faceLabels()[info.index()]
233 labelList cellOrFaceLabels(fc.size(), -1);
235 bitSet facesToSubset(fc.size());
239 const auto& near = nearest[facei];
241 const label index = near.second();
248 else if (globalCells.isLocal(index))
250 facesToSubset.set(facei);
253 cellOrFaceLabels[facei] =
255 (near.first() < maxDistanceSqr_)
256 ? globalCells.toLocal(index)
265 Pout<<
"Local out of faces:" << cellOrFaceLabels.size()
266 <<
" keeping:" << facesToSubset.count() <<
endl;
276 s = surface_.subsetMesh(facesToSubset, pointMap,
faceMap);
295 sampleElements_.resize(pointMap.size(), -1);
298 labelList pointToFace(std::move(pointMap));
302 const face&
f =
s[facei];
304 for (
const label labi :
f)
306 pointToFace[labi] = facei;
316 forAll(samplePoints_, pointi)
319 const point pt = samplePoints_[pointi];
321 const label celli = cellOrFaceLabels[pointToFace[pointi]];
323 sampleElements_[pointi] = celli;
328 && !
mesh().pointInCell(pt, celli, meshSearcher.decompMode())
334 scalar minDistSqr = VGREAT;
336 for (
const label facei :
mesh().
cells()[celli])
347 if (info.distance() < minDistSqr)
349 minDistSqr = info.distance();
350 samplePoints_[pointi] = info.rawPoint();
356 else if (sampleSource_ == samplingSource::insideCells)
361 forAll(samplePoints_, pointi)
363 const label celli = cellOrFaceLabels[pointToFace[pointi]];
365 sampleElements_[pointi] = celli;
374 forAll(samplePoints_, pointi)
376 const point& pt = samplePoints_[pointi];
378 const label facei = cellOrFaceLabels[pointToFace[pointi]];
380 sampleElements_[pointi] = facei;
384 samplePoints_[pointi] =
406 sampleElements_.
transfer(cellOrFaceLabels);
407 samplePoints_.clear();
414 OFstream str(
mesh().time().
path()/
"surfaceToMesh.obj");
415 Info<<
"Dumping correspondence from local surface (points or faces)"
416 <<
" to mesh (cells or faces) to " << str.name() <<
endl;
428 forAll(samplePoints_, pointi)
436 label elemi = sampleElements_[pointi];
439 str <<
"l " << vertI-2 <<
' ' << vertI-1 <<
' ' << vertI <<
nl;
445 forAll(sampleElements_, triI)
450 label elemi = sampleElements_[triI];
453 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
458 needsUpdate_ =
false;
469 const word& surfaceName,
475 surfaceName_(surfaceName),
481 sampleSource_(sampleSource),
503 meshedSurface::findFile
514 sampleSource_(samplingSourceNames_.get(
"source",
dict)),
535 maxDistanceSqr_ =
Foam::sqr(maxDistanceSqr_);
540 includePatches.
uniq();
545 if (!includePatches.empty())
547 Info<<
"Subsetting surface " << surfaceName_
564 bitSet includeMap(surface_.size());
566 for (
const label zonei : zoneIndices)
572 if (includeMap.none())
575 <<
"Patch selection results in an empty surface"
576 <<
" - ignoring" <<
nl;
578 else if (!includeMap.all())
585 <<
"Bad surface subset (empty)"
586 <<
" - skip and hope for the best" <<
nl;
591 surface_.transfer(subSurf);
618 sampleElements_.clear();
619 samplePoints_.clear();
634 treeBoundBox bb(surface_.points(), surface_.meshPoints());
645 <<
"Surface " << surfaceName_
646 <<
" does not overlap bounding box of mesh " <<
mesh().
bounds()
650 const vector span(bb.span());
652 bb.
min() += (0.5-1
e-6)*span;
653 bb.
max() -= (0.5-1
e-6)*span;
658 const vector span(bb.span());
659 bb.
min() -= 0.5*span;
660 bb.
max() += 0.5*span;
668 return update(meshSearcher);
682 return update(meshSearcher);
691 return sampleOnFaces(sampler);
700 return sampleOnFaces(sampler);
709 return sampleOnFaces(sampler);
718 return sampleOnFaces(sampler);
727 return sampleOnFaces(sampler);
736 return sampleOnPoints(interpolator);
745 return sampleOnPoints(interpolator);
753 return sampleOnPoints(interpolator);
762 return sampleOnPoints(interpolator);
771 return sampleOnPoints(interpolator);
777 os <<
"meshedSurface: " <<
name() <<
" :"
778 <<
" surface:" << surfaceName_;
782 os <<
" faces:" << faces().size()
783 <<
" points:" <<
points().size()
784 <<
" zoneids:" << zoneIds().size();
int debug
Static debugging option.
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
virtual void print(Ostream &os, int level=0) const
Print information.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual bool needsUpdate() const
Does the surface need an update?
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
A class for handling words, derived from Foam::string.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
sampledMeshedSurface(const word &name, const polyMesh &mesh, const word &surfaceName, const samplingSource sampleSource)
Construct from components.
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))
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void resize(const label len)
Adjust allocated size of list.
A class for managing temporary objects.
static IOobject selectReadIO(const word &name, const Time &runTime)
labelRange range() const
The start/size range of this zone.
Standard boundBox with extra functionality for use in octree.
const cellList & cells() const
Ostream & endl(Ostream &os)
Add newline and flush stream.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
virtual void clear()
Clear all storage.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
virtual bool update()
Update the surface as required.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Mesh consisting of general polyhedral cells.
#define forAll(list, i)
Loop across all elements in list.
Field< vector > vectorField
Specialisation of Field<T> for vector.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
bool intersect(const boundBox &bb)
Intersection (union) with the second box.
bool interpolate() const noexcept
Same as isPointData()
messageStream Info
Information stream (stdout output on master, null elsewhere)
void transfer(List< T > &list)
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
Extract name (as a word) from an object, typically using its name() method.
An abstract class for surfaces with sampling.
labelList findMatching(const StringListType &input, const wordRes &allow, const wordRes &deny=wordRes(), AccessOp aop=noOp())
Return ids for items with matching names.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
PointHit< point > pointHit
A PointIndexHit for 3D points.
OBJstream os(runTime.globalPath()/outputName)
Macros for easy insertion into run-time selection tables.
bool isPointData() const noexcept
Using interpolation to surface points.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
const boundBox & bounds() const
Return mesh bounding box.
const vectorField & cellCentres() const
virtual const faceList & faces() const
Return raw faces.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
MeshedSurface< face > meshedSurface
A surface zone on a MeshedSurface.
const vectorField & faceCentres() const
const dimensionedScalar e
Elementary charge.
A List of wordRe with additional matching capabilities.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
virtual void clearGeom() const
Additional cleanup when clearing the geometry.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
const Time & time() const
Return the top-level database.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual bool expire()
Mark the surface as needing an update.
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
vector point
Point is a vector.
static wordRes uniq(const UList< wordRe > &input)
Return a wordRes with duplicate entries filtered out.
const word & constant() const
Return constant name.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
label size() const
The surface size is the number of faces.
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
samplingSource
Types of sampling regions.
UIndirectList< label > labelUIndList
UIndirectList of labels.