MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / calcSamples

Function calcSamples

src/sampling/sampledSet/patchSeed/patchSeedSet.C:48–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47
48void Foam::patchSeedSet::calcSamples
49(
50 DynamicList<point>& samplingPts,
51 DynamicList<label>& samplingCells,
52 DynamicList<label>& samplingFaces,
53 DynamicList<label>& samplingSegments,
54 DynamicList<scalar>& samplingCurveDist
55)
56{
57 if (debug)
58 {
59 Info<< "patchSeedSet : sampling on patches :" << endl;
60 }
61
62 // Construct search tree for all patch faces.
63 label sz = 0;
64 forAllConstIter(labelHashSet, patchSet_, iter)
65 {
66 const polyPatch& pp = mesh().boundaryMesh()[iter.key()];
67
68 sz += pp.size();
69
70 if (debug)
71 {
72 Info<< " " << pp.name() << " size " << pp.size() << endl;
73 }
74 }
75
76 labelList patchFaces(sz);
77 sz = 0;
78 forAllConstIter(labelHashSet, patchSet_, iter)
79 {
80 const polyPatch& pp = mesh().boundaryMesh()[iter.key()];
81 forAll(pp, i)
82 {
83 patchFaces[sz++] = pp.start()+i;
84 }
85 }
86
87
88 label totalSize = returnReduce(sz, sumOp<label>());
89
90
91 // Shuffle and truncate if in random mode
92 if (maxPoints_ < totalSize)
93 {
94 // Check what fraction of maxPoints_ I need to generate locally.
95 label myMaxPoints = label(scalar(sz)/totalSize*maxPoints_);
96
97 rndGenPtr_.reset(new Random(123456));
98 Random& rndGen = rndGenPtr_();
99
100 labelList subset = identity(sz);
101 for (label iter = 0; iter < 4; iter++)
102 {
103 forAll(subset, i)
104 {
105 label j = rndGen.integer(0, subset.size()-1);

Callers 1

genSamplesFunction · 0.70

Calls 15

meshFunction · 0.85
returnReduceFunction · 0.85
labelFunction · 0.85
scalarFunction · 0.85
SwapFunction · 0.85
toGlobalMethod · 0.80
forAllConstIterFunction · 0.50
forAllFunction · 0.50
RandomClass · 0.50
mappedPatchBaseClass · 0.50
keyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected