Loading...
Searching...
No Matches
searchableBoxFeatures.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-2016 OpenFOAM Foundation
9 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
31#include "treeBoundBox.H"
32
33// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34
35namespace Foam
36{
37
40(
43 dict
44);
45
46}
47
48
49// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50
51Foam::searchableBoxFeatures::searchableBoxFeatures
52(
53 const searchableSurface& surface,
54 const dictionary& dict
55)
56:
57 searchableSurfaceFeatures(surface, dict),
58 mode_
59 (
60 extendedFeatureEdgeMesh::sideVolumeTypeNames_
61 [
62 dict.getOrDefault<word>("meshableSide", "inside")
63 ]
64 )
65{
66 Info<< indent
67 << " Meshable region = "
68 << extendedFeatureEdgeMesh::sideVolumeTypeNames_[mode_]
69 << endl;
70}
71
72
73// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
74
76{}
77
78
79// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
80
81Foam::autoPtr<Foam::extendedFeatureEdgeMesh>
83{
85
87 vectorField faceNormals(std::move(faceNormalsList));
88
89 vectorField edgeDirections(12);
90 labelListList normalDirections(12, labelList(2, Zero));
91 labelListList edgeNormals(12, labelList(2, Zero));
92
93 edgeNormals[0][0] = 2; edgeNormals[0][1] = 4;
94 edgeNormals[1][0] = 1; edgeNormals[1][1] = 4;
95 edgeNormals[2][0] = 3; edgeNormals[2][1] = 4;
96 edgeNormals[3][0] = 0; edgeNormals[3][1] = 4;
97 edgeNormals[4][0] = 2; edgeNormals[4][1] = 5;
98 edgeNormals[5][0] = 1; edgeNormals[5][1] = 5;
99 edgeNormals[6][0] = 3; edgeNormals[6][1] = 5;
100 edgeNormals[7][0] = 0; edgeNormals[7][1] = 5;
101 edgeNormals[8][0] = 0; edgeNormals[8][1] = 2;
102 edgeNormals[9][0] = 2; edgeNormals[9][1] = 1;
103 edgeNormals[10][0] = 1; edgeNormals[10][1] = 3;
104 edgeNormals[11][0] = 3; edgeNormals[11][1] = 0;
105
106 tmp<pointField> surfacePointsTmp(surface().points());
107 pointField& surfacePoints = surfacePointsTmp.ref();
108
109 forAll(edgeDirections, eI)
110 {
111 edgeDirections[eI] =
112 surfacePoints[treeBoundBox::edges[eI].end()]
113 - surfacePoints[treeBoundBox::edges[eI].start()];
114
115 for (label j = 0; j < 2; ++j)
116 {
117 const vector cross =
118 (faceNormals[edgeNormals[eI][j]] ^ edgeDirections[eI]);
119 const vector fC0tofE0 =
120 0.5*(max(surfacePoints + min(surfacePoints)))
121 - surfacePoints[treeBoundBox::edges[eI].start()];
122
123 normalDirections[eI][j] =
124 (
125 (
126 (cross/(mag(cross) + VSMALL))
127 & (fC0tofE0/(mag(fC0tofE0)+ VSMALL))
128 )
129 > 0.0
130 ? 1
131 : -1
132 );
133 }
134 }
135
136 labelListList featurePointNormals(8, labelList(3, Zero));
137 labelListList featurePointEdges(8, labelList(3, Zero));
138
139 forAll(featurePointNormals, pI)
140 {
141 labelList& ftPtEdges = featurePointEdges[pI];
142
143 label edgeI = 0;
145 {
146 const edge& e = treeBoundBox::edges[eI];
147
148 if (e.start() == pI)
149 {
150 ftPtEdges[edgeI++] = eI;
151 }
152 else if (e.end() == pI)
153 {
154 ftPtEdges[edgeI++] = eI;
155 }
156 }
157
158 labelList& ftPtNormals = featurePointNormals[pI];
159
160 ftPtNormals[0] = edgeNormals[ftPtEdges[0]][0];
161 ftPtNormals[1] = edgeNormals[ftPtEdges[0]][1];
162 ftPtNormals[2] = edgeNormals[ftPtEdges[1]][0];
163 }
164
165 labelList regionEdges;
166
167 features.reset
168 (
170 (
172 (
173 surface().name() + ".extendedFeatureEdgeMesh",
174 surface().instance(),
175 "extendedFeatureEdgeMesh",
176 surface().db(),
179 ),
180 surface().points(),
182 8, 8, 8,
183 12, 12, 12, 12,
184 faceNormals,
186 edgeDirections,
187 normalDirections,
188 edgeNormals,
189 featurePointNormals,
190 featurePointEdges,
191 regionEdges
192 )
193 );
194
195 return features;
196}
197
198
199// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
@ NO_READ
Nothing to be read.
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
iterator end() noexcept
Return an iterator to end traversing the UList.
Definition UListI.H:454
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static const FixedList< vector, 6 > faceNormals
The unit normal per face.
Definition boundBox.H:136
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Definition edge.H:62
virtual ~searchableBoxFeatures()
Destructor.
virtual autoPtr< extendedFeatureEdgeMesh > features() const
Return an extendedFeatureEdgeMesh containing the features.
Decorator that returns the features of a searchable surface.
A class for managing temporary objects.
Definition tmp.H:75
static const edgeList edges
Edge to point addressing, using octant corner points.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
auto & name
const pointField & points
const wordList surface
Standard surface field types (scalar, vector, tensor, etc).
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
Ostream & indent(Ostream &os)
Indent stream.
Definition Ostream.H:481
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:26
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
dictionary dict
volScalarField & e
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299