BUG: cloudSet.C: force early construction of tetBasePtIs to avoid demand-driven comms
[OpenFOAM-2.0.x.git] / src / sampling / sampledSet / cloud / cloudSet.C
blob223f449ad6e9b81618caca7011f5cb8e69317bb6
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "cloudSet.H"
27 #include "sampledSet.H"
28 #include "meshSearch.H"
29 #include "DynamicList.H"
30 #include "polyMesh.H"
31 #include "addToRunTimeSelectionTable.H"
32 #include "word.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 namespace Foam
38     defineTypeNameAndDebug(cloudSet, 0);
39     addToRunTimeSelectionTable(sampledSet, cloudSet, word);
43 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
45 void Foam::cloudSet::calcSamples
47     DynamicList<point>& samplingPts,
48     DynamicList<label>& samplingCells,
49     DynamicList<label>& samplingFaces,
50     DynamicList<label>& samplingSegments,
51     DynamicList<scalar>& samplingCurveDist
52 ) const
54     // Force calculation of face-diagonals
55     (void)mesh().tetBasePtIs();
57     const meshSearch& queryMesh = searchEngine();
59     forAll(sampleCoords_, sampleI)
60     {
61         label cellI = queryMesh.findCell(sampleCoords_[sampleI]);
63         if (cellI != -1)
64         {
65             samplingPts.append(sampleCoords_[sampleI]);
66             samplingCells.append(cellI);
67             samplingFaces.append(-1);
68             samplingSegments.append(0);
69             samplingCurveDist.append(1.0 * sampleI);
70         }
71     }
75 void Foam::cloudSet::genSamples()
77     // Storage for sample points
78     DynamicList<point> samplingPts;
79     DynamicList<label> samplingCells;
80     DynamicList<label> samplingFaces;
81     DynamicList<label> samplingSegments;
82     DynamicList<scalar> samplingCurveDist;
84     calcSamples
85     (
86         samplingPts,
87         samplingCells,
88         samplingFaces,
89         samplingSegments,
90         samplingCurveDist
91     );
93     samplingPts.shrink();
94     samplingCells.shrink();
95     samplingFaces.shrink();
96     samplingSegments.shrink();
97     samplingCurveDist.shrink();
99     setSamples
100     (
101         samplingPts,
102         samplingCells,
103         samplingFaces,
104         samplingSegments,
105         samplingCurveDist
106     );
110 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
112 Foam::cloudSet::cloudSet
114     const word& name,
115     const polyMesh& mesh,
116     meshSearch& searchEngine,
117     const word& axis,
118     const List<point>& sampleCoords
121     sampledSet(name, mesh, searchEngine, axis),
122     sampleCoords_(sampleCoords)
124     genSamples();
126     if (debug)
127     {
128         write(Info);
129     }
133 Foam::cloudSet::cloudSet
135     const word& name,
136     const polyMesh& mesh,
137     meshSearch& searchEngine,
138     const dictionary& dict
141     sampledSet(name, mesh, searchEngine, dict),
142     sampleCoords_(dict.lookup("points"))
144     genSamples();
146     if (debug)
147     {
148         write(Info);
149     }
153 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
155 Foam::cloudSet::~cloudSet()
159 // ************************************************************************* //