50void Foam::patchSeedSet::calcSamples
52 DynamicList<point>& samplingPts,
53 DynamicList<label>& samplingCells,
54 DynamicList<label>& samplingFaces,
55 DynamicList<label>& samplingSegments,
56 DynamicList<scalar>& samplingCurveDist
63 for (
const label patchi : patchSet_)
69 DebugInfo <<
" " << pp.name() <<
" size " << pp.size() <<
endl;
74 for (
const label patchi : patchSet_)
79 patchFaces[sz++] = pp.start()+i;
86 rndGenPtr_.reset(
new Random(0));
88 Random&
rndGen = *rndGenPtr_;
91 if (selectedLocations_.
size())
93 DynamicList<label> newPatchFaces(patchFaces.size());
101 List<mappedPatchBase::nearInfo> nearest(selectedLocations_.
size());
105 IndirectList<face>(
mesh().
faces(), patchFaces),
111 treeBoundBox(pp.points(), pp.meshPoints()).extend
117 patchBb.min() -= point::uniform(ROOTVSMALL);
118 patchBb.max() += point::uniform(ROOTVSMALL);
120 indexedOctree<treeDataFace> boundaryTree
136 const scalar globalDistSqr
150 forAll(selectedLocations_, sampleI)
155 nearInfo = boundaryTree.findNearest
163 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
164 nearest[sampleI].second().second() =
169 point fc(pp[nearInfo.index()].centre(pp.points()));
170 nearInfo.setPoint(fc);
172 nearest[sampleI].second().second() =
184 mappedPatchBase::nearestEqOp()
191 if (nearest[sampleI].
first().hit())
193 label procI = nearest[sampleI].second().second();
194 label index = nearest[sampleI].first().index();
198 newPatchFaces.append(pp.addressing()[index]);
206 Pout<<
"Found " << newPatchFaces.size()
207 <<
" out of " << selectedLocations_.
size()
208 <<
" on local processor" <<
endl;
211 patchFaces.transfer(newPatchFaces);
216 label totalSize =
returnReduce(patchFaces.size(), sumOp<label>());
218 if (maxPoints_ < totalSize)
222 label(scalar(patchFaces.size())/totalSize*maxPoints_);
225 for (label iter = 0; iter < 4; ++iter)
234 subset.setSize(myMaxPoints);
240 Pout<<
"In random mode : selected " <<
subset.size()
241 <<
" faces out of " << patchFaces.size() <<
endl;
249 globalIndex globalSampleNumbers(patchFaces.size());
251 samplingPts.setCapacity(patchFaces.size());
252 samplingCells.setCapacity(patchFaces.size());
253 samplingFaces.setCapacity(patchFaces.size());
254 samplingSegments.setCapacity(patchFaces.size());
255 samplingCurveDist.setCapacity(patchFaces.size());
262 label facei = patchFaces[i];
280 info.hitPoint() + 1
e-1*(cc-info.hitPoint())
285 samplingPts.append(info.rawPoint());
287 samplingCells.append(celli);
288 samplingFaces.append(facei);
289 samplingSegments.append(0);
290 samplingCurveDist.append(globalSampleNumbers.toGlobal(i));
295void Foam::patchSeedSet::genSamples()
298 DynamicList<point> samplingPts;
299 DynamicList<label> samplingCells;
300 DynamicList<label> samplingFaces;
301 DynamicList<label> samplingSegments;
302 DynamicList<scalar> samplingCurveDist;
313 samplingPts.shrink();
314 samplingCells.shrink();
315 samplingFaces.shrink();
316 samplingSegments.shrink();
317 samplingCurveDist.shrink();
322 std::move(samplingPts),
323 std::move(samplingCells),
324 std::move(samplingFaces),
325 std::move(samplingSegments),
326 std::move(samplingCurveDist)
351 maxPoints_(
dict.get<label>(
"maxPoints")),
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Minimal example by using system/controlDict.functions:
void append(const T &val)
Append an element at the end of the list.
static void listCombineAllGather(const List< commsStruct > &comms, List< T > &values, const CombineOp &cop, const int tag, const label comm)
After completion all processors have the same data.
Type position(const Type &start, const Type &end)
Return a sample on the interval [start,end].
T & first()
Return the first element of the list.
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
The number of elements in the list.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
const pointField & points() const noexcept
Return the points.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
static pointIndexHit facePoint(const polyMesh &, const label facei, const polyMesh::cellDecomposition)
Get a point on the face given a face decomposition method:
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Initialises points on or just off patch.
Mesh consisting of general polyhedral cells.
virtual const labelList & faceOwner() const
Return face owner.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const vectorField & cellCentres() const
int myProcNo() const noexcept
Return processor number.
Holds list of sampling points which is filled at construction time. Various implementations of this b...
const labelList & faces() const noexcept
const polyMesh & mesh() const noexcept
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define DebugInfo
Report an information message using Foam::Info.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< T > subset(const BoolListType &select, const UList< T > &input, const bool invert=false)
Extract elements of the input list when select is true.
vector point
Point is a vector.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field.
UIndirectList< label > labelUIndList
UIndirectList of labels.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
#define forAll(list, i)
Loop across all elements in list.