Loading...
Searching...
No Matches
dimensionSetExpression.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) 2025 M. Janssens
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
26InNamespace
27 Foam::Expression
28
29Description
30 Expression templates for dimensionSet
31
32SourceFiles
33 dimensionSetExpression.H
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef Foam_dimensionSetExpression_H
38#define Foam_dimensionSetExpression_H
39
40#include "GenericExpression.H"
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44namespace Foam
45{
46namespace Expression
47{
48
49/*---------------------------------------------------------------------------*\
50 Class dimensionSetRefWrap Declaration
51\*---------------------------------------------------------------------------*/
53//- Expression wrap of non-const reference to dimensionSet
55:
56 public GenericExpression<dimensionSetRefWrap>
57{
58 dimensionSet& elems_;
60public:
61 static constexpr bool is_leaf = false; //true;
62
63 //- Construct from components
65 :
66 elems_(elems)
67 {}
68
69 // Construct from GenericExpression, forcing its evaluation.
70 template<typename E>
72 (
73 dimensionSet& elems,
75 )
76 :
77 elems_(elems)
78 {
79 elems_ = expr.evaluate();
80 }
81
82 auto evaluate() const
83 {
84 return elems_;
85 }
86
87 template<typename E>
89 (
91 )
92 {
93 elems_ = expr.evaluate();
94 return elems_;
95 }
96
97 //- Assignment
98 template<typename E>
99 void operator=
100 (
102 )
103 {
104 elems_ = expr.evaluate();
105 }
106};
107
108
109/*---------------------------------------------------------------------------*\
110 Class dimensionSetConstRefWrap Declaration
111\*---------------------------------------------------------------------------*/
112
113//- Expression wrap of const reference to dimensionSet
114class dimensionSetConstRefWrap
115:
116 public GenericExpression<dimensionSetConstRefWrap>
117{
118 const dimensionSet& elems_;
119
120public:
121
122 // ! Store as copy (since holds reference)
123 static constexpr bool is_leaf = false;
124
125 //- Construct from components
128 elems_(elems)
129 {}
130
131 auto evaluate() const
133 return elems_;
134 }
135};
136
138// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139
140} // End namespace Expression
141} // End namespace Foam
142
143// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144
145#endif
146
147// ************************************************************************* //
dimensionSetConstRefWrap(const dimensionSet &elems)
Construct from components.
dimensionSetRefWrap(dimensionSet &elems, const GenericExpression< E > &expr)
dimensionSetRefWrap(dimensionSet &elems)
Construct from components.
auto & evaluate(const GenericExpression< E > &expr)
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
A namespace for expression templates.
ListConstRefWrap< typename Expr::value_type > expr
Fully self-contained constant field wrapper. Not needed?
Namespace for OpenFOAM.