All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2021 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 template<class ThermoType>
50 class binaryNode
51 {
52 
53 public:
54 
55  //- Element on the left
57 
58  //- Element on the right
60 
61  //- Node which follows on the left
63 
64  //- Node which follows on the right
66 
67  //- Parent node
69 
71 
72  scalar a_;
73 
74  //- Compute vector v:
75  // Let E be the ellipsoid which covers the region of accuracy of
76  // the left leaf (previously defined). E is described by
77  // E={phi| ||L^T.(phi-phi0)|| <= 1}, (see chemPoint for more details).
78  // let E' be the transformation of E in a space where E' is a hypersphere
79  // centered at the origin, in this space y=L^T.(phi-phi0) and then
80  // E'={y| ||y||<=1}
81  // let u be the unit vector joining the center of E' and the newly added
82  // composition point in the transformed space
83  // (y2=L^T.(phiq-phi0)),u = y2/||y2|
84  // Then the hyperplane separating the two points is defined as the
85  // perpendicular bisector of the segment linking 0 to y2
86  // H' = {y| u^T.(y-yh) = 0},
87  // where yh = y2/2.
88  // In the original composition space, the hyperplane H is defined by
89  // H = {y| v^T(phi-phih) = 0},
90  // where phih = phi0 + L^-T.yh = (phi0 + phiq) / 2 and v is
91  // L.L^T (phiq-phi0)
92  // v = -------------------- .
93  // ||L.L^T (phiq-phi0)||
94  //
95  // Note : v is not normalised in this implementation since it is used
96  // on both side of an equality to know if one should go on the
97  // left or the right in the binary tree
98  // Parameter:
99  // elementLeft : chemPoint of the left element
100  // elementRight: chemPoint of the right element
101  // v : empty scalar field to store v
102  // Returnq: void (v is stored in the empty scalarField)
103  void calcV
104  (
105  chemPointISAT<ThermoType>*& elementLeft,
106  chemPointISAT<ThermoType>*& elementRight,
107  scalarField& v
108  );
109 
110  //- Compute a the product v^T.phih, with phih = (phi0 + phiq)/2.
111  // When travelling in the binary tree,
112  // to know in which part of the composition space the query point 'phi'
113  // belongs to, v^T.phi is performed. If the result is "> a" then it belongs
114  // to the right part (where phiq is), otherwise it belongs to the left
115  // part (where phi0 is).
116  scalar calcA
117  (
118  chemPointISAT<ThermoType>* elementLeft,
119  chemPointISAT<ThermoType>* elementRight
120  );
121 
122  // Constructors
123 
124  //- Construct null
125  binaryNode();
126 
127  //- Construct from components
128  binaryNode
129  (
130  chemPointISAT<ThermoType>* elementLeft,
131  chemPointISAT<ThermoType>* elementRight,
133  );
134 
135 
136  // Member Functions
137 
138  //- Access
141  {
142  return leafLeft_;
143  }
146  {
147  return leafRight_;
148  }
151  {
152  return nodeLeft_;
153  }
156  {
157  return nodeRight_;
158  }
160  inline binaryNode<ThermoType>*& parent()
161  {
162  return parent_;
163  }
164 
165  //- Topology
167  inline const scalarField& v() const
168  {
169  return v_;
170  }
172  inline scalarField& v()
173  {
174  return v_;
175  }
177  inline const scalar& a() const
178  {
179  return a_;
180  }
182  inline scalar& a()
183  {
184  return a_;
185  }
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #ifdef NoRepository
196  #include "binaryNode.C"
197 #endif
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 #endif
202 
203 // ************************************************************************* //
scalar calcA(chemPointISAT< ThermoType > *elementLeft, chemPointISAT< ThermoType > *elementRight)
Compute a the product v^T.phih, with phih = (phi0 + phiq)/2.
Definition: binaryNode.C:147
chemPointISAT< ThermoType > *& leafLeft()
Access.
Definition: binaryNode.H:139
Leaf of the binary tree. The chemPoint stores the composition &#39;phi&#39;, the mapping of this composition ...
scalarField v_
Definition: binaryNode.H:69
const scalar & a() const
Definition: binaryNode.H:176
binaryNode()
Construct null.
Definition: binaryNode.C:31
chemPointISAT< ThermoType > *& leafRight()
Definition: binaryNode.H:144
chemPointISAT< ThermoType > * leafLeft_
Element on the left.
Definition: binaryNode.H:55
Node of the binary tree.
Definition: binaryNode.H:49
binaryNode< ThermoType > *& parent()
Definition: binaryNode.H:159
binaryNode< ThermoType > *& nodeLeft()
Definition: binaryNode.H:149
binaryNode< ThermoType > * parent_
Parent node.
Definition: binaryNode.H:67
binaryNode< ThermoType > * nodeRight_
Node which follows on the right.
Definition: binaryNode.H:64
binaryNode< ThermoType > * nodeLeft_
Node which follows on the left.
Definition: binaryNode.H:61
binaryNode< ThermoType > *& nodeRight()
Definition: binaryNode.H:154
const scalarField & v() const
Topology.
Definition: binaryNode.H:166
chemPointISAT< ThermoType > * leafRight_
Element on the right.
Definition: binaryNode.H:58
Namespace for OpenFOAM.
void calcV(chemPointISAT< ThermoType > *&elementLeft, chemPointISAT< ThermoType > *&elementRight, scalarField &v)
Compute vector v:
Definition: binaryNode.C:65