RootsI.H
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) 2017 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
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
28// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29
30template <Foam::direction N>
32:
33 types_(0)
34{
35 forAll(*this, i)
36 {
37 type(i, roots::nan);
38 }
39}
40
41
42template <Foam::direction N>
43inline Foam::Roots<N>::Roots(const roots::type t, const scalar x)
44:
45 types_(0)
46{
47 forAll(*this, i)
48 {
49 this->v_[i] = x;
50 type(i, t);
51 }
52}
53
54
55template <Foam::direction N>
57(
58 const roots::type t,
59 const scalar x,
60 const Roots<N - 1>& xs
61)
62:
63 types_(0)
64{
65 this->v_[0] = x;
66 type(0, t);
67 forAll(xs, i)
68 {
69 this->v_[i+1] = xs[i];
70 type(i + 1, xs.type(i));
71 }
72}
73
74
75template <Foam::direction N>
77(
78 const Roots<N - 1>& xs,
79 const roots::type t,
80 const scalar x
81)
82:
83 types_(0)
84{
85 forAll(xs, i)
86 {
87 this->v_[i] = xs[i];
88 type(i, xs.type(i));
89 }
90 this->v_[N-1] = x;
91 type(N - 1, t);
92}
93
94
95template <Foam::direction N>
96template <Foam::direction M>
98(
99 const Roots<M>& xs,
100 const Roots<N - M>& ys
101)
102:
103 types_(0)
104{
105 forAll(xs, i)
106 {
107 this->v_[i] = xs[i];
108 type(i, xs.type(i));
109 }
110 forAll(ys, i)
111 {
112 this->v_[i + M] = ys[i];
113 type(i + M, ys.type(i));
114 }
115}
116
117
118// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
119
120template <Foam::direction N>
122(
123 const direction i,
124 const roots::type t
125)
126{
127 types_ += (t - type(i)) << 3*i;
128}
129
130
131template <Foam::direction N>
133{
134 return static_cast<roots::type>((types_ >> 3*i) & 7);
135}
136
137
138// ************************************************************************* //
#define M(I)
Templated storage for the roots of polynomial equations, plus flags to indicate the nature of the roo...
Definition: Roots.H:73
void type(const direction i, const roots::type t)
Set the type of the i-th root.
Definition: RootsI.H:122
Roots()
Construct null.
Definition: RootsI.H:31
scalar v_[Ncmpts]
The components of this vector space.
Definition: VectorSpace.H:83
type
Volume classification types.
Definition: volumeType.H:66
type
Types of root.
Definition: Roots.H:55
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
uint8_t direction
Definition: direction.H:56
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
const Vector< label > N(dict.get< Vector< label > >("N"))