Barycentric2D.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  Copyright (C) 2019-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 Class
28  Foam::Barycentric2D
29 
30 Description
31  Templated 2D Barycentric derived from VectorSpace.
32  Has 3 components, one of which is redundant.
33 
34 SourceFiles
35  Barycentric2DI.H
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Foam_Barycentric2D_H
40 #define Foam_Barycentric2D_H
41 
42 #include "contiguous.H"
43 #include "VectorSpace.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class Barycentric2D Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 template<class Cmpt>
55 class Barycentric2D
56 :
57  public VectorSpace<Barycentric2D<Cmpt>, Cmpt, 3>
58 {
59 public:
60 
61  // Typedefs
62 
63  //- Equivalent type of labels used for valid component indexing
65 
66 
67  // Member Constants
68 
69  //- Rank of Barycentric2D is 1
70  static constexpr direction rank = 1;
71 
72 
73  //- Component labeling enumeration
74  enum components { A, B, C };
75 
76 
77  // Generated Methods: copy construct/assignment
78 
79  //- Default construct
80  Barycentric2D() = default;
81 
82 
83  // Constructors
84 
85  //- Construct initialized to zero
86  inline Barycentric2D(const Foam::zero);
87 
88  //- Construct from components
89  inline Barycentric2D(const Cmpt& va, const Cmpt& vb, const Cmpt& vc);
90 
91  //- Construct from two components, calculating third component
92  inline Barycentric2D(const Cmpt& va, const Cmpt& vb);
93 
94 
95  // Member Functions
96 
97  // Component Access
98 
99  const Cmpt& a() const noexcept { return this->v_[A]; }
100  const Cmpt& b() const noexcept { return this->v_[B]; }
101  const Cmpt& c() const noexcept { return this->v_[C]; }
102 
103  Cmpt& a() noexcept { return this->v_[A]; }
104  Cmpt& b() noexcept { return this->v_[B]; }
105  Cmpt& c() noexcept { return this->v_[C]; }
106 
107 
108  // Operations, Tests
110  //- Scalar-product of \c this with another Barycentric2D.
111  inline Cmpt inner(const Barycentric2D<Cmpt>& b2) const;
113  //- True if any coordinate is negative
114  inline bool outside() const;
115 };
116 
117 
118 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
119 
120 //- Data are contiguous if component type is contiguous
121 template<class Cmpt>
122 struct is_contiguous<Barycentric2D<Cmpt>> : is_contiguous<Cmpt> {};
123 
124 //- Data are contiguous label if component type is label
125 template<class Cmpt>
126 struct is_contiguous_label<Barycentric2D<Cmpt>> : is_contiguous_label<Cmpt> {};
127 
128 //- Data are contiguous scalar if component type is scalar
129 template<class Cmpt>
130 struct is_contiguous_scalar<Barycentric2D<Cmpt>> : is_contiguous_scalar<Cmpt>{};
131 
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 } // End namespace Foam
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 #include "Barycentric2DI.H"
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 #endif
144 
145 // ************************************************************************* //
Graphite solid properties.
Definition: C.H:46
uint8_t direction
Definition: direction.H:46
const Cmpt & b() const noexcept
bool outside() const
True if any coordinate is negative.
Templated vector space.
Definition: VectorSpace.H:52
const Cmpt & a() const noexcept
Cmpt inner(const Barycentric2D< Cmpt > &b2) const
Scalar-product of this with another Barycentric2D.
Templated 2D Barycentric derived from VectorSpace. Has 3 components, one of which is redundant...
Definition: Barycentric2D.H:50
components
Component labeling enumeration.
Definition: Barycentric2D.H:75
static constexpr direction rank
Rank of Barycentric2D is 1.
Definition: Barycentric2D.H:69
const direction noexcept
Definition: Scalar.H:258
const Cmpt & c() const noexcept
Barycentric2D< label > labelType
Equivalent type of labels used for valid component indexing.
Definition: Barycentric2D.H:61
A template class to specify that a data type can be considered as being contiguous in memory...
Definition: contiguous.H:70
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
Cmpt v_[Ncmpts]
The components of this vector space.
Definition: VectorSpace.H:81
Namespace for OpenFOAM.
Barycentric2D()=default
Default construct.