49 void Foam::patchSeedSet::calcPatchSamples
51 const label nAvailable,
52 const label nPatchPoints,
53 DynamicList<point>& samplingPts,
54 DynamicList<label>& samplingCells,
55 DynamicList<label>& samplingFaces,
56 DynamicList<label>& samplingSegments,
57 DynamicList<scalar>& samplingCurveDist
65 Random&
rndGen = *rndGenPtr_;
67 globalIndex globalSampleNumbers(nAvailable);
68 label nGlobalPatchPoints =
returnReduce(nPatchPoints, sumOp<label>());
74 const bool perturb =
true;
76 for (
const label patchi : patchSet_)
79 triangulatedPatch tp(
pp, perturb);
81 const label np = nAvailable*
pp.size()/scalar(nGlobalPatchPoints);
82 for (label i = 0; i < np; ++i)
84 tp.randomLocalPoint(
rndGen, pt, facei, celli);
86 samplingPts.append(pt);
87 samplingCells.append(celli);
88 samplingFaces.append(
pp.start() + facei);
89 samplingSegments.append(0);
90 samplingCurveDist.append(globalSampleNumbers.toGlobal(i));
96 void Foam::patchSeedSet::calcSelectedLocations
98 const label nAvailable,
99 const label nPatchPoints,
100 DynamicList<point>& samplingPts,
101 DynamicList<label>& samplingCells,
102 DynamicList<label>& samplingFaces,
103 DynamicList<label>& samplingSegments,
104 DynamicList<scalar>& samplingCurveDist
112 Random&
rndGen = *rndGenPtr_;
116 for (
const label patchi : patchSet_)
121 patchFaces[sz++] =
pp.start() + localFacei;
126 DynamicList<label> newPatchFaces(patchFaces.size());
134 List<mappedPatchBase::nearInfo> nearest(nAvailable);
138 IndirectList<face>(
mesh().faces(), patchFaces),
145 .extend(
rndGen, 1
e-4, ROOTVSMALL)
148 indexedOctree<treeDataFace> boundaryTree
150 treeDataFace(
mesh(), patchFaces),
160 const scalar globalDistSqr
166 for (label sampleI = 0; sampleI < nAvailable; ++sampleI)
168 const auto& treeData = boundaryTree.shapes();
169 const point& sample = selectedLocations_[sampleI];
172 auto& distSqrProc = nearest[sampleI].second();
174 nearInfo = boundaryTree.findNearest
187 nearInfo.setPoint(treeData.centre(nearInfo.index()));
189 distSqrProc.first() = sample.distSqr(nearInfo.point());
204 if (nearest[sampleI].first().hit())
206 label procI = nearest[sampleI].second().second();
207 label index = nearest[sampleI].first().index();
211 newPatchFaces.append(
pp.addressing()[index]);
219 Pout<<
"Found " << newPatchFaces.size()
220 <<
" out of " << nAvailable
221 <<
" on local processor" <<
endl;
224 patchFaces.transfer(newPatchFaces);
229 const label totalSize =
returnReduce(patchFaces.size(), sumOp<label>());
231 if (totalSize > nAvailable)
234 label myMaxPoints = scalar(patchFaces.size())/totalSize*nAvailable;
237 for (label iter = 0; iter < 4; ++iter)
247 subset.setSize(myMaxPoints);
253 Pout<<
"In random mode : selected " <<
subset.size()
254 <<
" faces out of " << patchFaces.size() <<
endl;
262 globalIndex globalSampleNumbers(patchFaces.size());
264 samplingPts.setCapacity(patchFaces.size());
265 samplingCells.setCapacity(patchFaces.size());
266 samplingFaces.setCapacity(patchFaces.size());
267 samplingSegments.setCapacity(patchFaces.size());
268 samplingCurveDist.setCapacity(patchFaces.size());
275 const label facei = patchFaces[i];
293 info.point() + 1
e-1*(cc-info.point())
298 samplingPts.append(info.point());
300 samplingCells.append(celli);
301 samplingFaces.append(facei);
302 samplingSegments.append(0);
303 samplingCurveDist.append(globalSampleNumbers.toGlobal(i));
308 void Foam::patchSeedSet::genSamples()
311 DynamicList<point> samplingPts;
312 DynamicList<label> samplingCells;
313 DynamicList<label> samplingFaces;
314 DynamicList<label> samplingSegments;
315 DynamicList<scalar> samplingCurveDist;
326 samplingPts.shrink();
327 samplingCells.shrink();
328 samplingFaces.shrink();
329 samplingSegments.shrink();
330 samplingCurveDist.shrink();
335 std::move(samplingPts),
336 std::move(samplingCells),
337 std::move(samplingFaces),
338 std::move(samplingSegments),
339 std::move(samplingCurveDist)
349 void Foam::patchSeedSet::calcSamples
351 DynamicList<point>& samplingPts,
352 DynamicList<label>& samplingCells,
353 DynamicList<label>& samplingFaces,
354 DynamicList<label>& samplingSegments,
355 DynamicList<scalar>& samplingCurveDist
362 rndGenPtr_.reset(
new Random(0));
365 label nPatchPoints = 0;
366 for (
const label patchi : patchSet_)
369 nPatchPoints +=
pp.size();
374 label nAvailable =
min(maxPoints_, selectedLocations_.size());
376 calcSelectedLocations
387 nAvailable = maxPoints_ - nAvailable;
417 maxPoints_(
dict.
get<label>(
"maxPoints")),
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...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
void append(const T &val)
Append an element at the end of the list.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
UIndirectList< label > labelUIndList
UIndirectList of labels.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
Ostream & endl(Ostream &os)
Add newline and flush stream.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field...
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Macros for easy insertion into run-time selection tables.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
patchSeedSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Construct from dictionary.
#define forAll(list, i)
Loop across all elements in list.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
const dimensionedScalar e
Elementary charge.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Holds list of sampling points which is filled at construction time. Various implementations of this b...
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
virtual const labelList & faceOwner() const
Return face owner.
A List of wordRe with additional matching capabilities.
const Field< point_type > & points() const noexcept
Return reference to global points.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
const vectorField & cellCentres() const
#define DebugInfo
Report an information message using Foam::Info.
const polyMesh & mesh() const noexcept
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
static pointIndexHit facePoint(const polyMesh &, const label facei, const polyMesh::cellDecomposition)
Get a point on the face given a face decomposition method:
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.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
Type position(const Type &start, const Type &end)
Return a sample on the interval [start,end].
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Combines List elements. After completion all processors have the same data.