Report patch name instead of index in debug
[foam-extend-3.2.git] / src / foam / fields / CoeffField / scalarCoeffField.H
blob9936f33af9f5067a20f21efc8ec2513e34d87557
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
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     CoeffField<T>
27 Description
28     Template specialisation for scalar coefficients
30 Author
31     Hrvoje Jasak, Wikki Ltd.  All rights reserved.
33 SourceFiles
34     tensorCoeffField.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef scalarCoeffField_H
39 #define scalarCoeffField_H
41 #include "CoeffField.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 template<>
49 class CoeffField<scalar>
51     public scalarField
53 public:
55     // Public data types
57         //- Component type
58         typedef scalar scalarType;
59         typedef scalar linearType;
60         typedef scalar squareType;
63         //- Field type
64         typedef scalarField scalarTypeField;
65         typedef scalarField linearTypeField;
66         typedef scalarField squareTypeField;
69     // Static data members
71         static const char* const typeName;
74     // Constructors
76         //- Construct given size
77         explicit CoeffField<scalar>(const label size)
78         :
79             scalarField(size, pTraits<scalar>::zero)
80         {}
82         //- Construct as copy
83         CoeffField(const CoeffField<scalar>& f)
84         :
85             scalarField(f)
86         {}
88         //- Construct from Istream
89         CoeffField(Istream& is)
90         :
91             scalarField(is)
92         {}
95     // Member functions
97         //- Return active type
98         blockCoeffBase::activeLevel activeType() const;
100         //- Return the field transpose
101         tmp<CoeffField<scalar> > transpose() const;
104         // Return as typed.  Fails when asked for the incorrect type
106             //- Return as scalar field
107             const scalarField& asScalar() const;
108             scalarField& asScalar();
110             //- Return as linear field.  Equal to scalar field
111             const scalarField& asLinear() const;
112             scalarField& asLinear();
114             //- Return as square field.  Equal to scalar field
115             const scalarField& asSquare() const;
116             scalarField& asSquare();
119         //- Return coefficient as a block
120         BlockCoeff<scalar> getCoeff(const label index) const;
122         //- Set coefficient from a block
123         void setCoeff(const label index, const BlockCoeff<scalar>& coeff);
126         // Subset operations
128             //- Get subset with offset and size and store in given field
129             void getSubset
130             (
131                 CoeffField<scalar>& f,
132                 const label start,
133                 const label size
134             ) const;
136             //- Get subset with addressing and store in given field
137             void getSubset
138             (
139                 CoeffField<scalar>& f,
140                 const labelList& addr
141             ) const;
144             //- Set subset with offset and size from given field
145             void setSubset
146             (
147                 const CoeffField<scalar>& f,
148                 const label start,
149                 const label size
150             );
152             //- Get subset with addressing and store in target field
153             void setSubset
154             (
155                 const CoeffField<scalar>& f,
156                 const labelList& addr
157             );
159             //- Zero out subset with offset and size
160             void zeroOutSubset
161             (
162                 const label start,
163                 const label size
164             );
166             //- Zero out subset with addressing
167             void zeroOutSubset
168             (
169                 const labelList& addr
170             );
172             //- Add subset with addressing to field
173             void addSubset
174             (
175                 const CoeffField<scalar>& f,
176                 const labelList& addr
177             );
180     // Member operators
182         void operator=(const scalarField&);
183         void operator=(const tmp<scalarField>&);
186     // IOstream operators
188         friend Ostream& operator<<
189         (
190             Ostream&,
191             const CoeffField<scalar>&
192         );
194         friend Ostream& operator<<
195         (
196             Ostream&,
197             const tmp<CoeffField<scalar> >&
198         );
202 /* * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * */
204 template<>
205 tmp<CoeffField<scalar> > inv(const CoeffField<scalar>& f);
208 template<>
209 void negate
211     CoeffField<scalar>& f,
212     const CoeffField<scalar>& f1
216 template<>
217 void multiply
219     scalarField& f,
220     const CoeffField<scalar>& f1,
221     const scalar& f2
225 template<>
226 void multiply
228     scalarField& f,
229     const CoeffField<scalar>& f1,
230     const scalarField& f2
234 template<>
235 void multiply
237     scalarField& f,
238     const scalarField& f1,
239     const CoeffField<scalar>& f2
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 } // End namespace Foam
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 #endif
251 // ************************************************************************* //