50 void 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())
112 .extend(
rndGen, 1
e-4, ROOTVSMALL)
115 indexedOctree<treeDataFace> boundaryTree
117 treeDataFace(
mesh(), patchFaces),
127 const scalar globalDistSqr
133 forAll(selectedLocations_, sampleI)
135 const auto& treeData = boundaryTree.shapes();
136 const point& sample = selectedLocations_[sampleI];
139 auto& distSqrProc = nearest[sampleI].second();
141 nearInfo = boundaryTree.findNearest
154 nearInfo.setPoint(treeData.centre(nearInfo.index()));
156 distSqrProc.first() = sample.distSqr(nearInfo.point());
171 if (nearest[sampleI].
first().hit())
173 label procI = nearest[sampleI].second().second();
174 label index = nearest[sampleI].first().index();
178 newPatchFaces.append(pp.addressing()[index]);
186 Pout<<
"Found " << newPatchFaces.size()
187 <<
" out of " << selectedLocations_.
size()
188 <<
" on local processor" <<
endl;
191 patchFaces.transfer(newPatchFaces);
196 label totalSize =
returnReduce(patchFaces.size(), sumOp<label>());
198 if (maxPoints_ < totalSize)
202 label(scalar(patchFaces.size())/totalSize*maxPoints_);
205 for (label iter = 0; iter < 4; ++iter)
214 subset.setSize(myMaxPoints);
220 Pout<<
"In random mode : selected " <<
subset.size()
221 <<
" faces out of " << patchFaces.size() <<
endl;
229 globalIndex globalSampleNumbers(patchFaces.size());
231 samplingPts.setCapacity(patchFaces.size());
232 samplingCells.setCapacity(patchFaces.size());
233 samplingFaces.setCapacity(patchFaces.size());
234 samplingSegments.setCapacity(patchFaces.size());
235 samplingCurveDist.setCapacity(patchFaces.size());
242 label facei = patchFaces[i];
260 info.point() + 1
e-1*(cc-info.point())
265 samplingPts.append(info.point());
267 samplingCells.append(celli);
268 samplingFaces.append(facei);
269 samplingSegments.append(0);
270 samplingCurveDist.append(globalSampleNumbers.toGlobal(i));
275 void Foam::patchSeedSet::genSamples()
278 DynamicList<point> samplingPts;
279 DynamicList<label> samplingCells;
280 DynamicList<label> samplingFaces;
281 DynamicList<label> samplingSegments;
282 DynamicList<scalar> samplingCurveDist;
293 samplingPts.shrink();
294 samplingCells.shrink();
295 samplingFaces.shrink();
296 samplingSegments.shrink();
297 samplingCurveDist.shrink();
302 std::move(samplingPts),
303 std::move(samplingCells),
304 std::move(samplingFaces),
305 std::move(samplingSegments),
306 std::move(samplingCurveDist)
321 const polyMesh&
mesh,
322 const meshSearch& searchEngine,
323 const dictionary&
dict 329 mesh.boundaryMesh().patchSet(
dict.
get<wordRes>(
"patches"))
331 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.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
void size(const label n)
Older name for setAddressableSize.
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)
T & first()
Access first element of the list, position [0].
Ostream & endl(Ostream &os)
Add newline and flush stream.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
const labelList & faces() const noexcept
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
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.
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)
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
label size() const noexcept
The number of elements in the list.
virtual const labelList & faceOwner() const
Return face owner.
const pointField & points() const noexcept
Return the points.
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:
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
List< T > subset(const BoolListType &select, const UList< T > &input, const bool invert=false)
Extract elements of the input list when select is true.
UIndirectList< label > labelUIndList
UIndirectList of labels.
vector point
Point is a vector.
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< label > labelList
A List of labels.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
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.