Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / blockMatrix / CoeffField / scalarCoeffField.H
bloba11c5852f44b98440993723b427e9da00067bb4f
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-6 H. Jasak All rights reserved
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM 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 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 Class
26     CoeffField<T>
28 Description
29     Template specialisation for scalar coefficients
31 Author
32     Hrvoje Jasak, Wikki Ltd.  All rights reserved.
34 SourceFiles
35     tensorCoeffField.C
37 \*---------------------------------------------------------------------------*/
39 #ifndef scalarCoeffField_H
40 #define scalarCoeffField_H
42 #include "CoeffField.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 template<>
50 class CoeffField<scalar>
52     public scalarField
54 public:
56     // Public data types
58         //- Component type
59         typedef scalar scalarType;
60         typedef scalar linearType;
62         //- Field type
63         typedef scalarField scalarTypeField;
64         typedef scalarField linearTypeField;
67     // Static data members
69         static const char* const typeName;
72     // Constructors
74         //- Construct given size
75         explicit CoeffField<scalar>(const label size)
76         :
77             scalarField(size, pTraits<scalar>::zero)
78         {}
80         //- Construct as copy
81         CoeffField(const CoeffField<scalar>& f)
82         :
83             scalarField(f)
84         {}
86         //- Construct from Istream
87         CoeffField(Istream& is)
88         :
89             scalarField(is)
90         {}
93     // Member functions
95         //- Return active type
96         blockCoeffBase::activeLevel activeType() const;
98         //- Return the field transpose
99         tmp<CoeffField<scalar> > transpose() const;
102         // Return as typed.  Fails when asked for the incorrect type
104             //- Return as scalar field
105             const scalarField& asScalar() const;
106             scalarField& asScalar();
108             //- Return as linear field.  Equal to scalar field
109             const scalarField& asLinear() const;
110             scalarField& asLinear();
113         //- Return coefficient as a block
114         BlockCoeff<scalar> getCoeff(const label index) const;
116         //- Set coefficient from a block
117         void setCoeff(const label index, const BlockCoeff<scalar>& coeff);
120         // Subset operations
122             //- Get subset with offset and size and store in given field
123             void getSubset
124             (
125                 CoeffField<scalar>& f,
126                 const label start,
127                 const label size
128             ) const;
130             //- Get subset with addressing and store in given field
131             void getSubset
132             (
133                 CoeffField<scalar>& f,
134                 const labelList& addr
135             ) const;
138             //- Set subset with offset and size from given field
139             void setSubset
140             (
141                 const CoeffField<scalar>& f,
142                 const label start,
143                 const label size
144             );
146             //- Get subset with addressing and store in target field
147             void setSubset
148             (
149                 const CoeffField<scalar>& f,
150                 const labelList& addr
151             );
153             //- Zero out subset with offset and size
154             void zeroOutSubset
155             (
156                 const label start,
157                 const label size
158             );
160             //- Zero out subset with addressing
161             void zeroOutSubset
162             (
163                 const labelList& addr
164             );
166             //- Add subset with addressing to field
167             void addSubset
168             (
169                 const CoeffField<scalar>& f,
170                 const labelList& addr
171             );
174     // Member operators
176         void operator=(const scalarField&);
177         void operator=(const tmp<scalarField>&);
180     // IOstream operators
182         friend Ostream& operator<<
183         (
184             Ostream&,
185             const CoeffField<scalar>&
186         );
188         friend Ostream& operator<<
189         (
190             Ostream&,
191             const tmp<CoeffField<scalar> >&
192         );
196 /* * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * */
198 template<>
199 tmp<CoeffField<scalar> > inv(const CoeffField<scalar>& f);
202 template<>
203 void negate
205     CoeffField<scalar>& f,
206     const CoeffField<scalar>& f1
210 template<>
211 void multiply
213     scalarField& f,
214     const CoeffField<scalar>& f1,
215     const scalar& f2
219 template<>
220 void multiply
222     scalarField& f,
223     const CoeffField<scalar>& f1,
224     const scalarField& f2
228 template<>
229 void multiply
231     scalarField& f,
232     const scalarField& f1,
233     const CoeffField<scalar>& f2
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 } // End namespace Foam
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 #endif
245 // ************************************************************************* //