Go to the documentation of this file.
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;
84 if (!rndGenPtr_.valid())
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
120 indexedOctree<treeDataFace> boundaryTree
136 const scalar globalDistSqr
150 forAll(selectedLocations_, sampleI)
152 const point& sample = selectedLocations_[sampleI];
163 nearest[sampleI].second().first() =
Foam::sqr(GREAT);
164 nearest[sampleI].second().second() =
171 nearest[sampleI].second().first() =
magSqr(fc-sample);
172 nearest[sampleI].second().second() =
189 if (nearest[sampleI].first().hit())
191 label procI = nearest[sampleI].second().second();
192 label index = nearest[sampleI].first().index();
196 newPatchFaces.append(pp.addressing()[index]);
204 Pout<<
"Found " << newPatchFaces.size()
205 <<
" out of " << selectedLocations_.size()
206 <<
" on local processor" <<
endl;
209 patchFaces.transfer(newPatchFaces);
214 label totalSize =
returnReduce(patchFaces.size(), sumOp<label>());
216 if (maxPoints_ < totalSize)
220 label(scalar(patchFaces.size())/totalSize*maxPoints_);
223 for (label iter = 0; iter < 4; ++iter)
232 subset.setSize(myMaxPoints);
239 Pout<<
"In random mode : selected " << patchFaces.size()
240 <<
" faces out of " << patchFaces.size() <<
endl;
246 globalIndex globalSampleNumbers(patchFaces.size());
248 samplingPts.setCapacity(patchFaces.size());
249 samplingCells.setCapacity(patchFaces.size());
250 samplingFaces.setCapacity(patchFaces.size());
251 samplingSegments.setCapacity(patchFaces.size());
252 samplingCurveDist.setCapacity(patchFaces.size());
259 label facei = patchFaces[i];
277 info.hitPoint() + 1
e-1*(cc-info.hitPoint())
282 samplingPts.append(info.rawPoint());
284 samplingCells.append(celli);
285 samplingFaces.append(facei);
286 samplingSegments.append(0);
287 samplingCurveDist.append(globalSampleNumbers.toGlobal(i));
292 void Foam::patchSeedSet::genSamples()
295 DynamicList<point> samplingPts;
296 DynamicList<label> samplingCells;
297 DynamicList<label> samplingFaces;
298 DynamicList<label> samplingSegments;
299 DynamicList<scalar> samplingCurveDist;
310 samplingPts.shrink();
311 samplingCells.shrink();
312 samplingFaces.shrink();
313 samplingSegments.shrink();
314 samplingCurveDist.shrink();
319 std::move(samplingPts),
320 std::move(samplingCells),
321 std::move(samplingFaces),
322 std::move(samplingSegments),
323 std::move(samplingCurveDist)
348 maxPoints_(
dict.
get<label>(
"maxPoints")),
int debug
Static debugging option.
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Holds list of sampling points which is filled at construction time. Various implementations of this b...
List< label > labelList
A List of labels.
A class for handling words, derived from Foam::string.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
static Vector< Cmpt > uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
List< T > subset(const BoolListType &select, const UList< T > &input, const bool invert=false)
Extract elements of the input list when select is true.
patchSeedSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Construct from dictionary.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
void Swap(DynamicList< T, SizeMin1 > &a, DynamicList< T, SizeMin2 > &b)
Mesh consisting of general polyhedral cells.
#define forAll(list, i)
Loop across all elements in list.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Tuple2< scalar, label > nearInfo
Private class for finding nearest.
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
virtual const labelList & faceOwner() const
Return face owner.
const labelList & faces() const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Macros for easy insertion into run-time selection tables.
static int myProcNo(const label communicator=0)
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.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
const vectorField & cellCentres() const
const polyMesh & mesh() const
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
#define DebugInfo
Report an information message using Foam::Info.
const dimensionedScalar e
Elementary charge.
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
A List of wordRe with additional matching capabilities.
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool useGroups=true) const
Return the set of patch IDs corresponding to the given names.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
vector point
Point is a vector.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
static pointIndexHit facePoint(const polyMesh &, const label facei, const polyMesh::cellDecomposition)
Get a point on the face given a face decomposition method:
defineTypeNameAndDebug(combustionModel, 0)
UIndirectList< label > labelUIndList
UIndirectList of labels.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.