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

Function findElements

src/sampling/probes/probes.C:51–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
50
51void Foam::probes::findElements(const fvMesh& mesh)
52{
53 if (debug)
54 {
55 Info<< "probes: resetting sample locations" << endl;
56 }
57
58 elementList_.clear();
59 elementList_.setSize(size());
60
61 faceList_.clear();
62 faceList_.setSize(size());
63
64 forAll(*this, probei)
65 {
66 const vector& location = operator[](probei);
67
68 const label celli = mesh.findCell(location);
69
70 elementList_[probei] = celli;
71
72 if (celli != -1)
73 {
74 const labelList& cellFaces = mesh.cells()[celli];
75 const vector& cellCentre = mesh.cellCentres()[celli];
76 scalar minDistance = GREAT;
77 label minFaceID = -1;
78 forAll(cellFaces, i)
79 {
80 label facei = cellFaces[i];
81 vector dist = mesh.faceCentres()[facei] - cellCentre;
82 if (mag(dist) < minDistance)
83 {
84 minDistance = mag(dist);
85 minFaceID = facei;
86 }
87 }
88 faceList_[probei] = minFaceID;
89 }
90 else
91 {
92 faceList_[probei] = -1;
93 }
94
95 if (debug && (elementList_[probei] != -1 || faceList_[probei] != -1))
96 {
97 Pout<< "probes : found point " << location
98 << " in cell " << elementList_[probei]
99 << " and face " << faceList_[probei] << endl;
100 }
101 }
102
103
104 // Check if all probes have been found.
105 forAll(elementList_, probei)
106 {
107 const vector& location = operator[](probei);
108 label celli = elementList_[probei];

Callers 3

readFunction · 0.70
updateMeshFunction · 0.70
movePointsFunction · 0.70

Calls 6

sizeFunction · 0.85
forAllFunction · 0.50
magClass · 0.50
reduceFunction · 0.50
clearMethod · 0.45
setSizeMethod · 0.45

Tested by

no test coverage detected