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,
470 const samplingSource sampleSource
475 surfaceName_(surfaceName),
481 sampleSource_(sampleSource),
487 maxDistanceSqr_(
Foam::
sqr(GREAT)),
514 sampleSource_(samplingSourceNames_.
get(
"source",
dict)),
516 keepIds_(
dict.getOrDefault(
"keepIds", true)),
520 maxDistanceSqr_(
Foam::
sqr(GREAT)),
521 defaultValues_(
dict.subOrEmptyDict(
"defaultValue"))
523 if (
dict.readIfPresent(
"maxDistance", maxDistanceSqr_))
535 maxDistanceSqr_ =
Foam::sqr(maxDistanceSqr_);
538 wordRes includePatches;
539 dict.readIfPresent(
"patches", includePatches);
540 includePatches.uniq();
545 if (!includePatches.empty())
547 Info<<
"Subsetting surface " << surfaceName_
564 bitSet includeMap(surface_.
size());
566 for (
const label zonei : zoneIndices)
568 const surfZone& zn = zones[zonei];
569 includeMap.set(zn.range());
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;
618 sampleElements_.clear();
619 samplePoints_.clear();
634 treeBoundBox bb(surface_.points(), surface_.meshPoints());
637 const bool intersect = bb.intersect(
mesh().bounds());
645 <<
"Surface " << surfaceName_
646 <<
" does not overlap bounding box of mesh " <<
mesh().
bounds()
649 bb = treeBoundBox(
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();
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
const surfZoneList & surfZones() const
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
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)
const point & max() const
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)
A class for managing temporary objects.
static IOobject selectReadIO(const word &name, const Time &runTime)
void inflate(const scalar s)
Standard boundBox with extra functionality for use in octree.
void set(const bitSet &bitset)
Ostream & endl(Ostream &os)
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
label min(const labelHashSet &set, label minValue=labelMax)
Mesh consisting of general polyhedral cells.
Field< vector > vectorField
Specialisation of Field<T> for vector.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
static const dictionary null
bool intersect(const boundBox &bb)
bool interpolate() const noexcept
void transfer(pointField &pointLst, List< Face > &faceLst)
void transfer(List< T > &list)
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
An abstract class for surfaces with sampling.
labelList findMatching(const StringListType &input, const wordRes &allow, const wordRes &deny=wordRes(), AccessOp aop=noOp())
const point & min() const
label max(const labelHashSet &set, label maxValue=labelMin)
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
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Vector< scalar > vector
A scalar version of the templated Vector.
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
const vectorField & cellCentres() const
virtual const faceList & faces() const
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
MeshedSurface< face > meshedSurface
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A surface zone on a MeshedSurface.
const vectorField & faceCentres() const
const dimensionedScalar e
A List of wordRe with additional matching capabilities.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
virtual void clearGeom() const
List< surfZone > surfZoneList
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
word name(const expressions::valueTypeCode typeCode)
const Time & time() const
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
vector point
Point is a vector.
static wordRes uniq(const UList< wordRe > &input)
const word & constant() const
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
MeshedSurface subsetMesh(const UList< bool > &include, labelList &pointMap, labelList &faceMap) const
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
UIndirectList< label > labelUIndList
UIndirectList of labels.