searchablePlateFeatures.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2018 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 
28 #include "treeBoundBox.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 defineTypeNameAndDebug(searchablePlateFeatures, 0);
37 (
38  searchableSurfaceFeatures,
39  searchablePlateFeatures,
40  dict
41 );
42 
44 const Foam::label edgesArray[4][2] =
45 {
46  {0, 1}, // 0
47  {0, 3},
48  {2, 1}, // 2
49  {2, 3}
50 };
52 
53 const edgeList searchablePlateFeatures::edges(calcEdges(edgesArray));
54 
55 }
56 
57 
58 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
59 
60 Foam::edgeList Foam::searchablePlateFeatures::calcEdges
61 (
62  const label edgesArray[4][2]
63 )
64 {
65  edgeList edges(4);
66  forAll(edges, edgeI)
67  {
68  edges[edgeI][0] = edgesArray[edgeI][0];
69  edges[edgeI][1] = edgesArray[edgeI][1];
70  }
71  return edges;
72 }
73 
74 
75 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
76 
78 (
79  const searchableSurface& surface,
80  const dictionary& dict
81 )
82 :
83  searchableSurfaceFeatures(surface, dict),
84  mode_
85  (
86  extendedFeatureEdgeMesh::sideVolumeTypeNames_
87  [
88  dict.lookupOrDefault<word>("meshableSide", "inside")
89  ]
90  )
91 {
92  Info<< indent
93  << " Meshable region = "
95  << endl;
96 }
97 
98 
99 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
100 
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
109 {
111 
112  vectorField faceNormals(1);
113  surface().getNormal(List<pointIndexHit>(1), faceNormals);
114 
115  vectorField edgeDirections(4);
116  labelListList normalDirections(4);
117 
118  labelListList edgeNormals(4);
119  forAll(edgeNormals, eI)
120  {
121  edgeNormals[eI].setSize(2, 0);
122  }
123  edgeNormals[0][0] = 0; edgeNormals[0][1] = 0;
124  edgeNormals[1][0] = 0; edgeNormals[1][1] = 0;
125  edgeNormals[2][0] = 0; edgeNormals[2][1] = 0;
126  edgeNormals[3][0] = 0; edgeNormals[3][1] = 0;
127 
128  forAll(edgeDirections, eI)
129  {
130  edgeDirections[eI] =
131  surface().points()()[edges[eI].end()]
132  - surface().points()()[edges[eI].start()];
133 
134  normalDirections[eI] = labelList(2, label(0));
135  for (label j = 0; j < 2; ++j)
136  {
137  const vector cross =
138  (faceNormals[edgeNormals[eI][j]] ^ edgeDirections[eI]);
139  const vector fC0tofE0 =
140  0.5*(max(surface().points()() + min(surface().points()())))
141  - surface().points()()[edges[eI].start()];
142 
143  normalDirections[eI][j] =
144  (
145  (
146  (cross/(mag(cross) + vSmall))
147  & (fC0tofE0/(mag(fC0tofE0)+ vSmall))
148  )
149  > 0.0
150  ? 1
151  : -1
152  );
153  }
154  }
155 
156  labelListList featurePointNormals(4);
157  labelListList featurePointEdges(4);
158  forAll(featurePointNormals, pI)
159  {
160  labelList& ftPtEdges = featurePointEdges[pI];
161  ftPtEdges.setSize(2, 0);
162 
163  label edgeI = 0;
164  forAll(edges, eI)
165  {
166  const edge& e = edges[eI];
167 
168  if (e.start() == pI)
169  {
170  ftPtEdges[edgeI++] = eI;
171  }
172  else if (e.end() == pI)
173  {
174  ftPtEdges[edgeI++] = eI;
175  }
176  }
177 
178  labelList& ftPtNormals = featurePointNormals[pI];
179  ftPtNormals.setSize(1, 0);
180 
181  ftPtNormals[0] = edgeNormals[ftPtEdges[0]][0];
182  }
183 
184  labelList regionEdges;
185 
186  features.set
187  (
189  (
190  IOobject
191  (
192  surface().name() + ".extendedFeatureEdgeMesh",
193  surface().instance(),
194  "extendedFeatureEdgeMesh",
195  surface().db(),
198  ),
199  surface().points(),
200  edges,
201  4, 4, 4,
202  0, 0, 4, 4, // 4 flat edges
203  faceNormals,
205  edgeDirections,
206  normalDirections,
207  edgeNormals,
208  featurePointNormals,
209  featurePointEdges,
210  regionEdges
211  )
212  );
213 
214  return features;
215 }
216 
217 
218 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
const searchableSurface & surface() const
Return a reference to the searchable surface.
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
Decorator that returns the features of a searchable surface.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
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
static const Foam::NamedEnum< sideVolumeType, 4 > sideVolumeTypeNames_
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
virtual ~searchablePlateFeatures()
Destructor.
Macros for easy insertion into run-time selection tables.
searchablePlateFeatures(const searchableSurface &surface, const dictionary &dict)
Construct from searchable surface and dictionary.
const pointField & points
List< edge > edgeList
Definition: edgeList.H:38
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
A class for handling words, derived from string.
Definition: word.H:59
static const edgeList edges
Edge to point addressing.
List< label > labelList
A List of labels.
Definition: labelList.H:56
virtual autoPtr< extendedFeatureEdgeMesh > features() const
Return an extendedFeatureEdgeMesh containing the features.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
virtual tmp< pointField > points() const =0
Get the points that define the surface.
defineTypeNameAndDebug(combustionModel, 0)
void set(T *)
Set pointer to that given.
Definition: autoPtrI.H:99
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
void setSize(const label)
Reset size of List.
Definition: List.C:281
label end() const
Return end vertex label.
Definition: edgeI.H:92
messageStream Info
dimensioned< scalar > mag(const dimensioned< Type > &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
const doubleScalar e
Elementary charge.
Definition: doubleScalar.H:105
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
label start() const
Return start vertex label.
Definition: edgeI.H:81
Namespace for OpenFOAM.