midPointAndFaceSet.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "midPointAndFaceSet.H"
27 #include "polyMesh.H"
29 
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(midPointAndFaceSet, 0);
36  addToRunTimeSelectionTable(sampledSet, midPointAndFaceSet, word);
37 }
38 
39 
40 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
41 
42 // Rework faceOnlySet samples.
43 // Take two consecutive samples
45 {
46  // Generate midpoints and add to face points
47 
48  List<point> newSamplePoints(3*size());
49  labelList newSampleCells(3*size());
50  labelList newSampleFaces(3*size());
51  labelList newSampleSegments(3*size());
52  scalarList newSampleCurveDist(3*size());
53 
54  label newSampleI = 0;
55 
56  label sampleI = 0;
57 
58  while(true && size()>0)
59  {
60  // sampleI is start of segment
61 
62  // Add sampleI
63  newSamplePoints[newSampleI] = operator[](sampleI);
64  newSampleCells[newSampleI] = cells_[sampleI];
65  newSampleFaces[newSampleI] = faces_[sampleI];
66  newSampleSegments[newSampleI] = segments_[sampleI];
67  newSampleCurveDist[newSampleI] = curveDist_[sampleI];
68  newSampleI++;
69 
70  while
71  (
72  (sampleI < size() - 1)
73  && (segments_[sampleI] == segments_[sampleI+1])
74  )
75  {
76  // Add mid point
77  const point mid = 0.5*(operator[](sampleI) + operator[](sampleI+1));
78 
79  label cell1 = getCell(faces_[sampleI], mid);
80  label cell2 = getCell(faces_[sampleI+1], mid);
81 
82  if (cell1 != cell2)
83  {
85  << " newSampleI:" << newSampleI
86  << " pts[sampleI]:" << operator[](sampleI)
87  << " face[sampleI]:" << faces_[sampleI]
88  << " pts[sampleI+1]:" << operator[](sampleI+1)
89  << " face[sampleI+1]:" << faces_[sampleI+1]
90  << " cell1:" << cell1
91  << " cell2:" << cell2
92  << abort(FatalError);
93  }
94 
95  newSamplePoints[newSampleI] = mid;
96  newSampleCells[newSampleI] = cell1;
97  newSampleFaces[newSampleI] = -1;
98  newSampleSegments[newSampleI] = segments_[sampleI];
99  newSampleCurveDist[newSampleI] =
100  mag(newSamplePoints[newSampleI] - start());
101 
102  newSampleI++;
103 
104  // Add sampleI+1
105  newSamplePoints[newSampleI] = operator[](sampleI+1);
106  newSampleCells[newSampleI] = cells_[sampleI+1];
107  newSampleFaces[newSampleI] = faces_[sampleI+1];
108  newSampleSegments[newSampleI] = segments_[sampleI+1];
109  newSampleCurveDist[newSampleI] =
110  mag(newSamplePoints[newSampleI] - start());
111 
112  newSampleI++;
113 
114  sampleI++;
115  }
116 
117  if (sampleI == size() - 1)
118  {
119  break;
120  }
121  sampleI++;
122  }
123 
124  newSamplePoints.setSize(newSampleI);
125  newSampleCells.setSize(newSampleI);
126  newSampleFaces.setSize(newSampleI);
127  newSampleSegments.setSize(newSampleI);
128  newSampleCurveDist.setSize(newSampleI);
129 
130  setSamples
131  (
132  newSamplePoints,
133  newSampleCells,
134  newSampleFaces,
135  newSampleSegments,
136  newSampleCurveDist
137  );
138 }
139 
140 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
141 
143 (
144  const word& name,
145  const polyMesh& mesh,
146  const meshSearch& searchEngine,
147  const word& axis,
148  const point& start,
149  const point& end
150 )
151 :
152  faceOnlySet(name, mesh, searchEngine, axis, start, end)
153 {
154  genSamples();
155 
156  if (debug)
157  {
158  write(Info);
159  }
160 }
161 
162 
164 (
165  const word& name,
166  const polyMesh& mesh,
167  const meshSearch& searchEngine,
168  const dictionary& dict
169 )
170 :
171  faceOnlySet(name, mesh, searchEngine, dict)
172 {
173  genSamples();
174 
175  if (debug)
176  {
177  write(Info);
178  }
179 }
180 
181 
182 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
183 
185 {}
186 
187 
188 // ************************************************************************* //
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::sampledSet::getCell
label getCell(const label faceI, const point &sample) const
Returns cell using face and containing sample.
Definition: sampledSet.C:53
Foam::meshSearch
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Definition: meshSearch.H:57
Foam::midPointAndFaceSet::~midPointAndFaceSet
virtual ~midPointAndFaceSet()
Destructor.
Definition: midPointAndFaceSet.C:184
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::faceOnlySet::start
const point & start() const
Definition: faceOnlySet.H:127
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Info
messageStream Info
Foam::faceOnlySet
Definition: faceOnlySet.H:49
Foam::sampledSet::segments_
labelList segments_
Segment numbers.
Definition: sampledSet.H:80
Foam::midPointAndFaceSet::midPointAndFaceSet
midPointAndFaceSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const word &axis, const point &start, const point &end)
Construct from components.
Definition: midPointAndFaceSet.C:143
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::sampledSet::cells_
labelList cells_
Cell numbers.
Definition: sampledSet.H:83
Foam::coordSet::curveDist_
scalarList curveDist_
Cumulative distance "distance" write specifier.
Definition: coordSet.H:84
Foam::List::setSize
void setSize(const label)
Reset size of List.
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::midPointAndFaceSet::genSamples
void genSamples()
Definition: midPointAndFaceSet.C:44
Foam::sampledSet::setSamples
void setSamples(const List< point > &samplingPts, const labelList &samplingCells, const labelList &samplingFaces, const labelList &samplingSegments, const scalarList &samplingCurveDist)
Sets sample data.
Definition: sampledSet.C:351
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
midPointAndFaceSet.H
Foam::sampledSet::faces_
labelList faces_
Face numbers (-1 if not known)
Definition: sampledSet.H:86
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
write
Tcoeff write()
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47