searchablePlateFeatures.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2013-2015 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
30 #include "treeBoundBox.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 defineTypeNameAndDebug(searchablePlateFeatures, 0);
39 (
40  searchableSurfaceFeatures,
41  searchablePlateFeatures,
42  dict
43 );
44 
46 const Foam::label edgesArray[4][2] =
47 {
48  {0, 1}, // 0
49  {0, 3},
50  {2, 1}, // 2
51  {2, 3}
52 };
54 
55 const edgeList searchablePlateFeatures::edges(calcEdges(edgesArray));
56 
57 }
58 
59 
60 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
61 
62 Foam::edgeList Foam::searchablePlateFeatures::calcEdges
63 (
64  const label edgesArray[4][2]
65 )
66 {
67  edgeList edges(4);
68  forAll(edges, edgeI)
69  {
70  edges[edgeI][0] = edgesArray[edgeI][0];
71  edges[edgeI][1] = edgesArray[edgeI][1];
72  }
73  return edges;
74 }
75 
76 
77 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
78 
79 Foam::searchablePlateFeatures::searchablePlateFeatures
80 (
81  const searchableSurface& surface,
82  const dictionary& dict
83 )
84 :
86  mode_
87  (
88  extendedFeatureEdgeMesh::sideVolumeTypeNames_
89  [
90  dict.lookupOrDefault<word>("meshableSide", "inside")
91  ]
92  )
93 {
94  Info<< indent
95  << " Meshable region = "
97  << endl;
98 }
99 
100 
101 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
102 
104 {}
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
111 {
113 
116 
117  vectorField edgeDirections(4);
118  labelListList normalDirections(4);
119 
120  labelListList edgeNormals(4);
121  forAll(edgeNormals, eI)
122  {
123  edgeNormals[eI].setSize(2, 0);
124  }
125  edgeNormals[0][0] = 0; edgeNormals[0][1] = 0;
126  edgeNormals[1][0] = 0; edgeNormals[1][1] = 0;
127  edgeNormals[2][0] = 0; edgeNormals[2][1] = 0;
128  edgeNormals[3][0] = 0; edgeNormals[3][1] = 0;
129 
130  forAll(edgeDirections, eI)
131  {
132  edgeDirections[eI] =
133  surface().points()()[edges[eI].end()]
134  - surface().points()()[edges[eI].start()];
135 
136  normalDirections[eI] = labelList(2, Zero);
137  for (label j = 0; j < 2; ++j)
138  {
139  const vector cross =
140  (faceNormals[edgeNormals[eI][j]] ^ edgeDirections[eI]);
141  const vector fC0tofE0 =
142  0.5*(max(surface().points()() + min(surface().points()())))
143  - surface().points()()[edges[eI].start()];
144 
145  normalDirections[eI][j] =
146  (
147  (
148  (cross/(mag(cross) + VSMALL))
149  & (fC0tofE0/(mag(fC0tofE0)+ VSMALL))
150  )
151  > 0.0
152  ? 1
153  : -1
154  );
155  }
156  }
157 
158  labelListList featurePointNormals(4);
159  labelListList featurePointEdges(4);
160  forAll(featurePointNormals, pI)
161  {
162  labelList& ftPtEdges = featurePointEdges[pI];
163  ftPtEdges.setSize(2, 0);
164 
165  label edgeI = 0;
166  forAll(edges, eI)
167  {
168  const edge& e = edges[eI];
169 
170  if (e.start() == pI)
171  {
172  ftPtEdges[edgeI++] = eI;
173  }
174  else if (e.end() == pI)
175  {
176  ftPtEdges[edgeI++] = eI;
177  }
178  }
179 
180  labelList& ftPtNormals = featurePointNormals[pI];
181  ftPtNormals.setSize(1, 0);
182 
183  ftPtNormals[0] = edgeNormals[ftPtEdges[0]][0];
184  }
185 
186  labelList regionEdges;
187 
188  features.reset
189  (
191  (
192  IOobject
193  (
194  surface().name() + ".extendedFeatureEdgeMesh",
195  surface().instance(),
196  "extendedFeatureEdgeMesh",
197  surface().db(),
200  ),
201  surface().points(),
202  edges,
203  4, 4, 4,
204  0, 0, 4, 4, // 4 flat edges
205  faceNormals,
207  edgeDirections,
208  normalDirections,
209  edgeNormals,
210  featurePointNormals,
211  featurePointEdges,
212  regionEdges
213  )
214  );
215 
216  return features;
217 }
218 
219 
220 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:74
Foam::autoPtr::reset
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:158
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:129
Foam::edgeList
List< edge > edgeList
A List of edges.
Definition: edgeList.H:63
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::searchableSurface::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
searchablePlateFeatures.H
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:63
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::dictionary::lookupOrDefault
T lookupOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionary.H:1241
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::extendedEdgeMesh::sideVolumeTypeNames_
static const Enum< sideVolumeType > sideVolumeTypeNames_
Definition: extendedEdgeMesh.H:126
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:62
faceNormals
surfaceVectorField faceNormals(mesh.Sf()/mesh.magSf())
Foam::Field< vector >
treeBoundBox.H
Foam::searchablePlateFeatures::~searchablePlateFeatures
virtual ~searchablePlateFeatures()
Destructor.
Definition: searchablePlateFeatures.C:104
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::searchableSurface::points
virtual tmp< pointField > points() const =0
Get the points that define the surface.
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:69
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:115
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:307
Foam::searchablePlateFeatures::edges
static const edgeList edges
Edge to point addressing.
Definition: searchablePlateFeatures.H:83
Foam::searchablePlateFeatures::features
virtual autoPtr< extendedFeatureEdgeMesh > features() const
Return an extendedFeatureEdgeMesh containing the features.
Definition: searchablePlateFeatures.C:111
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
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:102
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::start
label ListType::const_reference const label start
Definition: ListOps.H:408
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::extendedFeatureEdgeMesh
extendedEdgeMesh + IO.
Definition: extendedFeatureEdgeMesh.H:54
Foam::searchableSurfaceFeatures
Decorator that returns the features of a searchable surface.
Definition: searchableSurfaceFeatures.H:53
Foam::List::setSize
void setSize(const label newSize)
Alias for resize(const label)
Definition: ListI.H:146
Foam::IOobject::NO_READ
Definition: IOobject.H:123
Foam::cross
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:943
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)