binaryNode.H
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) 2016-2022 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 Class
25  Foam::binaryNode
26 
27 Description
28  Node of the binary tree
29 
30 SourceFile
31  binaryNode.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef binaryNode_H
36 #define binaryNode_H
37 
38 #include "chemPointISAT.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class binaryNode Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 class binaryNode
50 {
51 
52 public:
53 
54  //- Element on the left
56 
57  //- Element on the right
59 
60  //- Node which follows on the left
62 
63  //- Node which follows on the right
65 
66  //- Parent node
68 
70 
71  scalar a_;
72 
73  //- Compute vector v:
74  // Let E be the ellipsoid which covers the region of accuracy of
75  // the left leaf (previously defined). E is described by
76  // E={phi| ||L^T.(phi-phi0)|| <= 1}, (see chemPoint for more details).
77  // let E' be the transformation of E in a space where E' is a hypersphere
78  // centered at the origin, in this space y=L^T.(phi-phi0) and then
79  // E'={y| ||y||<=1}
80  // let u be the unit vector joining the center of E' and the newly added
81  // composition point in the transformed space
82  // (y2=L^T.(phiq-phi0)),u = y2/||y2|
83  // Then the hyperplane separating the two points is defined as the
84  // perpendicular bisector of the segment linking 0 to y2
85  // H' = {y| u^T.(y-yh) = 0},
86  // where yh = y2/2.
87  // In the original composition space, the hyperplane H is defined by
88  // H = {y| v^T(phi-phih) = 0},
89  // where phih = phi0 + L^-T.yh = (phi0 + phiq) / 2 and v is
90  // L.L^T (phiq-phi0)
91  // v = -------------------- .
92  // ||L.L^T (phiq-phi0)||
93  //
94  // Note : v is not normalised in this implementation since it is used
95  // on both side of an equality to know if one should go on the
96  // left or the right in the binary tree
97  // Parameter:
98  // elementLeft : chemPoint of the left element
99  // elementRight: chemPoint of the right element
100  // v : empty scalar field to store v
101  // Returnq: void (v is stored in the empty scalarField)
102  void calcV
103  (
104  const chemPointISAT& elementLeft,
105  const chemPointISAT& elementRight,
106  scalarField& v
107  );
108 
109  //- Compute a the product v^T.phih, with phih = (phi0 + phiq)/2.
110  // When travelling in the binary tree,
111  // to know in which part of the composition space the query point 'phi'
112  // belongs to, v^T.phi is performed. If the result is "> a" then it belongs
113  // to the right part (where phiq is), otherwise it belongs to the left
114  // part (where phi0 is).
115  inline scalar calcA
116  (
117  const chemPointISAT& elementLeft,
118  const chemPointISAT& elementRight
119  );
120 
121  // Constructors
122 
123  //- Construct null
124  binaryNode();
125 
126  //- Construct from components
127  binaryNode
128  (
129  chemPointISAT* elementLeft,
130  chemPointISAT* elementRight,
132  );
133 
134 
135  // Member Functions
136 
137  //- Access
138 
139  inline chemPointISAT*& leafLeft()
140  {
141  return leafLeft_;
142  }
143 
144  inline chemPointISAT*& leafRight()
145  {
146  return leafRight_;
147  }
148 
149  inline binaryNode*& nodeLeft()
150  {
151  return nodeLeft_;
152  }
153 
154  inline binaryNode*& nodeRight()
155  {
156  return nodeRight_;
157  }
158 
159  inline binaryNode*& parent()
160  {
161  return parent_;
162  }
163 
164  //- Topology
165 
166  inline const scalarField& v() const
167  {
168  return v_;
169  }
170 
171  inline const scalar& a() const
172  {
173  return a_;
174  }
175 };
176 
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 } // End namespace Foam
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 #include "binaryNodeI.H"
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 #endif
189 
190 // ************************************************************************* //
Node of the binary tree.
Definition: binaryNode.H:49
scalarField v_
Definition: binaryNode.H:68
binaryNode *& parent()
Definition: binaryNode.H:158
chemPointISAT * leafRight_
Element on the right.
Definition: binaryNode.H:57
void calcV(const chemPointISAT &elementLeft, const chemPointISAT &elementRight, scalarField &v)
Compute vector v:
Definition: binaryNode.C:63
binaryNode()
Construct null.
Definition: binaryNode.C:31
chemPointISAT *& leafLeft()
Access.
Definition: binaryNode.H:138
const scalarField & v() const
Topology.
Definition: binaryNode.H:165
binaryNode * nodeRight_
Node which follows on the right.
Definition: binaryNode.H:63
binaryNode * parent_
Parent node.
Definition: binaryNode.H:66
binaryNode *& nodeRight()
Definition: binaryNode.H:153
binaryNode * nodeLeft_
Node which follows on the left.
Definition: binaryNode.H:60
scalar calcA(const chemPointISAT &elementLeft, const chemPointISAT &elementRight)
Compute a the product v^T.phih, with phih = (phi0 + phiq)/2.
Definition: binaryNodeI.H:30
chemPointISAT *& leafRight()
Definition: binaryNode.H:143
binaryNode *& nodeLeft()
Definition: binaryNode.H:148
const scalar & a() const
Definition: binaryNode.H:170
chemPointISAT * leafLeft_
Element on the left.
Definition: binaryNode.H:54
Leaf of the binary tree. The chemPoint stores the composition 'phi', the mapping of this composition ...
Namespace for OpenFOAM.