BarycentricTensor.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::BarycentricTensor
29 
30 Description
31  Templated 4x3 tensor derived from VectorSpace. Has 12 components.
32  Can represent a barycentric transformation as a matrix-barycentric
33  inner-product.
34 
35 SourceFiles
36  BarycentricTensorI.H
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef Foam_BarycentricTensor_H
41 #define Foam_BarycentricTensor_H
42 
43 #include "Barycentric.H"
44 #include "Tensor.H"
45 #include "Vector.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class BarycentricTensor Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 template<class Cmpt>
58 :
59  public MatrixSpace<BarycentricTensor<Cmpt>, Cmpt, 4, 3>
60 {
61 public:
62 
63  // Typedefs
64 
65  //- Equivalent type of labels used for valid component indexing
66  //- (unused)
68 
69 
70  // Member Constants
71 
72  //- Rank of BarycentricTensor is 2
73  static constexpr direction rank = 2;
74 
75 
76  //- Component labeling enumeration
77  enum components { XA, XB, XC, XD, YA, YB, YC, YD, ZA, ZB, ZC, ZD };
78 
79 
80  // Generated Methods: copy construct/assignment
81 
82  //- Default construct
83  BarycentricTensor() = default;
84 
85 
86  // Constructors
87 
88  //- Construct initialised to zero
89  inline BarycentricTensor(const Foam::zero);
90 
91  //- Construct given three barycentric components (rows)
92  inline BarycentricTensor
93  (
94  const Barycentric<Cmpt>& x,
95  const Barycentric<Cmpt>& y,
96  const Barycentric<Cmpt>& z
97  );
98 
99  //- Construct given four vector components (columns)
100  // Eg, the corners of a tetrahedron
101  inline BarycentricTensor
102  (
103  const Vector<Cmpt>& a,
104  const Vector<Cmpt>& b,
105  const Vector<Cmpt>& c,
106  const Vector<Cmpt>& d
107  );
108 
109 
110  // Member Functions
111 
112  // Component Access
113 
114  const Cmpt& xa() const noexcept { return this->v_[XA]; }
115  const Cmpt& xb() const noexcept { return this->v_[XB]; }
116  const Cmpt& xc() const noexcept { return this->v_[XC]; }
117  const Cmpt& xd() const noexcept { return this->v_[XD]; }
118 
119  const Cmpt& ya() const noexcept { return this->v_[YA]; }
120  const Cmpt& yb() const noexcept { return this->v_[YB]; }
121  const Cmpt& yc() const noexcept { return this->v_[YC]; }
122  const Cmpt& yd() const noexcept { return this->v_[YD]; }
123 
124  const Cmpt& za() const noexcept { return this->v_[ZA]; }
125  const Cmpt& zb() const noexcept { return this->v_[ZB]; }
126  const Cmpt& zc() const noexcept { return this->v_[ZC]; }
127  const Cmpt& zd() const noexcept { return this->v_[ZD]; }
128 
130  // Row-barycentric access
132  inline Barycentric<Cmpt> x() const;
133  inline Barycentric<Cmpt> y() const;
134  inline Barycentric<Cmpt> z() const;
137  // Column-vector access
138 
139  inline Vector<Cmpt> a() const;
140  inline Vector<Cmpt> b() const;
141  inline Vector<Cmpt> c() const;
142  inline Vector<Cmpt> d() const;
143 
144 
145  // Operations
146 
147  //- Tensor/barycentric inner product
148  // (transforms barycentric coordinates to vector)
149  inline Vector<Cmpt> inner(const Barycentric<Cmpt>& bry) const;
150 };
151 
152 
153 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
154 
155 //- Data are contiguous if component type is contiguous
156 template<class Cmpt>
157 struct is_contiguous<BarycentricTensor<Cmpt>> : is_contiguous<Cmpt> {};
158 
159 //- Data are contiguous label if component type is label
160 template<class Cmpt>
161 struct is_contiguous_label<BarycentricTensor<Cmpt>>
162 :
163  is_contiguous_label<Cmpt>
164 {};
165 
166 //- Data are contiguous scalar if component type is scalar
167 template<class Cmpt>
168 struct is_contiguous_scalar<BarycentricTensor<Cmpt>>
169 :
170  is_contiguous_scalar<Cmpt>
171 {};
173 
174 template<class Cmpt>
175 class typeOfTranspose<Cmpt, BarycentricTensor<Cmpt>>
176 {
177 public:
179  typedef void type;
180 };
181 
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 } // End namespace Foam
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 #include "BarycentricTensorI.H"
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #endif
195 // ************************************************************************* //
const Cmpt & yb() const noexcept
uint8_t direction
Definition: direction.H:46
Vector< Cmpt > inner(const Barycentric< Cmpt > &bry) const
Tensor/barycentric inner product.
Barycentric< Cmpt > x() const
Vector< Cmpt > b() const
const Cmpt & yd() const noexcept
const Cmpt & ya() const noexcept
static constexpr direction rank
Rank of BarycentricTensor is 2.
const Cmpt & zc() const noexcept
Barycentric< Cmpt > z() const
Templated matrix space.
Definition: MatrixSpace.H:54
const Cmpt & xb() const noexcept
components
Component labeling enumeration.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
const Cmpt & xd() const noexcept
Barycentric< Cmpt > y() const
const Cmpt & yc() const noexcept
BarycentricTensor< label > labelType
Equivalent type of labels used for valid component indexing (unused)
const Cmpt & za() const noexcept
Vector< Cmpt > d() const
Abstract template class to provide the transpose form of a form.
Definition: products.H:62
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross-product operators.
Definition: Vector.H:58
const direction noexcept
Definition: Scalar.H:258
const Cmpt & xa() const noexcept
Templated 3D Barycentric derived from VectorSpace. Has 4 components, one of which is redundant...
Definition: Barycentric.H:50
BarycentricTensor()=default
Default construct.
A template class to specify that a data type can be considered as being contiguous in memory...
Definition: contiguous.H:70
Templated 4x3 tensor derived from VectorSpace. Has 12 components. Can represent a barycentric transfo...
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
Vector< Cmpt > a() const
const Cmpt & zd() const noexcept
const Cmpt & zb() const noexcept
Vector< Cmpt > c() const
Cmpt v_[Ncmpts]
The components of this vector space.
Definition: VectorSpace.H:81
Namespace for OpenFOAM.
const Cmpt & xc() const noexcept