1 /*---------------------------------------------------------------------------*\
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 -------------------------------------------------------------------------------
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/>.
28 Template specialisation for scalar coefficients
31 Hrvoje Jasak, Wikki Ltd. All rights reserved.
36 \*---------------------------------------------------------------------------*/
38 #ifndef scalarCoeffField_H
39 #define scalarCoeffField_H
41 #include "CoeffField.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 class CoeffField<scalar>
58 typedef scalar scalarType;
59 typedef scalar linearType;
60 typedef scalar squareType;
64 typedef scalarField scalarTypeField;
65 typedef scalarField linearTypeField;
66 typedef scalarField squareTypeField;
69 // Static data members
71 static const char* const typeName;
76 //- Construct given size
77 explicit CoeffField<scalar>(const label size)
79 scalarField(size, pTraits<scalar>::zero)
83 CoeffField(const CoeffField<scalar>& f)
88 //- Construct from Istream
89 CoeffField(Istream& is)
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);
128 //- Get subset with offset and size and store in given field
131 CoeffField<scalar>& f,
136 //- Get subset with addressing and store in given field
139 CoeffField<scalar>& f,
140 const labelList& addr
144 //- Set subset with offset and size from given field
147 const CoeffField<scalar>& f,
152 //- Get subset with addressing and store in target field
155 const CoeffField<scalar>& f,
156 const labelList& addr
159 //- Zero out subset with offset and size
166 //- Zero out subset with addressing
169 const labelList& addr
172 //- Add subset with addressing to field
175 const CoeffField<scalar>& f,
176 const labelList& addr
182 void operator=(const scalarField&);
183 void operator=(const tmp<scalarField>&);
186 // IOstream operators
188 friend Ostream& operator<<
191 const CoeffField<scalar>&
194 friend Ostream& operator<<
197 const tmp<CoeffField<scalar> >&
202 /* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */
205 tmp<CoeffField<scalar> > inv(const CoeffField<scalar>& f);
211 CoeffField<scalar>& f,
212 const CoeffField<scalar>& f1
220 const CoeffField<scalar>& f1,
229 const CoeffField<scalar>& f1,
230 const scalarField& f2
238 const scalarField& f1,
239 const CoeffField<scalar>& f2
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 } // End namespace Foam
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 // ************************************************************************* //