Remove trailing whitespace systematically
[foam-extend-3.2.git] / src / foam / primitives / BlockCoeff / scalarBlockCoeff.H
bloba2a2bf607f3d7b76549b8f7d918cff94c670b79b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     |
5     \\  /    A nd           | For copyright notice see file Copyright
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     BlockCoeff specialisation for terminal class.
27 Description
28     Specialisation of a block coefficient for a scalar: always a scalae.
30 Author
31     Hrvoje Jasak, Wikki Ltd.  All rights reserved.
33 \*---------------------------------------------------------------------------*/
35 #ifndef scalarBlockCoeff_H
36 #define scalarBlockCoeff_H
38 #include "BlockCoeff.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 namespace Foam
45 /*---------------------------------------------------------------------------*\
46                           Class BlockCoeff Declaration
47 \*---------------------------------------------------------------------------*/
49 template<>
50 class BlockCoeff<scalar>
52     public blockCoeffBase
54 public:
56     // Public data types
58         //- Component type
59         typedef scalar Type;
61         typedef Type xType;
63         //- Coefficient type
64         typedef scalar scalarType;
67     //- Multiplication trait
68     class multiply
69     {
70     public:
72         multiply() {}
74         Type operator()(const scalarType& c, const Type& x) const
75         {
76             return c*x;
77         }
78         Type operator()(const BlockCoeff<Type>& c, const Type& x) const
79         {
80             return c.asScalar()*x;
81         }
83         // Inverse functions
84         scalarType inverse(const scalarType& c) const
85         {
86             return 1.0/c;
87         }
89         // Triple product of coefficients
90         scalarType tripleProduct
91         (
92             const scalarType& a,
93             const scalarType& b,
94             const scalarType& c
95         ) const
96         {
97             return a*c/b;
98         }
99     };
102 private:
104     // Private data
106         //- Scalar coefficient
107         scalar scalarCoeff_;
110 public:
112     // Constructors
114         //- Construct null
115         explicit BlockCoeff();
117         //- Construct as copy
118         BlockCoeff(const BlockCoeff<scalar>&);
120         //- Construct from Istream
121         BlockCoeff(Istream&);
123         //- Clone
124         BlockCoeff<scalar> clone() const;
127     // Destructor
129         ~BlockCoeff();
132     // Member functions
134         //- Return active type
135         blockCoeffBase::activeLevel activeType() const;
137         //- Return as scalar
138         const scalar& asScalar() const
139         {
140             return scalarCoeff_;
141         }
143         scalar& asScalar()
144         {
145             return scalarCoeff_;
146         }
148         //- Return as linear
149         const scalar& asLinear() const
150         {
151             return scalarCoeff_;
152         }
154         scalar& asLinear()
155         {
156             return scalarCoeff_;
157         }
159         //- Return as square
160         const scalar& asSquare() const
161         {
162             return scalarCoeff_;
163         }
165         scalar& asSquare()
166         {
167             return scalarCoeff_;
168         }
171         //- Return component
172         scalar component(const direction) const;
175     // Member operators
177         void operator=(const BlockCoeff<scalar>&);
180     // IOstream operators
182         friend Ostream& operator<<
183         (
184             Ostream&,
185             const BlockCoeff<scalar>&
186         );
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 } // End namespace Foam
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 #endif
198 // ************************************************************************* //