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 auto& cellTree = meshSearcher.cellTree();
163 const auto& treeData = cellTree.shapes();
167 const point& pt = fc[facei];
168 auto& near = nearest[facei];
174 const label objectIndex = treeData.objectIndex(info.index());
176 near.first() = info.point().distSqr(pt);
177 near.second() = globalCells.toGlobal(objectIndex);
181 else if (sampleSource_ == samplingSource::insideCells)
185 const auto& cellTree = meshSearcher.cellTree();
186 const auto& treeData = cellTree.shapes();
190 const point& pt = fc[facei];
191 auto& near = nearest[facei];
193 if (cellTree.bb().contains(pt))
195 const label index = cellTree.findInside(pt);
199 const label objectIndex = treeData.objectIndex(index);
202 near.second() = globalCells.toGlobal(objectIndex);
212 const auto& bndTree = meshSearcher.nonCoupledBoundaryTree();
213 const auto& treeData = bndTree.shapes();
217 const point& pt = fc[facei];
218 auto& near = nearest[facei];
224 const label objectIndex = treeData.objectIndex(info.index());
226 near.first() = info.point().distSqr(pt);
227 near.second() = globalCells.toGlobal(objectIndex);
238 labelList cellOrFaceLabels(fc.size(), -1);
240 bitSet facesToSubset(fc.size());
244 const auto& near = nearest[facei];
246 const label index = near.second();
253 else if (globalCells.isLocal(index))
255 facesToSubset.set(facei);
258 cellOrFaceLabels[facei] =
260 (near.first() < maxDistanceSqr_)
261 ? globalCells.toLocal(index)
270 Pout<<
"Local out of faces:" << cellOrFaceLabels.size()
271 <<
" keeping:" << facesToSubset.count() <<
endl;
281 s = surface_.subsetMesh(facesToSubset, pointMap,
faceMap);
300 sampleElements_.resize(pointMap.size(), -1);
303 labelList pointToFace(std::move(pointMap));
307 const face&
f =
s[facei];
309 for (
const label labi :
f)
311 pointToFace[labi] = facei;
321 forAll(samplePoints_, pointi)
324 const point pt = samplePoints_[pointi];
326 const label celli = cellOrFaceLabels[pointToFace[pointi]];
328 sampleElements_[pointi] = celli;
333 && !
mesh().pointInCell(pt, celli, meshSearcher.decompMode())
339 scalar minDistSqr = VGREAT;
341 for (
const label facei :
mesh().
cells()[celli])
352 if (info.distance() < minDistSqr)
354 minDistSqr = info.distance();
355 samplePoints_[pointi] = info.point();
361 else if (sampleSource_ == samplingSource::insideCells)
366 forAll(samplePoints_, pointi)
368 const label celli = cellOrFaceLabels[pointToFace[pointi]];
370 sampleElements_[pointi] = celli;
379 forAll(samplePoints_, pointi)
381 const point& pt = samplePoints_[pointi];
383 const label facei = cellOrFaceLabels[pointToFace[pointi]];
385 sampleElements_[pointi] = facei;
389 samplePoints_[pointi] =
411 sampleElements_.
transfer(cellOrFaceLabels);
412 samplePoints_.clear();
419 OFstream str(
mesh().time().
path()/
"surfaceToMesh.obj");
420 Info<<
"Dumping correspondence from local surface (points or faces)" 421 <<
" to mesh (cells or faces) to " << str.name() <<
endl;
433 forAll(samplePoints_, pointi)
441 label elemi = sampleElements_[pointi];
444 str <<
"l " << vertI-2 <<
' ' << vertI-1 <<
' ' << vertI <<
nl;
450 forAll(sampleElements_, triI)
455 label elemi = sampleElements_[triI];
458 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
463 needsUpdate_ =
false;
474 const word& surfaceName,
475 const samplingSource sampleSource
480 surfaceName_(surfaceName),
486 sampleSource_(sampleSource),
492 maxDistanceSqr_(
Foam::
sqr(GREAT)),
519 sampleSource_(samplingSourceNames_.
get(
"source",
dict)),
521 keepIds_(
dict.getOrDefault(
"keepIds", true)),
525 maxDistanceSqr_(
Foam::
sqr(GREAT)),
526 defaultValues_(
dict.subOrEmptyDict(
"defaultValue"))
528 if (
dict.readIfPresent(
"maxDistance", maxDistanceSqr_))
540 maxDistanceSqr_ =
Foam::sqr(maxDistanceSqr_);
543 wordRes includePatches;
544 dict.readIfPresent(
"patches", includePatches);
545 includePatches.uniq();
550 if (!includePatches.empty())
552 Info<<
"Subsetting surface " << surfaceName_
569 bitSet includeMap(surface_.
size());
571 for (
const label zonei : zoneIndices)
573 const surfZone& zn = zones[zonei];
574 includeMap.set(zn.range());
577 if (includeMap.none())
580 <<
"Patch selection results in an empty surface" 581 <<
" - ignoring" <<
nl;
583 else if (!includeMap.all())
590 <<
"Bad surface subset (empty)" 591 <<
" - skip and hope for the best" <<
nl;
623 sampleElements_.clear();
624 samplePoints_.clear();
639 treeBoundBox bb(surface_.points(), surface_.meshPoints());
647 bb.
grow(0.5*bb.span());
656 <<
"Surface " << surfaceName_
657 <<
" does not overlap bounding box of mesh " <<
mesh().
bounds()
660 bb.reset(
mesh().bounds().centre());
661 bb.grow(1
e-6*
mesh().bounds().span());
667 return update(meshSearcher);
681 return update(meshSearcher);
690 return sampleOnFaces(sampler);
699 return sampleOnFaces(sampler);
708 return sampleOnFaces(sampler);
717 return sampleOnFaces(sampler);
726 return sampleOnFaces(sampler);
735 return sampleOnPoints(interpolator);
744 return sampleOnPoints(interpolator);
752 return sampleOnPoints(interpolator);
761 return sampleOnPoints(interpolator);
770 return sampleOnPoints(interpolator);
776 os <<
"meshedSurface: " <<
name() <<
" :" 777 <<
" surface:" << surfaceName_;
781 os <<
" faces:" << faces().size()
783 <<
" zoneids:" << zoneIds().size();
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search...
void size(const label n)
Older name for setAddressableSize.
bool interpolate() const noexcept
Same as isPointData()
void resize(const label len)
Adjust allocated size of list.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
An abstract class for surfaces with sampling.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
UIndirectList< label > labelUIndList
UIndirectList of labels.
virtual void clear()
Clear all storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
const cellList & cells() const
Ignore writing from objectRegistry::writeObject()
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual bool expire()
Mark the surface as needing an update.
Macros for easy insertion into run-time selection tables.
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
#define forAll(list, i)
Loop across all elements in list.
static IOobject selectReadIO(const word &name, const Time &runTime)
samplingSource
Types of sampling regions.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
virtual void clearGeom() const
Additional cleanup when clearing the geometry.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
MeshedSurface< face > meshedSurface
virtual void print(Ostream &os, int level=0) const
Print information.
labelList findMatching(const StringListType &input, const wordRes::filter &pred, AccessOp aop=identityOp())
Return ids for items with matching names.
MeshedSurface subsetMesh(const UList< bool > &include, labelList &pointMap, labelList &faceMap) const
Return a new surface subsetted on the selected faces.
virtual const faceList & faces() const
Return raw faces.
sampledMeshedSurface(const word &name, const polyMesh &mesh, const word &surfaceName, const samplingSource sampleSource)
Construct from components.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
const vectorField & cellCentres() const
An Ostream is an abstract base class for all output systems (streams, files, token lists...
const word & constant() const noexcept
Return constant name.
virtual bool needsUpdate() const
Does the surface need an update?
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
defineTypeNameAndDebug(combustionModel, 0)
const vectorField & faceCentres() const
label size() const
The surface size is the number of faces.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
virtual bool update()
Update the surface as required.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
List< surfZone > surfZoneList
List of surfZone.
void transfer(pointField &pointLst, List< Face > &faceLst)
Transfer the components.
Standard boundBox with extra functionality for use in octree.
messageStream Info
Information stream (stdout output on master, null elsewhere)
const boundBox & bounds() const noexcept
Return mesh bounding box.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
A class for managing temporary objects.
const surfZoneList & surfZones() const
Const access to the surface zones.
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))
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.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Do not request registration (bool: false)
PointHit< point > pointHit
A PointHit with a 3D point.
bool isPointData() const noexcept
Using interpolation to surface points.
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
After completion all processors have the same data.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.